]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
video/readers/jpeg: Do not reallocate a given huff table
authorDaniel Axtens <dja@axtens.net>
Mon, 28 Jun 2021 04:16:58 +0000 (14:16 +1000)
committerDaniel Kiper <daniel.kiper@oracle.com>
Tue, 7 Jun 2022 14:39:32 +0000 (16:39 +0200)
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

index 806c56c78f4cd7cdb5f5f86d6304d965fe54ea9d..2284a6c062aaaf3111ec9bea6cf773ae082ac13c 100644 (file)
@@ -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;