Skip to content

Commit

Permalink
define MAX_SIZE_BUF
Browse files Browse the repository at this point in the history
esp. for asan: allocation-size-too-big
which is harmless, but throws a better error msg in add_ent_preview for a BLL.
Fixes GH #1006, fuzzing DXF input
  • Loading branch information
rurban committed Sep 28, 2024
1 parent a384325 commit adce77a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@
// strings also 16bits
#define MAX_SIZE_TF 0xFFF0
#define MAX_SIZE_T 0xFFFE
// asan: allocation-size-too-big
#ifdef MAX_MEM
#define MAX_SIZE_BUF MAX_MEM
#else
#define MAX_SIZE_BUF UINT64_C(0x7FFFFFFFFFFFFFFF)
#endif

#if !defined AX_STRCASECMP_HEADER && !defined HAVE_STRCASECMP
EXPORT int strcasecmp (const char *a, const char *b);
Expand Down
2 changes: 1 addition & 1 deletion src/in_dxf.c
Original file line number Diff line number Diff line change
Expand Up @@ -6935,7 +6935,7 @@ add_ent_preview (Dwg_Object *restrict obj, Bit_Chain *restrict dat,
dxf_free_pair (pair);
return dxf_read_pair (dat);
}
if (ent->preview_size > INTMAX_MAX)
if (ent->preview_size >= MAX_SIZE_BUF)
{
LOG_ERROR ("Invalid %s.preview_size", obj->name);
dxf_free_pair (pair);
Expand Down

0 comments on commit adce77a

Please sign in to comment.