video/readers/jpeg: Fix possible invalid loop boundary condition

The value of next_marker is adjusted based on the word sized value
read from data->file.

The updated next_marker value should reference a location in the file
just beyond the huffman table, and as such should not have a value
larger than the size of the file.

Fixes: CID 73657

Signed-off-by: Darren Kenny <darren.kenny@oracle.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
This commit is contained in:
Darren Kenny 2022-04-05 18:25:52 +00:00 committed by Daniel Kiper
parent 3ce13d974b
commit c244e331b9

View File

@ -199,6 +199,12 @@ grub_jpeg_decode_huff_table (struct grub_jpeg_data *data)
next_marker = data->file->offset;
next_marker += grub_jpeg_get_word (data);
if (next_marker > data->file->size)
{
return grub_error (GRUB_ERR_BAD_FILE_TYPE,
"jpeg: invalid huffman table");
}
while (data->file->offset + sizeof (count) + 1 <= next_marker)
{
id = grub_jpeg_get_byte (data);