Browse Source

LibGfx/JPEG2000: Check tile_part_length ("Psot") validity

Nico Weber 1 year ago
parent
commit
259c3fc7d3
1 changed files with 2 additions and 0 deletions
  1. 2 0
      Userland/Libraries/LibGfx/ImageFormats/JPEG2000Loader.cpp

+ 2 - 0
Userland/Libraries/LibGfx/ImageFormats/JPEG2000Loader.cpp

@@ -249,6 +249,8 @@ static ErrorOr<void> parse_codestream_tile_header(JPEG2000LoadingContext& contex
         tile_bitstream_length = context.codestream_data.size() - context.codestream_cursor - 2;
     } else {
         u32 tile_header_length = context.codestream_cursor - tile_start;
+        if (start_of_tile.tile_part_length < tile_header_length)
+            return Error::from_string_literal("JPEG2000ImageDecoderPlugin: Invalid tile part length");
         tile_bitstream_length = start_of_tile.tile_part_length - tile_header_length;
     }