[Tux3] [PATCH] Add check for valid attr encodings
Conrad Meyer
konrad at tylerc.org
Tue Sep 2 11:57:53 PDT 2008
diff -r bc704c9af6d6 user/test/iattr.c
--- a/user/test/iattr.c Tue Sep 02 10:17:39 2008 -0700
+++ b/user/test/iattr.c Tue Sep 02 11:47:08 2008 -0700
@@ -32,11 +32,28 @@
return need;
}
+int attr_check(void *attrs, unsigned size)
+{
+ void *limit = attrs + size;
+ unsigned head;
+ while (attrs < limit - 1)
+ {
+ attrs = decode16(attrs, &head);
+ kind = head >> 12;
+ if (kind < ATTR_MINIMUM || kind > ATTR_MAXIMUM)
+ return 0;
+ if (attrs + atsize[kind] > limit)
+ return 0;
+ attrs += atsize[kind];
+ }
+ return 1;
+}
+
void *encode_attrs(SB, void *attrs, unsigned size, struct inode *inode)
{
//printf("encode %u attr bytes\n", size);
void *limit = attrs + size - 3;
- for (int kind = 0; kind < 32; kind++) {
+ for (int kind = ATTR_MINIMUM; kind < ATTR_MAXIMUM; kind++) {
if (!(inode->present & (1 << kind)))
continue;
if (attrs >= limit)
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 11:47:08 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 {
_______________________________________________
Tux3 mailing list
Tux3 at tux3.org
http://tux3.org/cgi-bin/mailman/listinfo/tux3
More information about the Tux3
mailing list