Blob Blame History Raw
From 30c130df972756d651b33a2e0adf8f35052843c6 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Tue, 10 Sep 2013 19:05:15 +0100
Subject: [PATCH] ppc: Fix endianness bug which caused node_add_child to fail.

Code used:

  le32toh (reg_field + 0x1000)

instead of the correct version:

  le32toh (reg_field) + 0x1000

The first incorrect form adds 0x1000 to the possibly byte-swapped
registry field, corrupting it.

I used the following command to look for problems in the remaining
code but did not find any:

  git grep -P 'le\d+toh\s*\([^)]*\+'

NOTE that 'htole32 (reg_field - 0x1000)' is correct.
---
 lib/write.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/write.c b/lib/write.c
index 8515350..bc2251c 100644
--- a/lib/write.c
+++ b/lib/write.c
@@ -570,7 +570,7 @@ insert_subkey (hive_h *h, const char *name,
         struct ntreg_ri_record *ri =
           (struct ntreg_ri_record *) ((char *) h->addr + blocks[i]);
         for (j = 0; j < le16toh (ri->nr_offsets); ++j)
-          if (le32toh (ri->offset[j] + 0x1000) == old_offs) {
+          if (le32toh (ri->offset[j]) + 0x1000 == old_offs) {
             DEBUG (2, "replacing ri (0x%zx) ->offset[%zu] 0x%zx -> 0x%zx",
                    blocks[i], j, old_offs, new_offs);
             ri->offset[j] = htole32 (new_offs - 0x1000);
-- 
1.8.3.1