[vlc-commits] [Git][videolan/vlc][master] demux: image: fix JFIF detection
Steve Lhomme (@robUx4)
gitlab at videolan.org
Fri Dec 5 08:23:47 UTC 2025
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
70eb2735 by Marvin Scholz at 2025-12-05T08:00:41+00:00
demux: image: fix JFIF detection
A JFIF does not necessarily has an ICC Profile, and especially
not usually directly following the SOI, as the spec requires SOI
followed by the APP0 JFIF marker. So while this new detection logic
fixes out-of-spec files that have a (small) ICC profile before the
APP0 JFIF, it breaks most other properly structured ones.
This makes the APP0 ICC profile optional and continues looking for the
APP0 JFIF regardless.
Regression from 5ffd36ffa26a83ae498373f7d0ace1d82ab952f4
- - - - -
1 changed file:
- modules/demux/image.c
Changes:
=====================================
modules/demux/image.c
=====================================
@@ -415,26 +415,32 @@ static bool IsJfif(stream_t *s)
size_t size = (size_t) peek;
size_t position = 0;
- 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) != 0xd8) // SOI
+ return false;
+
+ while (1) {
+ uint8_t marker = FindJpegMarker(&position, header, size);
+ switch (marker) {
+ case 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;
+ break;
+ }
+ case 0xe0: { // APP0
+ position += 2; /* Skip size */
+ if (position + 5 > size)
+ return false;
+ return (memcmp(&header[position], "JFIF\0", 5) == 0);
+ }
+ default:
+ return false;
+ }
}
- if (FindJpegMarker(&position, header, size) != 0xe0)
- return false;
- position += 2; /* Skip size */
- if (position + 5 > size)
- return false;
- if (memcmp(&header[position], "JFIF\0", 5))
- return false;
- return true;
}
static bool IsWebP(stream_t *s)
@@ -822,4 +828,3 @@ static void Close(vlc_object_t *object)
block_Release(sys->data);
free(sys);
}
-
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/70eb2735e7b47eb082ceb3e299d94f42ac19331b
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/70eb2735e7b47eb082ceb3e299d94f42ac19331b
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list