From 9cd0c5658e642c032e9f6c588e7c2c29e6ddc0b5 Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Thu, 7 Mar 2024 20:41:32 -0500 Subject: [PATCH] LibGfx/JBIG2: Reject files with delayed height information for now 7.4.8.2 Page bitmap height: "In some cases, this value may not be known at the time that the page information segment is written. In this case, this field must contain 0xFFFFFFFF, and the actual page height may be communicated later, once it is known." --- Userland/Libraries/LibGfx/ImageFormats/JBIG2Loader.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Userland/Libraries/LibGfx/ImageFormats/JBIG2Loader.cpp b/Userland/Libraries/LibGfx/ImageFormats/JBIG2Loader.cpp index a3e08bcea1..4edd8a9757 100644 --- a/Userland/Libraries/LibGfx/ImageFormats/JBIG2Loader.cpp +++ b/Userland/Libraries/LibGfx/ImageFormats/JBIG2Loader.cpp @@ -297,6 +297,11 @@ static ErrorOr scan_for_page_size(JBIG2LoadingContext& context) if (segment.header.type != SegmentType::PageInformation || segment.header.page_association != 1) continue; auto page_information = TRY(decode_page_information_segment(segment.data)); + + // FIXME: We're supposed to compute this from the striping information if it's not set. + if (page_information.bitmap_height == 0xffff'ffff) + return Error::from_string_literal("JBIG2ImageDecoderPlugin: Cannot handle unknown page height yet"); + context.size = { page_information.bitmap_width, page_information.bitmap_height }; return {}; }