Report abuse

diff -r bc704c9af6d6 user/test/ileaf.c
--- a/user/test/ileaf.c	Tue Sep 02 10:17:39 2008 -0700
+++ b/user/test/ileaf.c	Tue Sep 02 10:39:13 2008 -0700
@@ -133,11 +133,35 @@
        return 1;
 }

+int attr_check(BTREE, struct ileaf *leaf)
+{
+	u16 *dict = (void *)leaf + btree->sb->blocksize;
+	for (int i = 0, offset = 0, limit; i > -leaf->count; i--, offset = limit)
+	{
+		unsigned head, kind, size;
+		limit = dict[i];
+		if ((size = limit - offset) >= 2)
+		{
+			decode16(leaf->table + offset, &head);
+			kind = head >> 12;
+			if (kind < ATTR_MINIMUM || kind > ATTR_MAXIMUM)
+				return 0;
+			if (size - 2 < atsize[kind])
+				return 0;
+		}
+		else return 0;
+	}
+	return 1;
+}
+
 int ileaf_check(BTREE, struct ileaf *leaf)
 {
 	char *why;
 	why = "not an inode table leaf";
 	if (leaf->magic != 0x90de);
+		goto eek;
+	why = "ileaf attribute invalid";
+	if (!attr_check(btree, leaf))
 		goto eek;
 	why = "dict out of order";
 	if (!isinorder(btree, leaf))
diff -r bc704c9af6d6 user/test/tux3.h
--- a/user/test/tux3.h	Tue Sep 02 10:17:39 2008 -0700
+++ b/user/test/tux3.h	Tue Sep 02 10:39:13 2008 -0700
@@ -231,11 +231,13 @@
 block_t balloc(SB);

 enum atkind {
+	ATTR_MINIMUM = 6,
 	MODE_OWNER_ATTR = 6,
 	DATA_BTREE_ATTR = 7,
 	CTIME_SIZE_ATTR = 8,
 	LINK_COUNT_ATTR = 9,
 	MTIME_ATTR = 10,
+	ATTR_MAXIMUM = 10,
 };

 enum atbit {