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

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