]> git.ipfire.org Git - thirdparty/krb5.git/commitdiff
Avoid byte-swap cache corruption in libdb2 527/head
authorTom Yu <tlyu@mit.edu>
Thu, 25 Aug 2016 22:02:56 +0000 (18:02 -0400)
committerTom Yu <tlyu@mit.edu>
Mon, 29 Aug 2016 19:46:29 +0000 (15:46 -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.

ticket: 8483 (new)
target_version: 1.14-next
target_version: 1.13-next
tags: pullup

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

index 79ad61316dd7ce59868663054ed5cc3b66427085..e1de6797ab5abb05a71beedd74d5d8e18abadfcb 100644 (file)
@@ -432,6 +432,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 caf6989ad18f0ea7bfc9b7a706ab28327bde30fc..728a70f9852ca3eb57d601086b3bef81c153e205 100644 (file)
@@ -614,6 +614,7 @@ test13()
                                echo p
                                echo k$i
                                echo d$i
+                               echo S
                                echo g
                                echo k$i
                        done > $TMP2