]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
ubik: ntohl on reading the replay log
authorAndrew Deason <adeason@sinenomine.net>
Fri, 18 Jun 2010 22:20:22 +0000 (17:20 -0500)
committerRuss Allbery <rra@debian.org>
Wed, 11 Aug 2010 04:46:43 +0000 (21:46 -0700)
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 <adeason@sinenomine.net>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Tested-by: Derrick Brashear <shadow@dementia.org>
(cherry picked from commit eec0d94f519b3e27f255b9b7a637df043951424e)

Change-Id: Ic6b3ba18c843d1f41c45fa69559bea869620439a
Reviewed-on: http://gerrit.openafs.org/2237
Tested-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Tested-by: Derrick Brashear <shadow@dementia.org>
(cherry picked from commit 639c0e467af3d78619e11cf44895809e0b9b8edf)

src/ubik/recovery.c

index 33b95a3302747433e1d3464cb9d24be532b676c3..581abe4b9cdc3e63210cbca4678505f2eeafc8e4 100644 (file)
@@ -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);