Skip to content

Commit

Permalink
hfs: fix namelength memory corruption
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Eric Sesterhenn authored and Linus Torvalds committed Oct 16, 2008
1 parent 649f1ee commit d38b7aa
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions fs/hfs/catalog.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit d38b7aa

Please sign in to comment.