summaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorEric Sesterhenn <snakebyte@gmx.de>2008-10-15 22:04:11 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2008-10-16 11:21:46 -0700
commitd38b7aa7fc3371b52d036748028db50b585ade2e (patch)
treefd4193112378362a5c12999d467bdaaf8875d1b0 /fs
parent649f1ee6c705aab644035a7998d7b574193a598a (diff)
downloadop-kernel-dev-d38b7aa7fc3371b52d036748028db50b585ade2e.zip
op-kernel-dev-d38b7aa7fc3371b52d036748028db50b585ade2e.tar.gz
hfs: fix namelength memory corruption
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>
Diffstat (limited to 'fs')
-rw-r--r--fs/hfs/catalog.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/fs/hfs/catalog.c b/fs/hfs/catalog.c
index ba85157..6d98f11 100644
--- a/fs/hfs/catalog.c
+++ b/fs/hfs/catalog.c
@@ -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);
}
OpenPOWER on IntegriCloud