Skip to content

Commit 9b4372f

Browse files
wxsBSDplusvic
authored andcommitted
Fix negative indexing in dex module. (#1730)
* Fix negative indexing in dex module. When attempting to call dex_get_integer() or dex_get_string() with a negative index we would eventually land in the assert() at https://github.com/VirusTotal/yara/blob/master/libyara/object.c#L497 failing. Instead of doing that let's check for negative values before going any further, which will at least allow the module to continue processing. * YR_UNDEFINED is < 0 already. Simplify the logic when checking for negative index. * Revert "YR_UNDEFINED is < 0 already. Simplify the logic when checking for negative index." This reverts commit 38af38f.
1 parent da831c2 commit 9b4372f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

libyara/modules/dex/dex.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ static int64_t dex_get_integer(
418418
const char* pattern,
419419
int64_t index)
420420
{
421-
if (index == YR_UNDEFINED)
421+
if (index == YR_UNDEFINED || index < 0)
422422
return YR_UNDEFINED;
423423

424424
// Impose a reasonably large limit to table indexes.
@@ -434,7 +434,7 @@ static SIZED_STRING* dex_get_string(
434434
const char* pattern,
435435
int64_t index)
436436
{
437-
if (index == YR_UNDEFINED)
437+
if (index == YR_UNDEFINED || index < 0)
438438
return NULL;
439439

440440
// Impose a reasonably large limit to table indexes.

0 commit comments

Comments
 (0)