[Forensics-changes] [yara] 21/368: Reject zero length jumps in hex strings

Hilko Bengen bengen at moszumanska.debian.org
Sat Jul 1 10:30:06 UTC 2017


This is an automated email from the git hooks/post-receive script.

bengen pushed a commit to annotated tag v3.5.0
in repository yara.

commit a18e9f391fa268a282be263b24e3fe9967c702dc
Author: Victor M. Alvarez <plusvic at gmail.com>
Date:   Fri Jul 3 11:16:31 2015 +0200

    Reject zero length jumps in hex strings
---
 libyara/hex_grammar.c | 4 ++--
 libyara/hex_grammar.y | 4 ++--
 yara-python/tests.py  | 1 +
 3 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/libyara/hex_grammar.c b/libyara/hex_grammar.c
index 6d98bb4..4a4de07 100644
--- a/libyara/hex_grammar.c
+++ b/libyara/hex_grammar.c
@@ -1579,9 +1579,9 @@ yyreduce:
     {
         RE_NODE* re_any;
 
-        if ((yyvsp[(2) - (3)].integer) < 0)
+        if ((yyvsp[(2) - (3)].integer) <= 0)
         {
-          yyerror(yyscanner, lex_env, "invalid negative jump length");
+          yyerror(yyscanner, lex_env, "invalid jump length");
           YYABORT;
         }
 
diff --git a/libyara/hex_grammar.y b/libyara/hex_grammar.y
index 38b72af..f803e00 100644
--- a/libyara/hex_grammar.y
+++ b/libyara/hex_grammar.y
@@ -231,9 +231,9 @@ range
       {
         RE_NODE* re_any;
 
-        if ($2 < 0)
+        if ($2 <= 0)
         {
-          yyerror(yyscanner, lex_env, "invalid negative jump length");
+          yyerror(yyscanner, lex_env, "invalid jump length");
           YYABORT;
         }
 
diff --git a/yara-python/tests.py b/yara-python/tests.py
index 3769379..78b9d44 100644
--- a/yara-python/tests.py
+++ b/yara-python/tests.py
@@ -524,6 +524,7 @@ class TestYara(unittest.TestCase):
         ], '123456789')
 
         self.assertSyntaxError([
+          'rule test { strings: $a = { 01 [0] 02 } condition: $a }',
           'rule test { strings: $a = { [-] 01 02 } condition: $a }',
           'rule test { strings: $a = { 01 02 [-] } condition: $a }',
           'rule test { strings: $a = { 01 02 ([-] 03 | 04) } condition: $a }',

-- 
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