diff options
Diffstat (limited to 'fs')
-rw-r--r-- | fs/hfs/catalog.c | 4 | ||||
-rw-r--r-- | fs/hfs/dir.c | 11 | ||||
-rw-r--r-- | fs/hfs/super.c | 7 |
3 files changed, 21 insertions, 1 deletions
diff --git a/fs/hfs/catalog.c b/fs/hfs/catalog.c index 6d98f116ca03..424b0337f524 100644 --- a/fs/hfs/catalog.c +++ b/fs/hfs/catalog.c | |||
@@ -289,6 +289,10 @@ int hfs_cat_move(u32 cnid, struct inode *src_dir, struct qstr *src_name, | |||
289 | err = hfs_brec_find(&src_fd); | 289 | err = hfs_brec_find(&src_fd); |
290 | if (err) | 290 | if (err) |
291 | goto out; | 291 | goto out; |
292 | if (src_fd.entrylength > sizeof(entry) || src_fd.entrylength < 0) { | ||
293 | err = -EIO; | ||
294 | goto out; | ||
295 | } | ||
292 | 296 | ||
293 | hfs_bnode_read(src_fd.bnode, &entry, src_fd.entryoffset, | 297 | hfs_bnode_read(src_fd.bnode, &entry, src_fd.entryoffset, |
294 | src_fd.entrylength); | 298 | src_fd.entrylength); |
diff --git a/fs/hfs/dir.c b/fs/hfs/dir.c index 7c69b98a2e45..2b3b8611b41b 100644 --- a/fs/hfs/dir.c +++ b/fs/hfs/dir.c | |||
@@ -79,6 +79,11 @@ static int hfs_readdir(struct file *filp, void *dirent, filldir_t filldir) | |||
79 | filp->f_pos++; | 79 | filp->f_pos++; |
80 | /* fall through */ | 80 | /* fall through */ |
81 | case 1: | 81 | case 1: |
82 | if (fd.entrylength > sizeof(entry) || fd.entrylength < 0) { | ||
83 | err = -EIO; | ||
84 | goto out; | ||
85 | } | ||
86 | |||
82 | hfs_bnode_read(fd.bnode, &entry, fd.entryoffset, fd.entrylength); | 87 | hfs_bnode_read(fd.bnode, &entry, fd.entryoffset, fd.entrylength); |
83 | if (entry.type != HFS_CDR_THD) { | 88 | if (entry.type != HFS_CDR_THD) { |
84 | printk(KERN_ERR "hfs: bad catalog folder thread\n"); | 89 | printk(KERN_ERR "hfs: bad catalog folder thread\n"); |
@@ -109,6 +114,12 @@ static int hfs_readdir(struct file *filp, void *dirent, filldir_t filldir) | |||
109 | err = -EIO; | 114 | err = -EIO; |
110 | goto out; | 115 | goto out; |
111 | } | 116 | } |
117 | |||
118 | if (fd.entrylength > sizeof(entry) || fd.entrylength < 0) { | ||
119 | err = -EIO; | ||
120 | goto out; | ||
121 | } | ||
122 | |||
112 | hfs_bnode_read(fd.bnode, &entry, fd.entryoffset, fd.entrylength); | 123 | hfs_bnode_read(fd.bnode, &entry, fd.entryoffset, fd.entrylength); |
113 | type = entry.type; | 124 | type = entry.type; |
114 | len = hfs_mac2asc(sb, strbuf, &fd.key->cat.CName); | 125 | len = hfs_mac2asc(sb, strbuf, &fd.key->cat.CName); |
diff --git a/fs/hfs/super.c b/fs/hfs/super.c index f7fcbe49da72..5ed7252b7b23 100644 --- a/fs/hfs/super.c +++ b/fs/hfs/super.c | |||
@@ -409,8 +409,13 @@ static int hfs_fill_super(struct super_block *sb, void *data, int silent) | |||
409 | /* try to get the root inode */ | 409 | /* try to get the root inode */ |
410 | hfs_find_init(HFS_SB(sb)->cat_tree, &fd); | 410 | hfs_find_init(HFS_SB(sb)->cat_tree, &fd); |
411 | res = hfs_cat_find_brec(sb, HFS_ROOT_CNID, &fd); | 411 | res = hfs_cat_find_brec(sb, HFS_ROOT_CNID, &fd); |
412 | if (!res) | 412 | if (!res) { |
413 | if (fd.entrylength > sizeof(rec) || fd.entrylength < 0) { | ||
414 | res = -EIO; | ||
415 | goto bail; | ||
416 | } | ||
413 | hfs_bnode_read(fd.bnode, &rec, fd.entryoffset, fd.entrylength); | 417 | hfs_bnode_read(fd.bnode, &rec, fd.entryoffset, fd.entrylength); |
418 | } | ||
414 | if (res) { | 419 | if (res) { |
415 | hfs_find_exit(&fd); | 420 | hfs_find_exit(&fd); |
416 | goto bail_no_root; | 421 | goto bail_no_root; |