Commit ccbea178 authored by Mirela Rabulea's avatar Mirela Rabulea Committed by Mauro Carvalho Chehab

media: Quit parsing stream if doesn't start with SOI

In the case we get an invalid stream, such as from v4l2-compliance
streaming test, jpeg_next_marker will end up parsing the entire
stream. The standard describes the high level syntax of a jpeg
as starting with SOI, ending with EOI, so return error if the very
first 2 bytes are not SOI.
Signed-off-by: default avatarMirela Rabulea <mirela.rabulea@nxp.com>
Reviewed-by: default avatarPhilipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
parent b8035f79
...@@ -503,11 +503,8 @@ int v4l2_jpeg_parse_header(void *buf, size_t len, struct v4l2_jpeg_header *out) ...@@ -503,11 +503,8 @@ int v4l2_jpeg_parse_header(void *buf, size_t len, struct v4l2_jpeg_header *out)
out->num_dht = 0; out->num_dht = 0;
out->num_dqt = 0; out->num_dqt = 0;
/* the first marker must be SOI */ /* the first bytes must be SOI, B.2.1 High-level syntax */
marker = jpeg_next_marker(&stream); if (jpeg_get_word_be(&stream) != SOI)
if (marker < 0)
return marker;
if (marker != SOI)
return -EINVAL; return -EINVAL;
/* init value to signal if this marker is not present */ /* init value to signal if this marker is not present */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment