Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some compiler edge cases. #1709

Merged
merged 3 commits into from
May 17, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions docs/writingrules.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1200,6 +1200,18 @@ The keywords ``any``, ``all`` and ``none`` can be used as well.
1 of ($*) // same that "any of them"
none of ($b*) // zero of the set of strings that start with "$b"

.. warning:: Due to the way YARA works internally, using "0 of them" is an
ambiguous part of the language which should be avoided in favor of "none
of them". To understand this, consider the meaning of "2 of them", which
is true if 2 or more of the strings match. Historically, "0 of them"
followed this principle and would evaluate to true if at least one of the
strings matched. This ambiguity is resolved in YARA 4.3.0 by making "0 of
them" evaluate to true if exactly 0 of the strings match. To improve on
the situation and make the intent clear, it is encouraged to use "none" in
place of 0. By not using an integer it is easier to reason about the meaning
of "none of them" without the historical understanding of "at least 0"
clouding the issue.


Starting with YARA 4.2.0 it is possible to express a set of strings in an
integer range, like this:
Expand Down
7 changes: 7 additions & 0 deletions libyara/compiler.c
Original file line number Diff line number Diff line change
Expand Up @@ -1041,6 +1041,13 @@ YR_API char* yr_compiler_get_error_message(
"rule identifier \"%s\" matches previously used wildcard rule set",
compiler->last_error_extra_info);
break;
case ERROR_INVALID_VALUE:
snprintf(
buffer,
buffer_size,
"invalid value in condition: \"%s\"",
compiler->last_error_extra_info);
break;
}

return buffer;
Expand Down
Loading