grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[SECURITY PATCH 12/30] video/readers/jpeg: Do not reallocate a given huf


From: Daniel Kiper
Subject: [SECURITY PATCH 12/30] video/readers/jpeg: Do not reallocate a given huff table
Date: Tue, 7 Jun 2022 19:01:21 +0200

From: Daniel Axtens <dja@axtens.net>

Fix a memory leak where an invalid file could cause us to reallocate
memory for a huffman table we had already allocated memory for.

Signed-off-by: Daniel Axtens <dja@axtens.net>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
---
 grub-core/video/readers/jpeg.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/grub-core/video/readers/jpeg.c b/grub-core/video/readers/jpeg.c
index 806c56c78..2284a6c06 100644
--- a/grub-core/video/readers/jpeg.c
+++ b/grub-core/video/readers/jpeg.c
@@ -251,6 +251,9 @@ grub_jpeg_decode_huff_table (struct grub_jpeg_data *data)
        n += count[i];
 
       id += ac * 2;
+      if (data->huff_value[id] != NULL)
+       return grub_error (GRUB_ERR_BAD_FILE_TYPE,
+                          "jpeg: attempt to reallocate huffman table");
       data->huff_value[id] = grub_malloc (n);
       if (grub_errno)
        return grub_errno;
-- 
2.11.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]