[Forensics-changes] [yara] 10/160: strutils: Made strcmp_w more exact (don't ignore upper byte of wide chars)
Hilko Bengen
bengen at moszumanska.debian.org
Sat Jul 1 10:29:12 UTC 2017
This is an automated email from the git hooks/post-receive script.
bengen pushed a commit to annotated tag v3.4.0
in repository yara.
commit 90d16f8208449f228e6c3df8bf796fefefbd7763
Author: Moritz Kroll <moritz.kroll at avira.com>
Date: Thu Feb 12 08:56:16 2015 +0100
strutils: Made strcmp_w more exact (don't ignore upper byte of wide chars)
---
libyara/strutils.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/libyara/strutils.c b/libyara/strutils.c
index eff9f5a..f456874 100644
--- a/libyara/strutils.c
+++ b/libyara/strutils.c
@@ -174,19 +174,17 @@ int strcmp_w(
const char* w_str,
const char* str)
{
- while (*w_str != 0 && *str != 0 && *w_str == *str)
+ while (*str != 0 && w_str[0] == *str && w_str[1] == 0)
{
w_str += 2;
str += 1;
}
- if (*w_str == *str)
- return 0;
-
- if (*w_str > *str)
+ // Higher-order byte of wide char non-zero? -> w_str is larger than str
+ if (w_str[1] != 0)
return 1;
- return -1;
+ return w_str[0] - *str;
}
--
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