summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorderaadt <deraadt@openbsd.org>1997-11-13 06:35:06 +0000
committerderaadt <deraadt@openbsd.org>1997-11-13 06:35:06 +0000
commiteab84c552e819ebed4a4628751cdf685494564d8 (patch)
tree8603657955621a294907b82cee3cc431ef03b2a6
parentsync (diff)
downloadwireguard-openbsd-eab84c552e819ebed4a4628751cdf685494564d8.tar.xz
wireguard-openbsd-eab84c552e819ebed4a4628751cdf685494564d8.zip
Bug fixes from Sleepycat Software for db_btree databases; for some corner
cases in splitting pages, and for correctly updating data base metadata.
-rw-r--r--lib/libc/db/btree/bt_page.c4
-rw-r--r--lib/libc/db/btree/bt_split.c7
2 files changed, 7 insertions, 4 deletions
diff --git a/lib/libc/db/btree/bt_page.c b/lib/libc/db/btree/bt_page.c
index db80a7ec332..2552ef2d1fe 100644
--- a/lib/libc/db/btree/bt_page.c
+++ b/lib/libc/db/btree/bt_page.c
@@ -32,7 +32,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char rcsid[] = "$OpenBSD: bt_page.c,v 1.3 1996/08/19 08:20:10 tholo Exp $";
+static char rcsid[] = "$OpenBSD: bt_page.c,v 1.4 1997/11/13 06:35:06 deraadt Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
@@ -65,6 +65,7 @@ __bt_free(t, h)
h->prevpg = P_INVALID;
h->nextpg = t->bt_free;
t->bt_free = h->pgno;
+ F_SET(t, B_METADIRTY);
/* Make sure the page gets written back. */
return (mpool_put(t->bt_mp, h, MPOOL_DIRTY));
@@ -92,6 +93,7 @@ __bt_new(t, npg)
(h = mpool_get(t->bt_mp, t->bt_free, 0)) != NULL) {
*npg = t->bt_free;
t->bt_free = h->nextpg;
+ F_SET(t, B_METADIRTY);
return (h);
}
return (mpool_new(t->bt_mp, npg));
diff --git a/lib/libc/db/btree/bt_split.c b/lib/libc/db/btree/bt_split.c
index a2098a70b5f..06f2eac5121 100644
--- a/lib/libc/db/btree/bt_split.c
+++ b/lib/libc/db/btree/bt_split.c
@@ -35,7 +35,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char rcsid[] = "$OpenBSD: bt_split.c,v 1.3 1996/08/19 08:20:16 tholo Exp $";
+static char rcsid[] = "$OpenBSD: bt_split.c,v 1.4 1997/11/13 06:35:06 deraadt Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
@@ -673,7 +673,8 @@ bt_psplit(t, h, l, r, pskip, ilen)
* where we decide to try and copy too much onto the left page.
* Make sure that doesn't happen.
*/
- if (skip <= off && used + nbytes >= full) {
+ if ((skip <= off && used + nbytes + sizeof(indx_t) >= full) ||
+ nxt == top - 1) {
--off;
break;
}
@@ -686,7 +687,7 @@ bt_psplit(t, h, l, r, pskip, ilen)
memmove((char *)l + l->upper, src, nbytes);
}
- used += nbytes;
+ used += nbytes + sizeof(indx_t);
if (used >= half) {
if (!isbigkey || bigkeycnt == 3)
break;