diff options
author | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-05-04 15:09:39 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-05-07 11:56:50 -0400 |
commit | 8792953929b01e82e57bce07cc717a0bf24384bc (patch) | |
tree | a3466b047caff23610fbf0cd5b858aa21138dc22 | |
parent | 7bfac470b517b18d496e96acc90be58353df2159 (diff) |
hfsplus: Fix potential buffer overflows
commit 6f24f892871acc47b40dd594c63606a17c714f77 upstream.
Commit ec81aecb2966 ("hfs: fix a potential buffer overflow") fixed a few
potential buffer overflows in the hfs filesystem. But as Timo Warns
pointed out, these changes also need to be made on the hfsplus
filesystem as well.
Reported-by: Timo Warns <warns@pre-sense.de>
Acked-by: WANG Cong <amwang@redhat.com>
Cc: Alexey Khoroshilov <khoroshilov@ispras.ru>
Cc: Miklos Szeredi <mszeredi@suse.cz>
Cc: Sage Weil <sage@newdream.net>
Cc: Eugene Teo <eteo@redhat.com>
Cc: Roman Zippel <zippel@linux-m68k.org>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Alexey Dobriyan <adobriyan@gmail.com>
Cc: Dave Anderson <anderson@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | fs/hfsplus/catalog.c | 4 | ||||
-rw-r--r-- | fs/hfsplus/dir.c | 11 |
2 files changed, 15 insertions, 0 deletions
diff --git a/fs/hfsplus/catalog.c b/fs/hfsplus/catalog.c index b4ba1b31933..408073ae7a2 100644 --- a/fs/hfsplus/catalog.c +++ b/fs/hfsplus/catalog.c | |||
@@ -360,6 +360,10 @@ int hfsplus_rename_cat(u32 cnid, | |||
360 | err = hfs_brec_find(&src_fd); | 360 | err = hfs_brec_find(&src_fd); |
361 | if (err) | 361 | if (err) |
362 | goto out; | 362 | goto out; |
363 | if (src_fd.entrylength > sizeof(entry) || src_fd.entrylength < 0) { | ||
364 | err = -EIO; | ||
365 | goto out; | ||
366 | } | ||
363 | 367 | ||
364 | hfs_bnode_read(src_fd.bnode, &entry, src_fd.entryoffset, | 368 | hfs_bnode_read(src_fd.bnode, &entry, src_fd.entryoffset, |
365 | src_fd.entrylength); | 369 | src_fd.entrylength); |
diff --git a/fs/hfsplus/dir.c b/fs/hfsplus/dir.c index 4df5059c25d..159f5ebf519 100644 --- a/fs/hfsplus/dir.c +++ b/fs/hfsplus/dir.c | |||
@@ -146,6 +146,11 @@ static int hfsplus_readdir(struct file *filp, void *dirent, filldir_t filldir) | |||
146 | filp->f_pos++; | 146 | filp->f_pos++; |
147 | /* fall through */ | 147 | /* fall through */ |
148 | case 1: | 148 | case 1: |
149 | if (fd.entrylength > sizeof(entry) || fd.entrylength < 0) { | ||
150 | err = -EIO; | ||
151 | goto out; | ||
152 | } | ||
153 | |||
149 | hfs_bnode_read(fd.bnode, &entry, fd.entryoffset, | 154 | hfs_bnode_read(fd.bnode, &entry, fd.entryoffset, |
150 | fd.entrylength); | 155 | fd.entrylength); |
151 | if (be16_to_cpu(entry.type) != HFSPLUS_FOLDER_THREAD) { | 156 | if (be16_to_cpu(entry.type) != HFSPLUS_FOLDER_THREAD) { |
@@ -177,6 +182,12 @@ static int hfsplus_readdir(struct file *filp, void *dirent, filldir_t filldir) | |||
177 | err = -EIO; | 182 | err = -EIO; |
178 | goto out; | 183 | goto out; |
179 | } | 184 | } |
185 | |||
186 | if (fd.entrylength > sizeof(entry) || fd.entrylength < 0) { | ||
187 | err = -EIO; | ||
188 | goto out; | ||
189 | } | ||
190 | |||
180 | hfs_bnode_read(fd.bnode, &entry, fd.entryoffset, | 191 | hfs_bnode_read(fd.bnode, &entry, fd.entryoffset, |
181 | fd.entrylength); | 192 | fd.entrylength); |
182 | type = be16_to_cpu(entry.type); | 193 | type = be16_to_cpu(entry.type); |