Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/shaggy...
[pandora-kernel.git] / fs / hfs / bfind.c
index 89450ae..f8452a0 100644 (file)
@@ -52,6 +52,10 @@ int __hfs_brec_find(struct hfs_bnode *bnode, struct hfs_find_data *fd)
                rec = (e + b) / 2;
                len = hfs_brec_lenoff(bnode, rec, &off);
                keylen = hfs_brec_keylen(bnode, rec);
+               if (keylen == HFS_BAD_KEYLEN) {
+                       res = -EINVAL;
+                       goto done;
+               }
                hfs_bnode_read(bnode, fd->key, off, keylen);
                cmpval = bnode->tree->keycmp(fd->key, fd->search_key);
                if (!cmpval) {
@@ -64,10 +68,13 @@ int __hfs_brec_find(struct hfs_bnode *bnode, struct hfs_find_data *fd)
                else
                        e = rec - 1;
        } while (b <= e);
-       //printk("%d: %d,%d,%d\n", bnode->this, b, e, rec);
        if (rec != e && e >= 0) {
                len = hfs_brec_lenoff(bnode, e, &off);
                keylen = hfs_brec_keylen(bnode, e);
+               if (keylen == HFS_BAD_KEYLEN) {
+                       res = -EINVAL;
+                       goto done;
+               }
                hfs_bnode_read(bnode, fd->key, off, keylen);
        }
 done:
@@ -127,7 +134,7 @@ int hfs_brec_find(struct hfs_find_data *fd)
        return res;
 
 invalid:
-       printk("HFS: inconsistency in B*Tree (%d,%d,%d,%u,%u)\n",
+       printk(KERN_ERR "hfs: inconsistency in B*Tree (%d,%d,%d,%u,%u)\n",
                height, bnode->height, bnode->type, nidx, parent);
        res = -EIO;
 release:
@@ -199,6 +206,10 @@ int hfs_brec_goto(struct hfs_find_data *fd, int cnt)
 
        len = hfs_brec_lenoff(bnode, fd->record, &off);
        keylen = hfs_brec_keylen(bnode, fd->record);
+       if (keylen == HFS_BAD_KEYLEN) {
+               res = -EINVAL;
+               goto out;
+       }
        fd->keyoffset = off;
        fd->keylength = keylen;
        fd->entryoffset = off + keylen;