Blame SOURCES/0523-normal-charset-Fix-array-out-of-bounds-formatting-un.patch

0ccc47
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
0ccc47
From: Daniel Axtens <dja@axtens.net>
0ccc47
Date: Tue, 13 Jul 2021 13:24:38 +1000
0ccc47
Subject: [PATCH] normal/charset: Fix array out-of-bounds formatting unicode
0ccc47
 for display
0ccc47
0ccc47
In some cases attempting to display arbitrary binary strings leads
0ccc47
to ASAN splats reading the widthspec array out of bounds.
0ccc47
0ccc47
Check the index. If it would be out of bounds, return a width of 1.
0ccc47
I don't know if that's strictly correct, but we're not really expecting
0ccc47
great display of arbitrary binary data, and it's certainly not worse than
0ccc47
an OOB read.
0ccc47
0ccc47
Signed-off-by: Daniel Axtens <dja@axtens.net>
0ccc47
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
0ccc47
(cherry picked from commit fdf32abc7a3928852422c0f291d8cd1dd6b34a8d)
0ccc47
(cherry picked from commit f2c10aaf335b88a69885375c4d68ffab2429df77)
0ccc47
(cherry picked from commit 4c942e1ba8d1f1199a58d2eb139022ae22f75cb2)
0ccc47
---
0ccc47
 grub-core/normal/charset.c | 2 ++
0ccc47
 1 file changed, 2 insertions(+)
0ccc47
0ccc47
diff --git a/grub-core/normal/charset.c b/grub-core/normal/charset.c
0ccc47
index f902b13b44..7b2de12001 100644
0ccc47
--- a/grub-core/normal/charset.c
0ccc47
+++ b/grub-core/normal/charset.c
0ccc47
@@ -395,6 +395,8 @@ grub_unicode_estimate_width (const struct grub_unicode_glyph *c)
0ccc47
 {
0ccc47
   if (grub_unicode_get_comb_type (c->base))
0ccc47
     return 0;
0ccc47
+  if (((unsigned long) (c->base >> 3)) >= ARRAY_SIZE (widthspec))
0ccc47
+    return 1;
0ccc47
   if (widthspec[c->base >> 3] & (1 << (c->base & 7)))
0ccc47
     return 2;
0ccc47
   else