Skip to content

Commit

Permalink
bmp: better bounds-checks for wrong header_size
Browse files Browse the repository at this point in the history
Fixes fuzzed GH #354 (Illegal DWG bmp preview)
  • Loading branch information
rurban committed Feb 6, 2022
1 parent 065a311 commit 84c34be
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/dwg.c
Original file line number Diff line number Diff line change
Expand Up @@ -582,10 +582,11 @@ dwg_bmp (const Dwg_Data *restrict dwg, BITCODE_RL *restrict size)
dat.byte += header_size;
if (*size)
LOG_TRACE ("BMP offset: %lu\n", dat.byte);
if (dat.byte > dat.size)
if (dat.byte + *size > dat.size)
{
*size = 0;
LOG_ERROR ("Preview overflow");
LOG_ERROR ("Preview overflow %lu + " FORMAT_RL " > %lu",
dat.byte, *size, dat.size);
return NULL;
}

Expand Down

0 comments on commit 84c34be

Please sign in to comment.