mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 17:27:35 +00:00
LibGfx/JPEG: Make non-zero-terminated APPn starts non-fatal
Necessary but not sufficient for #18456.
This commit is contained in:
parent
22e0603bf7
commit
cf3835b29b
1 changed files with 6 additions and 2 deletions
|
@ -835,6 +835,7 @@ static ErrorOr<void> read_huffman_table(Stream& stream, JPEGLoadingContext& cont
|
|||
|
||||
static ErrorOr<void> read_icc_profile(Stream& stream, JPEGLoadingContext& context, int bytes_to_read)
|
||||
{
|
||||
// https://www.color.org/technotes/ICC-Technote-ProfileEmbedding.pdf, page 5, "JFIF".
|
||||
if (bytes_to_read <= 2)
|
||||
return Error::from_string_literal("icc marker too small");
|
||||
|
||||
|
@ -937,6 +938,7 @@ static ErrorOr<void> read_colour_encoding(Stream& stream, [[maybe_unused]] JPEGL
|
|||
|
||||
static ErrorOr<void> read_app_marker(Stream& stream, JPEGLoadingContext& context, int app_marker_number)
|
||||
{
|
||||
// B.2.4.6 - Application data syntax
|
||||
i32 bytes_to_read = TRY(stream.read_value<BigEndian<u16>>());
|
||||
|
||||
if (bytes_to_read <= 2)
|
||||
|
@ -945,8 +947,10 @@ static ErrorOr<void> read_app_marker(Stream& stream, JPEGLoadingContext& context
|
|||
|
||||
StringBuilder builder;
|
||||
for (;;) {
|
||||
if (bytes_to_read == 0)
|
||||
return Error::from_string_literal("app marker size too small for identifier");
|
||||
if (bytes_to_read == 0) {
|
||||
dbgln_if(JPEG_DEBUG, "app marker {} does not start with zero-terminated string", app_marker_number);
|
||||
return {};
|
||||
}
|
||||
|
||||
auto c = TRY(stream.read_value<char>());
|
||||
bytes_to_read--;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue