[Forensics-changes] [yara] 360/415: Avoid possible stack overflow when compiled with assertions disabled

Hilko Bengen bengen at moszumanska.debian.org
Thu Apr 3 05:43:24 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 d5358cd39fb29f94cc7e205a7e97497c460502f9
Author: Victor Manuel Alvarez <vmalvarez at virustotal.com>
Date:   Wed Jan 15 20:34:57 2014 +0100

    Avoid possible stack overflow when compiled with assertions disabled
---
 libyara/rules.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/libyara/rules.c b/libyara/rules.c
index 2a16573..f802198 100644
--- a/libyara/rules.c
+++ b/libyara/rules.c
@@ -265,6 +265,10 @@ int _yr_scan_fast_hex_re_exec(
                  *(ip + 12) == *next_input))
             {
               assert(sp < MAX_FAST_HEX_RE_STACK);
+
+              if (sp < MAX_FAST_HEX_RE_STACK)
+                return -2;
+
               code_stack[sp] = ip + 11;
               input_stack[sp] = next_input;
               matches_stack[sp] = matches + i;
@@ -669,8 +673,7 @@ int _yr_scan_verify_re_match(
         NULL);
   }
 
-  if (STRING_IS_WIDE(ac_match->string) &&
-      forward_matches < 0)
+  if (STRING_IS_WIDE(ac_match->string) && forward_matches == -1)
   {
     flags |= RE_FLAGS_WIDE;
     forward_matches = exec(
@@ -682,7 +685,10 @@ int _yr_scan_verify_re_match(
         NULL);
   }
 
-  if (forward_matches < 0)
+  if (forward_matches == -2)
+    return ERROR_INTERNAL_FATAL_ERROR;
+
+  if (forward_matches == -1)
     return ERROR_SUCCESS;
 
   if (forward_matches == 0 && ac_match->backward_code == NULL)

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