diff mbox series

hfs: check key length before reading

Message ID tencent_398177A566523D6B372E972A36064B5C7409@qq.com (mailing list archive)
State New
Headers show
Series hfs: check key length before reading | expand

Commit Message

Edward Adam Davis Nov. 28, 2024, 12:31 p.m. UTC
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 mbox series

Patch

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);
 }