From: Daniel Axtens Date: Mon, 28 Jun 2021 04:16:58 +0000 (+1000) Subject: video/readers/jpeg: Do not reallocate a given huff table X-Git-Tag: grub-2.12-rc1~349 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=768ef2199e0265cf455b154f1a80a612f02274c8;p=thirdparty%2Fgrub.git video/readers/jpeg: Do not reallocate a given huff table 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 Reviewed-by: Daniel Kiper --- 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;