X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=hivex%2Fhivex.c;h=b20fe732d2117940495a9a26610e712688a51c2e;hb=7cd4b6aeee3693463b03608a31cf53f21152c2e8;hp=a0a730cdb7db89afbd33d0ea8e8bbf23115f8e47;hpb=d707ecc55ac2de267608435bdc1052176aecff46;p=libguestfs.git diff --git a/hivex/hivex.c b/hivex/hivex.c index a0a730c..b20fe73 100644 --- a/hivex/hivex.c +++ b/hivex/hivex.c @@ -30,7 +30,6 @@ #include #include #include -#include #ifdef HAVE_ENDIAN_H #include #endif @@ -46,13 +45,13 @@ #define be64toh(x) __bswap_64 (x) #endif #ifndef le16toh -#define le32toh(x) (x) +#define le16toh(x) (x) #endif #ifndef le32toh #define le32toh(x) (x) #endif #ifndef le64toh -#define le32toh(x) (x) +#define le64toh(x) (x) #endif #else #ifndef be32toh @@ -271,6 +270,8 @@ hivex_open (const char *filename, int flags) } h->bitmap = calloc (1 + h->size / 32, 1); + if (h->bitmap == NULL) + goto error; #if 0 /* Doesn't work. */ /* Header checksum. */ @@ -1031,9 +1032,12 @@ windows_utf16_to_utf8 (/* const */ char *input, size_t len) size_t r = iconv (ic, &inp, &inlen, &outp, &outlen); if (r == (size_t) -1) { if (errno == E2BIG) { + size_t prev = outalloc; /* Try again with a larger output buffer. */ free (out); outalloc *= 2; + if (outalloc < prev) + return NULL; goto again; } else {