nalika / rpms / grub2

Forked from rpms/grub2 2 years ago
Clone

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

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