Skip to content
Snippets Groups Projects
Commit ee032a34 authored by Steve Lhomme's avatar Steve Lhomme
Browse files

demux: image: detect ICC profile before JFIF data


Fixes #18857

(cherry picked from commit 5ffd36ff)
Signed-off-by: default avatarSteve Lhomme <robux4@ycbcr.xyz>
parent 0543689a
No related branches found
No related tags found
1 merge request!5557[3.0] demux: image: detect ICC profile before JFIF data
Pipeline #479912 passed with stages
in 21 minutes and 43 seconds
......@@ -392,7 +392,7 @@ static uint8_t FindJpegMarker(size_t *position, const uint8_t *data, size_t size
static bool IsJfif(stream_t *s)
{
const uint8_t *header;
ssize_t peek = vlc_stream_Peek(s, &header, 256);
ssize_t peek = vlc_stream_Peek(s, &header, 4096);
if(peek < 256)
return false;
size_t size = (size_t) peek;
......@@ -400,6 +400,16 @@ static bool IsJfif(stream_t *s)
if (FindJpegMarker(&position, header, size) != 0xd8)
return false;
if (FindJpegMarker(&position, header, size) == 0xe2) // ICC Profile
{
size_t icc_size = GetWBE(&header[position]);
position += 2;
if (position + 12 > size)
return false;
if (memcmp(&header[position], "ICC_PROFILE\0", 12))
return false;
position += icc_size - 2;
}
if (FindJpegMarker(&position, header, size) != 0xe0)
return false;
position += 2; /* Skip size */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment