summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard W.M. Jones <rjones@redhat.com>2011-04-13 14:03:21 +0100
committerRichard W.M. Jones <rjones@redhat.com>2011-04-13 14:04:49 +0100
commit75ea457771cec140fa3376bcc299948096c07acd (patch)
tree3dd2a51a8b77f0b586b040d724338872a840b782
parentc22ed5a6cb58aff70bf74df5b7c1edd33d796ef4 (diff)
downloadhivex-75ea457771cec140fa3376bcc299948096c07acd.tar.gz
hivex-75ea457771cec140fa3376bcc299948096c07acd.tar.xz
hivex-75ea457771cec140fa3376bcc299948096c07acd.zip
Handle odd-length "UTF16" strings.
If the length of the buffer is not even, then this would read a byte of uninitialized data. Fix the length check to avoid this.
-rw-r--r--lib/hivex.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/hivex.c b/lib/hivex.c
index b1f6ea6..71ea5c3 100644
--- a/lib/hivex.c
+++ b/lib/hivex.c
@@ -1384,7 +1384,7 @@ utf16_string_len_in_bytes_max (const char *str, size_t len)
{
size_t ret = 0;
- while (len > 0 && (str[0] || str[1])) {
+ while (len >= 2 && (str[0] || str[1])) {
str += 2;
ret += 2;
len -= 2;