X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=lib%2Fhivex.c;h=573c4461f8d4c67c12c3220b940b9f91a79fd6b2;hb=54ca9b34eebda11c017b854e54f8891e72f9d131;hp=71ea5c349cdb999c5cb35d4f83c219afa547b904;hpb=75ea457771cec140fa3376bcc299948096c07acd;p=hivex.git diff --git a/lib/hivex.c b/lib/hivex.c index 71ea5c3..573c446 100644 --- a/lib/hivex.c +++ b/lib/hivex.c @@ -62,7 +62,6 @@ #define HIVEX_MAX_ALLOCATION 1000000 static char *windows_utf16_to_utf8 (/* const */ char *input, size_t len); -static size_t utf16_string_len_in_bytes (const char *str); static size_t utf16_string_len_in_bytes_max (const char *str, size_t len); struct hive_h { @@ -1363,23 +1362,10 @@ free_strings (char **argv) } /* Get the length of a UTF-16 format string. Handle the string as - * pairs of bytes, looking for the first \0\0 pair. + * pairs of bytes, looking for the first \0\0 pair. Only read up to + * 'len' maximum bytes. */ static size_t -utf16_string_len_in_bytes (const char *str) -{ - size_t ret = 0; - - while (str[0] || str[1]) { - str += 2; - ret += 2; - } - - return ret; -} - -/* As for utf16_string_len_in_bytes but only read up to a maximum length. */ -static size_t utf16_string_len_in_bytes_max (const char *str, size_t len) { size_t ret = 0; @@ -1421,7 +1407,8 @@ hivex_value_multiple_strings (hive_h *h, hive_value_h value) char *p = data; size_t plen; - while (p < data + len && (plen = utf16_string_len_in_bytes (p)) > 0) { + while (p < data + len && + (plen = utf16_string_len_in_bytes_max (p, data + len - p)) > 0) { nr_strings++; char **ret2 = realloc (ret, (1 + nr_strings) * sizeof (char *)); if (ret2 == NULL) {