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

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