aboutsummaryrefslogtreecommitdiffstats
path: root/fs/hfsplus
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@tuxera.com>2010-10-14 09:54:23 -0400
committerChristoph Hellwig <hch@lst.de>2010-10-14 09:54:23 -0400
commit13571a6977f821fab7d9c3cc5f75da52b7732e40 (patch)
tree32b50f122fc37256d3ff8ad40ec905d0c3e540ea /fs/hfsplus
parent9250f925972d03ccc0c0a4dd4e9b794d2ef6d52b (diff)
hfsplus: validate btree flags
Signed-off-by: Christoph Hellwig <hch@tuxera.com>
Diffstat (limited to 'fs/hfsplus')
-rw-r--r--fs/hfsplus/brec.c20
-rw-r--r--fs/hfsplus/btree.c14
2 files changed, 20 insertions, 14 deletions
diff --git a/fs/hfsplus/brec.c b/fs/hfsplus/brec.c
index 790cd6a8605d..2f39d05443e1 100644
--- a/fs/hfsplus/brec.c
+++ b/fs/hfsplus/brec.c
@@ -42,20 +42,12 @@ u16 hfs_brec_keylen(struct hfs_bnode *node, u16 rec)
42 recoff = hfs_bnode_read_u16(node, node->tree->node_size - (rec + 1) * 2); 42 recoff = hfs_bnode_read_u16(node, node->tree->node_size - (rec + 1) * 2);
43 if (!recoff) 43 if (!recoff)
44 return 0; 44 return 0;
45 if (node->tree->attributes & HFS_TREE_BIGKEYS) { 45
46 retval = hfs_bnode_read_u16(node, recoff) + 2; 46 retval = hfs_bnode_read_u16(node, recoff) + 2;
47 if (retval > node->tree->max_key_len + 2) { 47 if (retval > node->tree->max_key_len + 2) {
48 printk(KERN_ERR "hfs: keylen %d too large\n", 48 printk(KERN_ERR "hfs: keylen %d too large\n",
49 retval); 49 retval);
50 retval = 0; 50 retval = 0;
51 }
52 } else {
53 retval = (hfs_bnode_read_u8(node, recoff) | 1) + 1;
54 if (retval > node->tree->max_key_len + 1) {
55 printk(KERN_ERR "hfs: keylen %d too large\n",
56 retval);
57 retval = 0;
58 }
59 } 51 }
60 } 52 }
61 return retval; 53 return retval;
diff --git a/fs/hfsplus/btree.c b/fs/hfsplus/btree.c
index 82caff215e08..22e4d4e32999 100644
--- a/fs/hfsplus/btree.c
+++ b/fs/hfsplus/btree.c
@@ -71,6 +71,11 @@ struct hfs_btree *hfs_btree_open(struct super_block *sb, u32 id)
71 tree->max_key_len); 71 tree->max_key_len);
72 goto fail_page; 72 goto fail_page;
73 } 73 }
74 if (tree->attributes & HFS_TREE_VARIDXKEYS) {
75 printk(KERN_ERR "hfs: invalid extent btree flag\n");
76 goto fail_page;
77 }
78
74 tree->keycmp = hfsplus_ext_cmp_key; 79 tree->keycmp = hfsplus_ext_cmp_key;
75 break; 80 break;
76 case HFSPLUS_CAT_CNID: 81 case HFSPLUS_CAT_CNID:
@@ -79,6 +84,10 @@ struct hfs_btree *hfs_btree_open(struct super_block *sb, u32 id)
79 tree->max_key_len); 84 tree->max_key_len);
80 goto fail_page; 85 goto fail_page;
81 } 86 }
87 if (!(tree->attributes & HFS_TREE_VARIDXKEYS)) {
88 printk(KERN_ERR "hfs: invalid catalog btree flag\n");
89 goto fail_page;
90 }
82 91
83 if (test_bit(HFSPLUS_SB_HFSX, &HFSPLUS_SB(sb)->flags) && 92 if (test_bit(HFSPLUS_SB_HFSX, &HFSPLUS_SB(sb)->flags) &&
84 (head->key_type == HFSPLUS_KEY_BINARY)) 93 (head->key_type == HFSPLUS_KEY_BINARY))
@@ -93,6 +102,11 @@ struct hfs_btree *hfs_btree_open(struct super_block *sb, u32 id)
93 goto fail_page; 102 goto fail_page;
94 } 103 }
95 104
105 if (!(tree->attributes & HFS_TREE_BIGKEYS)) {
106 printk(KERN_ERR "hfs: invalid btree flag\n");
107 goto fail_page;
108 }
109
96 size = tree->node_size; 110 size = tree->node_size;
97 if (!is_power_of_2(size)) 111 if (!is_power_of_2(size))
98 goto fail_page; 112 goto fail_page;