nalika / rpms / grub2

Forked from rpms/grub2 2 years ago
Clone

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

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