]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
hfs: fix namelength memory corruption
authorEric Sesterhenn <snakebyte@gmx.de>
Thu, 16 Oct 2008 05:04:11 +0000 (22:04 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 16 Oct 2008 18:21:46 +0000 (11:21 -0700)
Fix a stack corruption caused by a corrupted hfs filesystem.  If the
catalog name length is corrupted the memcpy overwrites the catalog btree
structure.  Since the field is limited to HFS_NAMELEN bytes in the
structure and the file format, we throw an error if it is too long.

Cc: Roman Zippel <zippel@linux-m68k.org>
Signed-off-by: Eric Sesterhenn <snakebyte@gmx.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
fs/hfs/catalog.c

index ba851576ebb13233eb2c84b4dc968f2caa2218f6..6d98f116ca03d610a1477dc77558c899f5abe48d 100644 (file)
@@ -190,6 +190,10 @@ int hfs_cat_find_brec(struct super_block *sb, u32 cnid,
 
        fd->search_key->cat.ParID = rec.thread.ParID;
        len = fd->search_key->cat.CName.len = rec.thread.CName.len;
+       if (len > HFS_NAMELEN) {
+               printk(KERN_ERR "hfs: bad catalog namelength\n");
+               return -EIO;
+       }
        memcpy(fd->search_key->cat.CName.name, rec.thread.CName.name, len);
        return hfs_brec_find(fd);
 }