maint: remove now-unnecessary #ifdef HAVE_BYTESWAP_H guard
[hivex.git] / lib / hivex.c
index 2abd5bd..946ecf3 100644 (file)
 #include "full-read.h"
 #include "full-write.h"
 
-#ifndef O_CLOEXEC
-#define O_CLOEXEC 0
-#endif
-
 #define STREQ(a,b) (strcmp((a),(b)) == 0)
 #define STRCASEEQ(a,b) (strcasecmp((a),(b)) == 0)
 //#define STRNEQ(a,b) (strcmp((a),(b)) != 0)
@@ -559,7 +555,7 @@ hivex_root (hive_h *h)
 {
   hive_node_h ret = h->rootoffs;
   if (!IS_VALID_BLOCK (h, ret)) {
-    errno = ENOKEY;
+    errno = HIVEX_NO_KEY;
     return 0;
   }
   return ret;
@@ -1062,7 +1058,7 @@ get_values (hive_h *h, hive_node_h node,
 
   size_t i;
   for (i = 0; i < nr_values; ++i) {
-    hive_node_h value = vlist->offset[i];
+    hive_node_h value = le32toh (vlist->offset[i]);
     value += 0x1000;
     if (!IS_VALID_BLOCK (h, value)) {
       if (h->msglvl >= 2)
@@ -2748,8 +2744,7 @@ hivex_node_set_value (hive_h *h, hive_node_h node,
 
  leave_partial:
   for (int i = 0; i < alloc_ct; i += 2) {
-    if (values[i / 2].value != NULL)
-      free (values[i / 2].value);
+    free (values[i / 2].value);
     if (i + 1 < alloc_ct && values[i / 2].key != NULL)
       free (values[i / 2].key);
   }