Skip to content

Commit

Permalink
lib: Promote byte_conversions.h #include to hivex-internal.h
Browse files Browse the repository at this point in the history
This patch addresses a build failure in OS X.  Running git-bisect on a
straightforward build (bootstrap, autogen.sh, configure, make, make
install) showed this as the "Bad commit:"
3e7c039

The issue is that hivex-internal.h uses le32toh in a static inline
function.  In case `configure` doesn't find le32toh, byte_conversions.h
defines it.  But hivex-internal.h doesn't include the safety definition.

OS X demonstrates this a problem.  Neither endian.h nor byteswap.h are
found with `configure` in OS X 10.8.5 (XCode 5), but the headers are
both found in Fedora 19 and Ubuntu 13.04.  This patch to configure.ac
further logs that only ntohl is available for byte swaps:

    @@ -153,6 +153,8 @@ AC_REPLACE_FUNCS([mmap])
     dnl Functions.
     AC_CHECK_FUNCS([bindtextdomain])

    +AC_CHECK_FUNCS([le32toh ntohl bswap_32 __bswap_32])
    +

(As an aside, it's curious that a missing byteswap.h didn't cause
hivex-internal.h to fail to build.)
(As another aside, this is an interesting example of lazy symbol
binding failing with an inline function.)

The problem is resolved by having hivex-internal.h include
byte_conversions.h.  This obviates most of the other direct inclusions
of byte_conversions.h.  (One persists under sh/.)

This patch builds and runs hivexml on images/large fine in Ubuntu 13.04
and Fedora 19.  It also allows builds to succeed in OS X, but doesn't
run hivexml for an unrelated reason.  The _iconv_open
symbol-not-found issue, that I thought was previously resolved
(491ba0f), resurfaced.

Signed-off-by: Alex Nelson <a.nelson@prometheuscomputing.com>
  • Loading branch information
ajnelson authored and rwmjones committed Oct 16, 2013
1 parent 30c130d commit b71ccbb
Show file tree
Hide file tree
Showing 7 changed files with 2 additions and 6 deletions.
1 change: 0 additions & 1 deletion lib/handle.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@

#include "hivex.h"
#include "hivex-internal.h"
#include "byte_conversions.h"

static uint32_t
header_checksum (const hive_h *h)
Expand Down
2 changes: 2 additions & 0 deletions lib/hivex-internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#include <stdarg.h>
#include <stddef.h>

#include "byte_conversions.h"

struct hive_h {
char *filename;
int fd;
Expand Down
1 change: 0 additions & 1 deletion lib/node.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@

#include "hivex.h"
#include "hivex-internal.h"
#include "byte_conversions.h"

hive_node_h
hivex_root (hive_h *h)
Expand Down
1 change: 0 additions & 1 deletion lib/utf16.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@

#include "hivex.h"
#include "hivex-internal.h"
#include "byte_conversions.h"

char *
_hivex_windows_utf16_to_utf8 (/* const */ char *input, size_t len)
Expand Down
1 change: 0 additions & 1 deletion lib/value.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@

#include "hivex.h"
#include "hivex-internal.h"
#include "byte_conversions.h"

int
_hivex_get_values (hive_h *h, hive_node_h node,
Expand Down
1 change: 0 additions & 1 deletion lib/visit.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@

#include "hivex.h"
#include "hivex-internal.h"
#include "byte_conversions.h"

int
hivex_visit (hive_h *h, const struct hivex_visitor *visitor, size_t len,
Expand Down
1 change: 0 additions & 1 deletion lib/write.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@

#include "hivex.h"
#include "hivex-internal.h"
#include "byte_conversions.h"

/*----------------------------------------------------------------------
* Writing.
Expand Down

0 comments on commit b71ccbb

Please sign in to comment.