From: Richard W.M. Jones Date: Fri, 13 May 2011 17:19:22 +0000 (+0100) Subject: hivex_root: Return errno == HIVEX_NO_KEY when root key is missing. X-Git-Tag: 1.2.7~3 X-Git-Url: http://git.annexia.org/?a=commitdiff_plain;h=ebd2ff37a9eba9412456c42398f64a3cb107b79c;p=hivex.git hivex_root: Return errno == HIVEX_NO_KEY when root key is missing. Previously we returned errno == ENOKEY. However this was an unfortunate choice of error code since it is not defined in POSIX. As a result it is missing on several platforms. HIVEX_NO_KEY is defined as ENOKEY on platforms where this symbol exists (thus maintaining backwards ABI compatibility), and defined as another POSIX error code otherwise. --- diff --git a/generator/generator.ml b/generator/generator.ml index 9722312..117781a 100755 --- a/generator/generator.ml +++ b/generator/generator.ml @@ -701,6 +701,13 @@ typedef struct hive_h hive_h; typedef size_t hive_node_h; typedef size_t hive_value_h; +#include +#ifdef ENOKEY +# define HIVEX_NO_KEY ENOKEY +#else +# define HIVEX_NO_KEY ENOENT +#endif + /* Pre-defined types. */ enum hive_type { "; @@ -1273,7 +1280,7 @@ exhaustive): Corrupt or unsupported Registry file format. -=item ENOKEY +=item HIVEX_NO_KEY Missing root key. diff --git a/lib/hivex.c b/lib/hivex.c index 7715520..d042f4f 100644 --- a/lib/hivex.c +++ b/lib/hivex.c @@ -559,7 +559,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;