]> git.ipfire.org Git - thirdparty/krb5.git/commitdiff
Avoid byte-swap cache corruption in libdb2
authorTom Yu <tlyu@mit.edu>
Thu, 25 Aug 2016 22:02:56 +0000 (18:02 -0400)
committerTom Yu <tlyu@mit.edu>
Fri, 2 Sep 2016 22:37:27 +0000 (18:37 -0400)
Apply a patch from NetBSD to restore the cached copy of a page to the
machine byte order after a write operation swapped it to the file byte
order.  As a regression test, modify test13 to sync the database file
after each put to exercise this bug.

(cherry picked from commit 56d02135d4c77b6aa0cb7136477d426248c60a6f)

ticket: 8483
version_fixed: 1.13.7

src/plugins/kdb/db2/libdb2/mpool/mpool.c
src/plugins/kdb/db2/libdb2/test/run.test

index 7941a9f81c1819a9973aed6407850964c2580f7b..81ecccc6e4f481997123a5ec3e58f788b398d1fa 100644 (file)
@@ -431,6 +431,14 @@ mpool_write(mp, bp)
        if (write(mp->fd, bp->page, mp->pagesize) != mp->pagesize)
                return (RET_ERROR);
 
+       /*
+        * Re-run through the input filter since this page may soon be
+        * accessed via the cache, and whatever the user's output filter
+        * did may screw things up if we don't let the input filter
+        * restore the in-core copy.
+        */
+       if (mp->pgin)
+               (mp->pgin)(mp->pgcookie, bp->pgno, bp->page);
        bp->flags &= ~MPOOL_DIRTY;
        return (RET_SUCCESS);
 }
index 729ca1f08dadec4625dcff9fa1f9f3519e6dccf2..b90710585b74ea583bebe800eb2684c8c7f07410 100644 (file)
@@ -614,6 +614,7 @@ test13()
                                echo p
                                echo k$i
                                echo d$i
+                               echo S
                                echo g
                                echo k$i
                        done > $TMP2