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