nalika / rpms / grub2

Forked from rpms/grub2 2 years ago
Clone

Blame SOURCES/0439-fs-hfsplus-Don-t-fetch-a-key-beyond-the-end-of-the-n.patch

80913e
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
80913e
From: Daniel Axtens <dja@axtens.net>
80913e
Date: Fri, 22 Jan 2021 18:13:56 +1100
80913e
Subject: [PATCH] fs/hfsplus: Don't fetch a key beyond the end of the node
80913e
80913e
Otherwise you get a wild pointer, leading to a bunch of invalid reads.
80913e
Check it falls inside the given node.
80913e
80913e
Signed-off-by: Daniel Axtens <dja@axtens.net>
80913e
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
80913e
---
80913e
 grub-core/fs/hfsplus.c | 4 ++++
80913e
 1 file changed, 4 insertions(+)
80913e
80913e
diff --git a/grub-core/fs/hfsplus.c b/grub-core/fs/hfsplus.c
b32e65
index 03a33ea24..423f4b956 100644
80913e
--- a/grub-core/fs/hfsplus.c
80913e
+++ b/grub-core/fs/hfsplus.c
80913e
@@ -635,6 +635,10 @@ grub_hfsplus_btree_search (struct grub_hfsplus_btree *btree,
80913e
 	      pointer = ((char *) currkey
80913e
 			 + grub_be_to_cpu16 (currkey->keylen)
80913e
 			 + 2);
80913e
+
80913e
+	      if ((char *) pointer > node + btree->nodesize - 2)
80913e
+		return grub_error (GRUB_ERR_BAD_FS, "HFS+ key beyond end of node");
80913e
+
80913e
 	      currnode = grub_be_to_cpu32 (grub_get_unaligned32 (pointer));
80913e
 	      match = 1;
80913e
 	    }