diff options
author | Mirela Rabulea <mirela.rabulea@nxp.com> | 2021-03-11 01:28:50 +0100 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab+huawei@kernel.org> | 2021-03-22 10:39:30 +0100 |
commit | ccbea178db47bf4a111ee97c0d77678818563a93 (patch) | |
tree | d6862edb6878e7a9e7470d95dfe5be844d6b9c38 /drivers/media/v4l2-core | |
parent | b8035f7988a82cbbabf1009b9f3234ff2431f8a4 (diff) | |
download | linux-ccbea178db47bf4a111ee97c0d77678818563a93.tar.gz linux-ccbea178db47bf4a111ee97c0d77678818563a93.tar.bz2 linux-ccbea178db47bf4a111ee97c0d77678818563a93.zip |
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: Mirela Rabulea <mirela.rabulea@nxp.com>
Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Diffstat (limited to 'drivers/media/v4l2-core')
-rw-r--r-- | drivers/media/v4l2-core/v4l2-jpeg.c | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/drivers/media/v4l2-core/v4l2-jpeg.c b/drivers/media/v4l2-core/v4l2-jpeg.c index ede40f2a5456..c4c0d6dd4577 100644 --- a/drivers/media/v4l2-core/v4l2-jpeg.c +++ b/drivers/media/v4l2-core/v4l2-jpeg.c @@ -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_dqt = 0; - /* the first marker must be SOI */ - marker = jpeg_next_marker(&stream); - if (marker < 0) - return marker; - if (marker != SOI) + /* the first bytes must be SOI, B.2.1 High-level syntax */ + if (jpeg_get_word_be(&stream) != SOI) return -EINVAL; /* init value to signal if this marker is not present */ |