Skip to content

Handle malformed image parser errors in View Bit Plane#2612

Open
zainnadeem786 wants to merge 1 commit into
gchq:masterfrom
zainnadeem786:fix/view-bit-plane-malformed-image-error
Open

Handle malformed image parser errors in View Bit Plane#2612
zainnadeem786 wants to merge 1 commit into
gchq:masterfrom
zainnadeem786:fix/view-bit-plane-malformed-image-error

Conversation

@zainnadeem786

Copy link
Copy Markdown
Contributor

Summary

Fix View Bit Plane handling for malformed image input whose file signature is detected as an image but fails during decoder parsing.

A crafted PNG can preserve the PNG magic bytes while replacing the required first IHDR chunk with IBDR. In that case, isImage() identifies the input as image/png, but Jimp.read() / pngjs throws a plain parser error.

Previously, that plain dependency error was treated as an unexpected operation failure. This PR wraps the image-loading step and converts decoder failures into a user-facing OperationError, consistent with nearby image operations.

Changes

  • Wrap only the Jimp.read(input) call in ViewBitPlane.run().
  • Convert image parser/read failures into:
Error loading image. (<original error>)
  • Add regression coverage for a malformed PNG where IBDR replaces the required IHDR chunk.
  • Keep valid View Bit Plane behavior unchanged.

Validation

Executed:

node --no-warnings --no-deprecation --openssl-legacy-provider --trace-uncaught tests/operations/index.mjs
git diff --check

Result:

TOTAL   2057
PASSING 2057

Closes #2504.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(View Bit Plane): Switching IHDR to IBDR on a png file cause an unhandled error

1 participant