diff options
author | Jan Kara <jack@suse.cz> | 2008-04-30 03:52:33 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-04-30 11:29:33 -0400 |
commit | 2deb1acc653cbd5384b107d050d2deba089db2bd (patch) | |
tree | 8d9a944b7f5b08b27d849a1aaa20d6ee3851ae9e /fs/isofs/namei.c | |
parent | 6bfe0b499082fd3950429017cd8ebf2a6c458aa5 (diff) |
isofs: fix access to unallocated memory when reading corrupted filesystem
When a directory on isofs is corrupted, we did not check whether length of the
name in a directory entry and the length of the directory entry itself are
consistent. This could lead to possible access beyond the end of buffer when
the length of the name was too big. Add this sanity check to directory
reading code.
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/isofs/namei.c')
-rw-r--r-- | fs/isofs/namei.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/fs/isofs/namei.c b/fs/isofs/namei.c index 344b247bc29a..8299889a835e 100644 --- a/fs/isofs/namei.c +++ b/fs/isofs/namei.c | |||
@@ -111,6 +111,13 @@ isofs_find_entry(struct inode *dir, struct dentry *dentry, | |||
111 | 111 | ||
112 | dlen = de->name_len[0]; | 112 | dlen = de->name_len[0]; |
113 | dpnt = de->name; | 113 | dpnt = de->name; |
114 | /* Basic sanity check, whether name doesn't exceed dir entry */ | ||
115 | if (de_len < dlen + sizeof(struct iso_directory_record)) { | ||
116 | printk(KERN_NOTICE "iso9660: Corrupted directory entry" | ||
117 | " in block %lu of inode %lu\n", block, | ||
118 | dir->i_ino); | ||
119 | return 0; | ||
120 | } | ||
114 | 121 | ||
115 | if (sbi->s_rock && | 122 | if (sbi->s_rock && |
116 | ((i = get_rock_ridge_filename(de, tmpname, dir)))) { | 123 | ((i = get_rock_ridge_filename(de, tmpname, dir)))) { |