VisionFive2 Linux kernel

StarFive Tech Linux Kernel for VisionFive (JH7110) boards (mirror)

More than 9999 Commits   32 Branches   54 Tags
author: Amerigo Wang <amwang@redhat.com> 2009-12-14 17:57:37 -0800 committer: Linus Torvalds <torvalds@linux-foundation.org> 2009-12-15 08:53:10 -0800 commit: ec81aecb29668ad71f699f4e7b96ec46691895b6 parent: 4b731d50ff3df6b9141a6c12b088e8eb0109e83c
Commit Summary:
hfs: fix a potential buffer overflow
Diffstat:
1 file changed, 6 insertions, 1 deletion
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)
 	/* try to get the root inode */
 	hfs_find_init(HFS_SB(sb)->cat_tree, &fd);
 	res = hfs_cat_find_brec(sb, HFS_ROOT_CNID, &fd);
-	if (!res)
+	if (!res) {
+		if (fd.entrylength > sizeof(rec) || fd.entrylength < 0) {
+			res =  -EIO;
+			goto bail;
+		}
 		hfs_bnode_read(fd.bnode, &rec, fd.entryoffset, fd.entrylength);
+	}
 	if (res) {
 		hfs_find_exit(&fd);
 		goto bail_no_root;