mirror of
https://git.savannah.gnu.org/git/grub.git
synced 2026-10-21 06:49:35 +00:00
video/readers: Add artificial limit to image dimensions
In grub-core/video/readers/jpeg.c, the height and width of a JPEG image don't have an upper limit for how big the JPEG image can be. In Coverity, this is getting flagged as an untrusted loop bound. This issue can also seen in PNG and TGA format images as well but Coverity isn't flagging it. To prevent this, the constant IMAGE_HW_MAX_PX is being added to include/grub/bitmap.h, which has a value of 16384, to act as an artificial limit and restrict the height and width of images. This value was picked as it is double the current max resolution size, which is 8K. Fixes: CID 292450 Signed-off-by: Alec Brown <alec.r.brown@oracle.com> Reviewed-by: Darren Kenny <darren.kenny@oracle.com> Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
This commit is contained in:
1 parent
2a5e3c1f2a
commit
a85714545f
5 files changed
+21
-3
No files matched your search
@@ -346,7 +346,11 @@ grub_jpeg_decode_sof (struct grub_jpeg_data *data)
|
||||
data->image_height = grub_jpeg_get_word (data);
|
||||
data->image_width = grub_jpeg_get_word (data);
|
||||
|
||||
if ((!data->image_height) || (!data->image_width))
|
||||
grub_dprintf ("jpeg", "image height: %d\n", data->image_height);
|
||||
grub_dprintf ("jpeg", "image width: %d\n", data->image_width);
|
||||
|
||||
if ((!data->image_height) || (!data->image_width) ||
|
||||
(data->image_height > IMAGE_HW_MAX_PX) || (data->image_width > IMAGE_HW_MAX_PX))
|
||||
return grub_error (GRUB_ERR_BAD_FILE_TYPE, "jpeg: invalid image size");
|
||||
|
||||
cc = grub_jpeg_get_byte (data);
|
||||
|
||||
Reference in new issue
Block a user