[Tux3] [PATCH 04/10] Fix ileaf on-by-one errors
OGAWA Hirofumi
hirofumi at mail.parknet.co.jp
Fri Oct 17 02:43:38 PDT 2008
---
user/test/ileaf.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff -puN user/test/ileaf.c~ileaf-off-by-one user/test/ileaf.c
--- tux3/user/test/ileaf.c~ileaf-off-by-one 2008-10-16 01:20:43.000000000 +0900
+++ tux3-hirofumi/user/test/ileaf.c 2008-10-16 01:20:43.000000000 +0900
@@ -129,7 +129,7 @@ void *ileaf_lookup(BTREE, inum_t inum, s
int isinorder(BTREE, struct ileaf *leaf)
{
u16 *dict = (void *)leaf + btree->sb->blocksize;
- for (int i = 0, offset = 0, limit; --i > -leaf->count; offset = limit)
+ for (int i = 0, offset = 0, limit; --i >= -leaf->count; offset = limit)
if ((limit = dict[i]) < offset)
return 0;
return 1;
@@ -226,7 +226,7 @@ void *ileaf_resize(BTREE, tuxkey_t inum,
u16 *dict = base + btree->sb->blocksize;
unsigned at = inum - leaf->ibase;
- if (at > 64)
+ if (at >= btree->entries_per_leaf)
return NULL;
unsigned extend_empty = at < leaf->count ? 0 : at - leaf->count + 1;
_
_______________________________________________
Tux3 mailing list
Tux3 at tux3.org
http://tux3.org/cgi-bin/mailman/listinfo/tux3
More information about the Tux3
mailing list