X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=hivex%2Fhivex.c;h=ac463465c487b13bd2184314e954a6311bf8efd7;hb=3cf719bc077a5f0d4f1a79279a5ba6e41d53c9b9;hp=85d6c7bee9c0097435a595ba5cd359914a98b260;hpb=a4e27cdf4d3b831792dd20d796dc98a5bc684290;p=libguestfs.git diff --git a/hivex/hivex.c b/hivex/hivex.c index 85d6c7b..ac46346 100644 --- a/hivex/hivex.c +++ b/hivex/hivex.c @@ -45,9 +45,15 @@ #ifndef be64toh #define be64toh(x) __bswap_64 (x) #endif +#ifndef le16toh +#define le16toh(x) (x) +#endif #ifndef le32toh #define le32toh(x) (x) #endif +#ifndef le64toh +#define le64toh(x) (x) +#endif #else #ifndef be32toh #define be32toh(x) (x) @@ -55,9 +61,15 @@ #ifndef be64toh #define be64toh(x) (x) #endif +#ifndef le16toh +#define le16toh(x) __bswap_16 (x) +#endif #ifndef le32toh #define le32toh(x) __bswap_32 (x) #endif +#ifndef le64toh +#define le64toh(x) __bswap_64 (x) +#endif #endif #include "hivex.h" @@ -259,6 +271,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. */ @@ -1019,9 +1033,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 {