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

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