Skip to content

Commit

Permalink
Fix buffer overflow in dotnet module.
Browse files Browse the repository at this point in the history
Credit to OSS-Fuzz.
  • Loading branch information
plusvic committed Dec 19, 2018
1 parent a0ef13b commit 7493247
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions libyara/modules/dotnet.c
Expand Up @@ -208,9 +208,13 @@ void dotnet_parse_us(
const uint8_t* offset = pe->data + metadata_root + us_header->Offset;
const uint8_t* end_of_header = offset + us_header->Size;

// Make sure end of header is not past end of PE, and the first entry MUST be
// a single NULL byte.
if (!fits_in_pe(pe, offset, us_header->Size) || *offset != 0x00)
// Make sure the header size is larger than 0 and its end is not past the
// end of PE.
if (us_header->Size == 0 || !fits_in_pe(pe, offset, us_header->Size))
return;

// The first entry MUST be single NULL byte.
if (*offset != 0x00)
return;

offset++;
Expand Down
Binary file not shown.

0 comments on commit 7493247

Please sign in to comment.