Skip to content

Validate PBM max pixel value#3134

Merged
JimBobSquarePants merged 1 commit into
mainfrom
js/fix-pbm-dcoder
May 26, 2026
Merged

Validate PBM max pixel value#3134
JimBobSquarePants merged 1 commit into
mainfrom
js/fix-pbm-dcoder

Conversation

@JimBobSquarePants
Copy link
Copy Markdown
Member

Prerequisites

  • I have written a descriptive pull-request title
  • I have verified that there are no overlapping pull-requests open
  • I have verified that I am following the existing coding patterns and practice as demonstrated in the repository. These follow strict Stylecop rules 👮.
  • I have provided test coverage for my change (where applicable)

Description

Fixes #3130

This pull request adds stricter validation for the PBM image decoder to ensure that only valid max pixel values are accepted, and introduces corresponding tests to verify this behavior.

Decoder validation improvement:

  • Added a check in PbmDecoderCore.cs to throw an InvalidImageContentException if maxPixelValue is less than or equal to 0 or greater than or equal to 65536, preventing invalid PBM images from being processed.

Test coverage:

  • Added a new parameterized test in PbmDecoderTests.cs to verify that decoding PBM images with a max pixel value of 0 for all supported magic numbers throws an InvalidImageContentException.

@JimBobSquarePants JimBobSquarePants merged commit f6d369d into main May 26, 2026
12 checks passed
@JimBobSquarePants JimBobSquarePants deleted the js/fix-pbm-dcoder branch May 26, 2026 04:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DivideByZeroException in PbmDecoderCore.ProcessUpscaling

1 participant