|
|
80913e |
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
80913e |
From: Daniel Axtens <dja@axtens.net>
|
|
|
80913e |
Date: Fri, 15 Jan 2021 14:06:46 +1100
|
|
|
80913e |
Subject: [PATCH] video/readers/jpeg: Don't decode data before start of stream
|
|
|
80913e |
|
|
|
80913e |
When a start of stream marker is encountered, we call grub_jpeg_decode_sos()
|
|
|
80913e |
which allocates space for a bitmap.
|
|
|
80913e |
|
|
|
80913e |
When a restart marker is encountered, we call grub_jpeg_decode_data() which
|
|
|
80913e |
then fills in that bitmap.
|
|
|
80913e |
|
|
|
80913e |
If we get a restart marker before the start of stream marker, we will
|
|
|
80913e |
attempt to write to a bitmap_ptr that hasn't been allocated. Catch this
|
|
|
80913e |
and bail out. This fixes an attempt to write to NULL.
|
|
|
80913e |
|
|
|
80913e |
Signed-off-by: Daniel Axtens <dja@axtens.net>
|
|
|
80913e |
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
|
|
80913e |
---
|
|
|
80913e |
grub-core/video/readers/jpeg.c | 4 ++++
|
|
|
80913e |
1 file changed, 4 insertions(+)
|
|
|
80913e |
|
|
|
80913e |
diff --git a/grub-core/video/readers/jpeg.c b/grub-core/video/readers/jpeg.c
|
|
|
80913e |
index e5148120f69..e31602f766a 100644
|
|
|
80913e |
--- a/grub-core/video/readers/jpeg.c
|
|
|
80913e |
+++ b/grub-core/video/readers/jpeg.c
|
|
|
80913e |
@@ -646,6 +646,10 @@ grub_jpeg_decode_data (struct grub_jpeg_data *data)
|
|
|
80913e |
nr1 = (data->image_height + vb - 1) >> (3 + data->log_vs);
|
|
|
80913e |
nc1 = (data->image_width + hb - 1) >> (3 + data->log_hs);
|
|
|
80913e |
|
|
|
80913e |
+ if (data->bitmap_ptr == NULL)
|
|
|
80913e |
+ return grub_error(GRUB_ERR_BAD_FILE_TYPE,
|
|
|
80913e |
+ "jpeg: attempted to decode data before start of stream");
|
|
|
80913e |
+
|
|
|
80913e |
for (; data->r1 < nr1 && (!data->dri || rst);
|
|
|
80913e |
data->r1++, data->bitmap_ptr += (vb * data->image_width - hb * nc1) * 3)
|
|
|
80913e |
for (c1 = 0; c1 < nc1 && (!data->dri || rst);
|