Skip to content

Commit

Permalink
hfsplus: Fix potential buffer overflows
Browse files Browse the repository at this point in the history
commit 6f24f892871acc47b40dd594c63606a17c714f77 upstream.

Commit ec81aec ("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>
  • Loading branch information
gregkh committed May 7, 2012
1 parent 7bfac47 commit 8792953
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
4 changes: 4 additions & 0 deletions fs/hfsplus/catalog.c
Expand Up @@ -360,6 +360,10 @@ int hfsplus_rename_cat(u32 cnid,
err = hfs_brec_find(&src_fd); err = hfs_brec_find(&src_fd);
if (err) if (err)
goto out; goto out;
if (src_fd.entrylength > sizeof(entry) || src_fd.entrylength < 0) {
err = -EIO;
goto out;
}


hfs_bnode_read(src_fd.bnode, &entry, src_fd.entryoffset, hfs_bnode_read(src_fd.bnode, &entry, src_fd.entryoffset,
src_fd.entrylength); src_fd.entrylength);
Expand Down
11 changes: 11 additions & 0 deletions fs/hfsplus/dir.c
Expand Up @@ -146,6 +146,11 @@ static int hfsplus_readdir(struct file *filp, void *dirent, filldir_t filldir)
filp->f_pos++; filp->f_pos++;
/* fall through */ /* fall through */
case 1: case 1:
if (fd.entrylength > sizeof(entry) || fd.entrylength < 0) {
err = -EIO;
goto out;
}

hfs_bnode_read(fd.bnode, &entry, fd.entryoffset, hfs_bnode_read(fd.bnode, &entry, fd.entryoffset,
fd.entrylength); fd.entrylength);
if (be16_to_cpu(entry.type) != HFSPLUS_FOLDER_THREAD) { if (be16_to_cpu(entry.type) != HFSPLUS_FOLDER_THREAD) {
Expand Down Expand Up @@ -177,6 +182,12 @@ static int hfsplus_readdir(struct file *filp, void *dirent, filldir_t filldir)
err = -EIO; err = -EIO;
goto out; goto out;
} }

if (fd.entrylength > sizeof(entry) || fd.entrylength < 0) {
err = -EIO;
goto out;
}

hfs_bnode_read(fd.bnode, &entry, fd.entryoffset, hfs_bnode_read(fd.bnode, &entry, fd.entryoffset,
fd.entrylength); fd.entrylength);
type = be16_to_cpu(entry.type); type = be16_to_cpu(entry.type);
Expand Down

0 comments on commit 8792953

Please sign in to comment.