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/dir.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/dir.c')
-rw-r--r-- | fs/isofs/dir.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/fs/isofs/dir.c b/fs/isofs/dir.c index 1ba407c64df1..2f0dc5a14633 100644 --- a/fs/isofs/dir.c +++ b/fs/isofs/dir.c | |||
@@ -145,6 +145,14 @@ static int do_isofs_readdir(struct inode *inode, struct file *filp, | |||
145 | } | 145 | } |
146 | de = tmpde; | 146 | de = tmpde; |
147 | } | 147 | } |
148 | /* Basic sanity check, whether name doesn't exceed dir entry */ | ||
149 | if (de_len < de->name_len[0] + | ||
150 | sizeof(struct iso_directory_record)) { | ||
151 | printk(KERN_NOTICE "iso9660: Corrupted directory entry" | ||
152 | " in block %lu of inode %lu\n", block, | ||
153 | inode->i_ino); | ||
154 | return -EIO; | ||
155 | } | ||
148 | 156 | ||
149 | if (first_de) { | 157 | if (first_de) { |
150 | isofs_normalize_block_and_offset(de, | 158 | isofs_normalize_block_and_offset(de, |