X-Git-Url: http://git.annexia.org/?p=libguestfs.git;a=blobdiff_plain;f=hivex%2Fhivex.c;h=4b0deebc60e348bddcb8f395662639e6ee4438b2;hp=a0a730cdb7db89afbd33d0ea8e8bbf23115f8e47;hb=3e70b34eed5a48640e20fbf6dcba774aaace1f3c;hpb=d707ecc55ac2de267608435bdc1052176aecff46 diff --git a/hivex/hivex.c b/hivex/hivex.c index a0a730c..4b0deeb 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 @@ -144,7 +143,7 @@ struct ntreg_hbin_block { } __attribute__((__packed__)); #define BLOCK_ID_EQ(h,offs,eqid) \ - (strncmp (((struct ntreg_hbin_block *)((h)->addr + (offs)))->id, (eqid), 2) == 0) + (STREQLEN (((struct ntreg_hbin_block *)((h)->addr + (offs)))->id, (eqid), 2)) static size_t block_len (hive_h *h, size_t blkoff, int *used) @@ -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. */ @@ -724,7 +725,7 @@ hivex_node_get_child (hive_h *h, hive_node_h node, const char *nname) for (i = 0; children[i] != 0; ++i) { name = hivex_node_name (h, children[i]); if (!name) goto error; - if (strcasecmp (name, nname) == 0) { + if (STRCASEEQ (name, nname)) { ret = children[i]; break; } @@ -855,7 +856,7 @@ hivex_node_get_value (hive_h *h, hive_node_h node, const char *key) for (i = 0; values[i] != 0; ++i) { name = hivex_value_key (h, values[i]); if (!name) goto error; - if (strcasecmp (name, key) == 0) { + if (STRCASEEQ (name, key)) { ret = values[i]; break; } @@ -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 {