From 2853452d81881848264d65956c375fda137e5638 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. Reviewed-on: http://gerrit.openafs.org/2224 Tested-by: Andrew Deason Reviewed-by: Derrick Brashear Tested-by: Derrick Brashear (cherry picked from commit eec0d94f519b3e27f255b9b7a637df043951424e) Change-Id: Ic6b3ba18c843d1f41c45fa69559bea869620439a Reviewed-on: http://gerrit.openafs.org/2237 Tested-by: Andrew Deason Reviewed-by: Derrick Brashear Tested-by: Derrick Brashear (cherry picked from commit 639c0e467af3d78619e11cf44895809e0b9b8edf) --- 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 33b95a330..581abe4b9 100644 --- a/src/ubik/recovery.c +++ b/src/ubik/recovery.c @@ -207,6 +207,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); @@ -231,7 +232,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); @@ -250,6 +251,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