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

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