mirror of
https://github.com/VirusTotal/yara.git
synced 2026-10-11 22:49:58 +00:00
Fix issue with matches operator not matching empty strings
The `matches` operator was returning false if the left operand was an empty strings. So, `"" matches <some regexp>` was returning false regardless of the regexp used. However, some regexp *do* match the empty strings, like for example `/foo|/`.
This commit is contained in:
@@ -1967,13 +1967,6 @@ int yr_execute_code(YR_SCAN_CONTEXT* context)
|
||||
ensure_defined(r2);
|
||||
ensure_defined(r1);
|
||||
|
||||
if (r1.ss->length == 0)
|
||||
{
|
||||
r1.i = false;
|
||||
push(r1);
|
||||
break;
|
||||
}
|
||||
|
||||
result = yr_re_exec(
|
||||
context,
|
||||
(uint8_t*) r2.re->code,
|
||||
|
||||
@@ -2953,6 +2953,10 @@ static void test_matches_operator()
|
||||
assert_false_rule(
|
||||
"rule test { condition: \"foo\\nbar\" matches /foo.*bar/ }", NULL);
|
||||
|
||||
assert_true_rule("rule test { condition: \"\" matches /foo|/ }", NULL);
|
||||
|
||||
assert_true_rule("rule test { condition: \"\" matches /a||b/ }", NULL);
|
||||
|
||||
YR_DEBUG_FPRINTF(1, stderr, "} // %s()\n", __FUNCTION__);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user