Skip to content

Commit 6f24f89

Browse files
gregkhtorvalds
authored andcommitted
hfsplus: Fix potential buffer overflows
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 <[email protected]> Acked-by: WANG Cong <[email protected]> Cc: Alexey Khoroshilov <[email protected]> Cc: Miklos Szeredi <[email protected]> Cc: Sage Weil <[email protected]> Cc: Eugene Teo <[email protected]> Cc: Roman Zippel <[email protected]> Cc: Al Viro <[email protected]> Cc: Christoph Hellwig <[email protected]> Cc: Alexey Dobriyan <[email protected]> Cc: Dave Anderson <[email protected]> Cc: stable <[email protected]> Cc: Andrew Morton <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent f756beb commit 6f24f89

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

fs/hfsplus/catalog.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,10 @@ int hfsplus_rename_cat(u32 cnid,
366366
err = hfs_brec_find(&src_fd);
367367
if (err)
368368
goto out;
369+
if (src_fd.entrylength > sizeof(entry) || src_fd.entrylength < 0) {
370+
err = -EIO;
371+
goto out;
372+
}
369373

370374
hfs_bnode_read(src_fd.bnode, &entry, src_fd.entryoffset,
371375
src_fd.entrylength);

fs/hfsplus/dir.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,11 @@ static int hfsplus_readdir(struct file *filp, void *dirent, filldir_t filldir)
150150
filp->f_pos++;
151151
/* fall through */
152152
case 1:
153+
if (fd.entrylength > sizeof(entry) || fd.entrylength < 0) {
154+
err = -EIO;
155+
goto out;
156+
}
157+
153158
hfs_bnode_read(fd.bnode, &entry, fd.entryoffset,
154159
fd.entrylength);
155160
if (be16_to_cpu(entry.type) != HFSPLUS_FOLDER_THREAD) {
@@ -181,6 +186,12 @@ static int hfsplus_readdir(struct file *filp, void *dirent, filldir_t filldir)
181186
err = -EIO;
182187
goto out;
183188
}
189+
190+
if (fd.entrylength > sizeof(entry) || fd.entrylength < 0) {
191+
err = -EIO;
192+
goto out;
193+
}
194+
184195
hfs_bnode_read(fd.bnode, &entry, fd.entryoffset,
185196
fd.entrylength);
186197
type = be16_to_cpu(entry.type);

0 commit comments

Comments
 (0)