From eec0d94f519b3e27f255b9b7a637df043951424e Mon Sep 17 00:00:00 2001 From: Andrew Deason Date: Fri, 18 Jun 2010 17:20:22 -0500 Subject: [PATCH] ubik: ntohl on reading the replay log When attempting to read the replay log, ubik was not ntohl'ing all integers that were read in from the log, causing the log to appear invalid on little-endian systems. Fix it. This problem manifests as apparent corruption in the database on top of ubik when a commit is occurring when we are shut down, or a disk error is encountered during a commit. Change-Id: I82e04c59d0f55aa2105b02feb6ee332ea85eb4f3 Reviewed-on: http://gerrit.openafs.org/2224 Tested-by: Andrew Deason Reviewed-by: Derrick Brashear Tested-by: Derrick Brashear --- src/ubik/recovery.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/ubik/recovery.c b/src/ubik/recovery.c index 6787c2314..e9b3b9aef 100644 --- a/src/ubik/recovery.c +++ b/src/ubik/recovery.c @@ -226,6 +226,7 @@ ReplayLog(register struct ubik_dbase *adbase) sizeof(afs_int32)); if (code != sizeof(afs_int32)) break; + opcode = ntohl(opcode); if (opcode == LOGNEW) { /* handle begin trans */ tpos += sizeof(afs_int32); @@ -250,7 +251,7 @@ ReplayLog(register struct ubik_dbase *adbase) if (code != 3 * sizeof(afs_int32)) break; /* otherwise, skip over the data bytes, too */ - tpos += buffer[2] + 3 * sizeof(afs_int32); + tpos += ntohl(buffer[2]) + 3 * sizeof(afs_int32); } else { ubik_dprint("corrupt log opcode (%d) at position %d\n", opcode, tpos); @@ -269,6 +270,7 @@ ReplayLog(register struct ubik_dbase *adbase) sizeof(afs_int32)); if (code != sizeof(afs_int32)) break; + opcode = ntohl(opcode); if (opcode == LOGNEW) { /* handle begin trans */ tpos += sizeof(afs_int32); -- 2.39.5