aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Yu <tlyu@mit.edu>2016-08-25 18:02:56 -0400
committerTom Yu <tlyu@mit.edu>2016-09-02 18:37:27 -0400
commitbf8ccad8f2fd6d1ea90d1bd16de117f800ce3730 (patch)
tree408a627cb3e7ba353fe066f329ad8505418c9668
parent694b3ea5f5c966007b46c965424ce40a5979731b (diff)
downloadkrb5-bf8ccad8f2fd6d1ea90d1bd16de117f800ce3730.zip
krb5-bf8ccad8f2fd6d1ea90d1bd16de117f800ce3730.tar.gz
krb5-bf8ccad8f2fd6d1ea90d1bd16de117f800ce3730.tar.bz2
Avoid byte-swap cache corruption in libdb2
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
-rw-r--r--src/plugins/kdb/db2/libdb2/mpool/mpool.c8
-rw-r--r--src/plugins/kdb/db2/libdb2/test/run.test1
2 files changed, 9 insertions, 0 deletions
diff --git a/src/plugins/kdb/db2/libdb2/mpool/mpool.c b/src/plugins/kdb/db2/libdb2/mpool/mpool.c
index 7941a9f..81ecccc 100644
--- a/src/plugins/kdb/db2/libdb2/mpool/mpool.c
+++ b/src/plugins/kdb/db2/libdb2/mpool/mpool.c
@@ -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);
}
diff --git a/src/plugins/kdb/db2/libdb2/test/run.test b/src/plugins/kdb/db2/libdb2/test/run.test
index 729ca1f..b907105 100644
--- a/src/plugins/kdb/db2/libdb2/test/run.test
+++ b/src/plugins/kdb/db2/libdb2/test/run.test
@@ -614,6 +614,7 @@ test13()
echo p
echo k$i
echo d$i
+ echo S
echo g
echo k$i
done > $TMP2