summaryrefslogtreecommitdiffstats
path: root/fs/hfsplus/brec.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/hfsplus/brec.c')
-rw-r--r--fs/hfsplus/brec.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/fs/hfsplus/brec.c b/fs/hfsplus/brec.c
index fa90364..790cd6a 100644
--- a/fs/hfsplus/brec.c
+++ b/fs/hfsplus/brec.c
@@ -42,10 +42,21 @@ u16 hfs_brec_keylen(struct hfs_bnode *node, u16 rec)
recoff = hfs_bnode_read_u16(node, node->tree->node_size - (rec + 1) * 2);
if (!recoff)
return 0;
- if (node->tree->attributes & HFS_TREE_BIGKEYS)
+ if (node->tree->attributes & HFS_TREE_BIGKEYS) {
retval = hfs_bnode_read_u16(node, recoff) + 2;
- else
+ if (retval > node->tree->max_key_len + 2) {
+ printk(KERN_ERR "hfs: keylen %d too large\n",
+ retval);
+ retval = 0;
+ }
+ } else {
retval = (hfs_bnode_read_u8(node, recoff) | 1) + 1;
+ if (retval > node->tree->max_key_len + 1) {
+ printk(KERN_ERR "hfs: keylen %d too large\n",
+ retval);
+ retval = 0;
+ }
+ }
}
return retval;
}
OpenPOWER on IntegriCloud