[Forensics-changes] [yara] 35/135: Fix issue with undefined strings
Hilko Bengen
bengen at moszumanska.debian.org
Sat Jul 1 10:27:30 UTC 2017
This is an automated email from the git hooks/post-receive script.
bengen pushed a commit to annotated tag v3.1.0
in repository yara.
commit 51aeb0ebb8285e82fc680e391fb4d60289c17e34
Author: Victor M. Alvarez <plusvic at gmail.com>
Date: Thu Jul 3 12:06:20 2014 +0200
Fix issue with undefined strings
---
libyara/exec.c | 28 ++++++++++++++++++++++------
1 file changed, 22 insertions(+), 6 deletions(-)
diff --git a/libyara/exec.c b/libyara/exec.c
index 4916646..8768778 100644
--- a/libyara/exec.c
+++ b/libyara/exec.c
@@ -272,20 +272,33 @@ int yr_execute_code(
case OP_SZ_EQ:
pop(r2);
pop(r1);
- push(strcmp(UINT64_TO_PTR(char*, r1),
- UINT64_TO_PTR(char*, r2)) == 0);
+
+ if (IS_UNDEFINED(r1) || IS_UNDEFINED(r2))
+ push(UNDEFINED);
+ else
+ push(strcmp(UINT64_TO_PTR(char*, r1),
+ UINT64_TO_PTR(char*, r2)) == 0);
break;
case OP_SZ_NEQ:
pop(r2);
pop(r1);
- push(strcmp(UINT64_TO_PTR(char*, r1),
- UINT64_TO_PTR(char*, r2)) != 0);
+
+ if (IS_UNDEFINED(r1) || IS_UNDEFINED(r2))
+ push(UNDEFINED);
+ else
+ push(strcmp(UINT64_TO_PTR(char*, r1),
+ UINT64_TO_PTR(char*, r2)) != 0);
break;
case OP_SZ_TO_BOOL:
pop(r1);
- push(strlen(UINT64_TO_PTR(char*, r1)) > 0);
+
+ if (IS_UNDEFINED(r1))
+ push(UNDEFINED);
+ else
+ push(strlen(UINT64_TO_PTR(char*, r1)) > 0);
+
break;
case OP_ADD:
@@ -410,7 +423,10 @@ int yr_execute_code(
break;
case OBJECT_TYPE_STRING:
- push(PTR_TO_UINT64(((YR_OBJECT_STRING*) object)->value));
+ if (((YR_OBJECT_STRING*) object)->value != NULL)
+ push(PTR_TO_UINT64(((YR_OBJECT_STRING*) object)->value));
+ else
+ push(UNDEFINED);
break;
default:
--
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