nalika / rpms / grub2

Forked from rpms/grub2 2 years ago
Clone

Blame SOURCES/0227-video-readers-jpeg-Do-not-reallocate-a-given-huff-ta.patch

e28c09
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
e28c09
From: Daniel Axtens <dja@axtens.net>
e28c09
Date: Mon, 28 Jun 2021 14:16:58 +1000
e28c09
Subject: [PATCH] video/readers/jpeg: Do not reallocate a given huff table
e28c09
e28c09
Fix a memory leak where an invalid file could cause us to reallocate
e28c09
memory for a huffman table we had already allocated memory for.
e28c09
e28c09
Signed-off-by: Daniel Axtens <dja@axtens.net>
e28c09
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
e28c09
(cherry picked from commit bc06e12b4de55cc6f926af9f064170c82b1403e9)
e28c09
---
e28c09
 grub-core/video/readers/jpeg.c | 3 +++
e28c09
 1 file changed, 3 insertions(+)
e28c09
e28c09
diff --git a/grub-core/video/readers/jpeg.c b/grub-core/video/readers/jpeg.c
e28c09
index 10225abd53..caa211f06d 100644
e28c09
--- a/grub-core/video/readers/jpeg.c
e28c09
+++ b/grub-core/video/readers/jpeg.c
e28c09
@@ -245,6 +245,9 @@ grub_jpeg_decode_huff_table (struct grub_jpeg_data *data)
e28c09
 	n += count[i];
e28c09
 
e28c09
       id += ac * 2;
e28c09
+      if (data->huff_value[id] != NULL)
e28c09
+	return grub_error (GRUB_ERR_BAD_FILE_TYPE,
e28c09
+			   "jpeg: attempt to reallocate huffman table");
e28c09
       data->huff_value[id] = grub_malloc (n);
e28c09
       if (grub_errno)
e28c09
 	return grub_errno;