Skip to content

Commit

Permalink
fix: check mmap result
Browse files Browse the repository at this point in the history
Check if mmap failed (return value MAP_FAILED) and, if yes, exit.
  • Loading branch information
secDre4mer committed Nov 13, 2023
1 parent f3e3bdd commit 2c69c92
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions libyara/proc/linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,11 +230,17 @@ YR_API const uint8_t* yr_process_fetch_memory_block_data(YR_MEMORY_BLOCK* block)
0);
}

if (context->buffer != NULL)
if (context->buffer == MAP_FAILED)
{
context->buffer = NULL;
context->buffer_size = 0;
goto _exit;
}
else if (context->buffer != NULL)
{
context->buffer_size = block->size;
}
else
else // Should according to man page never happen
{
context->buffer_size = 0;
goto _exit;
Expand Down

0 comments on commit 2c69c92

Please sign in to comment.