[Libguestfs] [hivex PATCH 3/5] Handle odd-length "UTF16" strings.
Richard W.M. Jones
rjones at redhat.com
Wed Apr 13 13:18:13 UTC 2011
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
virt-top is 'top' for virtual machines. Tiny program with many
powerful monitoring features, net stats, disk stats, logging, etc.
http://et.redhat.com/~rjones/virt-top
-------------- next part --------------
>From 75ea457771cec140fa3376bcc299948096c07acd Mon Sep 17 00:00:00 2001
From: Richard W.M. Jones <rjones at redhat.com>
Date: Wed, 13 Apr 2011 14:03:21 +0100
Subject: [PATCH 3/5] 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.
---
lib/hivex.c | 2 +-
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;
--
1.7.4.1
More information about the Libguestfs
mailing list