mirror of
https://git.proxmox.com/git/grub2
synced 2025-10-04 22:00:34 +00:00
video/readers/png: Avoid heap OOB R/W inserting huff table items
In fuzzing we observed crashes where a code would attempt to be inserted into a huffman table before the start, leading to a set of heap OOB reads and writes as table entries with negative indices were shifted around and the new code written in. Catch the case where we would underflow the array and bail. Fixes: CVE-2021-3696 Signed-off-by: Daniel Axtens <dja@axtens.net> Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
This commit is contained in:
parent
558c69b5d3
commit
21e3b255f9
@ -438,6 +438,13 @@ grub_png_insert_huff_item (struct huff_table *ht, int code, int len)
|
|||||||
for (i = len; i < ht->max_length; i++)
|
for (i = len; i < ht->max_length; i++)
|
||||||
n += ht->maxval[i];
|
n += ht->maxval[i];
|
||||||
|
|
||||||
|
if (n > ht->num_values)
|
||||||
|
{
|
||||||
|
grub_error (GRUB_ERR_BAD_FILE_TYPE,
|
||||||
|
"png: out of range inserting huffman table item");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i < n; i++)
|
for (i = 0; i < n; i++)
|
||||||
ht->values[ht->num_values - i] = ht->values[ht->num_values - i - 1];
|
ht->values[ht->num_values - i] = ht->values[ht->num_values - i - 1];
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user