Skip to content

Commit

Permalink
Avoid byte-swap cache corruption in libdb2
Browse files Browse the repository at this point in the history
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
  • Loading branch information
tlyu committed Aug 29, 2016
1 parent af3e7a4 commit 56d0213
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/plugins/kdb/db2/libdb2/mpool/mpool.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
1 change: 1 addition & 0 deletions src/plugins/kdb/db2/libdb2/test/run.test
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,7 @@ test13()
echo p
echo k$i
echo d$i
echo S
echo g
echo k$i
done > $TMP2
Expand Down

0 comments on commit 56d0213

Please sign in to comment.