From ebd2ff37a9eba9412456c42398f64a3cb107b79c Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Fri, 13 May 2011 18:19:22 +0100 Subject: [PATCH 1/1] 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. --- generator/generator.ml | 9 ++++++++- lib/hivex.c | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) 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; -- 1.8.3.1