[PATCH] hfs: check key length before reading

Edward Adam Davis posted 1 patch 1 year, 2 months ago
fs/hfs/bnode.c | 3 +++
1 file changed, 3 insertions(+)
[PATCH] hfs: check key length before reading
Posted by Edward Adam Davis 1 year, 2 months ago
The length of the key maybe too large. Add a key length check before reading
the key.

Reported-and-tested-by: syzbot+c6811fc2262cec1e6266@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=c6811fc2262cec1e6266
Signed-off-by: Edward Adam Davis <eadavis@qq.com>
---
 fs/hfs/bnode.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/fs/hfs/bnode.c b/fs/hfs/bnode.c
index 6add6ebfef89..6e38d61da36f 100644
--- a/fs/hfs/bnode.c
+++ b/fs/hfs/bnode.c
@@ -67,6 +67,9 @@ void hfs_bnode_read_key(struct hfs_bnode *node, void *key, int off)
 	else
 		key_len = tree->max_key_len + 1;
 
+	if (key_len > tree->max_key_len + 1)
+		return;
+
 	hfs_bnode_read(node, key, off, key_len);
 }
 
-- 
2.47.0