[Forensics-changes] [yara] 195/415: Fix bug in offset (@) operator
Hilko Bengen
bengen at moszumanska.debian.org
Thu Apr 3 05:43:04 UTC 2014
This is an automated email from the git hooks/post-receive script.
bengen pushed a commit to branch debian
in repository yara.
commit 8cd3a5a6ca95f4a9a8fd15ed3fad82cc764fef4a
Author: Victor M. Alvarez <plusvic at gmail.com>
Date: Thu Jul 18 16:22:20 2013 +0000
Fix bug in offset (@) operator
---
libyara/exec.c | 13 ++++++-------
libyara/grammar.c | 2 +-
libyara/grammar.y | 2 +-
3 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/libyara/exec.c b/libyara/exec.c
index 5e951c7..3124fa8 100644
--- a/libyara/exec.c
+++ b/libyara/exec.c
@@ -380,17 +380,16 @@ int yr_execute_code(
string = UINT64_TO_PTR(STRING*, r3);
match = string->matches_list_head;
- found = 0;
+ found = FALSE;
- while (match != NULL)
+ while (match != NULL && !found)
{
if ((match->first_offset >= r1 && match->first_offset <= r2) ||
(match->last_offset >= r1 && match->last_offset <= r2) ||
(match->first_offset <= r1 && match->last_offset >= r2))
{
push(1);
- found = 1;
- break;
+ found = TRUE;
}
if (match->first_offset > r2)
@@ -430,15 +429,15 @@ int yr_execute_code(
string = UINT64_TO_PTR(STRING*, r2);
match = string->matches_list_head;
i = 1;
- found = 0;
+ found = FALSE;
- while (match != NULL)
+ while (match != NULL && !found)
{
if (r1 >= i &&
r1 <= i + match->last_offset - match->first_offset)
{
push(match->first_offset + r1 - i);
- found = 1;
+ found = TRUE;
}
i += match->last_offset - match->first_offset + 1;
diff --git a/libyara/grammar.c b/libyara/grammar.c
index 04ff9d2..ec4283a 100644
--- a/libyara/grammar.c
+++ b/libyara/grammar.c
@@ -2657,7 +2657,7 @@ yyreduce:
case 94:
#line 882 "grammar.y"
{
- int result = yr_parser_emit_with_arg(yyscanner, PUSH, 0, NULL);
+ int result = yr_parser_emit_with_arg(yyscanner, PUSH, 1, NULL);
if (result == ERROR_SUCCESS)
result = yr_parser_reduce_string_identifier(
diff --git a/libyara/grammar.y b/libyara/grammar.y
index d9c556d..6bd21ae 100644
--- a/libyara/grammar.y
+++ b/libyara/grammar.y
@@ -880,7 +880,7 @@ expression : '(' expression ')'
}
| _STRING_OFFSET_
{
- int result = yr_parser_emit_with_arg(yyscanner, PUSH, 0, NULL);
+ int result = yr_parser_emit_with_arg(yyscanner, PUSH, 1, NULL);
if (result == ERROR_SUCCESS)
result = yr_parser_reduce_string_identifier(
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/forensics/yara.git
More information about the forensics-changes
mailing list