mirror of
https://github.com/VirusTotal/yara.git
synced 2026-10-12 02:10:00 +00:00
Fix heap overflow. (#2178)
A heap overflow could occur when loading a hand-crafted compiled rules file. If the used field is less than sizeof(void) an integer overflow occurs that bypasses the file validation and causes heap overflow later on.
This commit is contained in:
+5
-3
@@ -597,9 +597,11 @@ int yr_arena_load_stream(YR_STREAM* stream, YR_ARENA** arena)
|
||||
{
|
||||
YR_ARENA_BUFFER* b = &new_arena->buffers[reloc_ref.buffer_id];
|
||||
|
||||
if (reloc_ref.buffer_id >= new_arena->num_buffers ||
|
||||
reloc_ref.offset > b->used - sizeof(void*) ||
|
||||
b->data == NULL)
|
||||
if (b->data == NULL ||
|
||||
b->used < sizeof(void*) ||
|
||||
b->used > b->size ||
|
||||
reloc_ref.buffer_id >= new_arena->num_buffers ||
|
||||
reloc_ref.offset > b->used - sizeof(void*))
|
||||
{
|
||||
yr_arena_release(new_arena);
|
||||
return ERROR_CORRUPT_FILE;
|
||||
|
||||
Reference in New Issue
Block a user