Skip to content

Fix copy-paste error in WebPImage::inject_VP8X height check#9280

Open
MarkLee131 wants to merge 1 commit intoExiv2:mainfrom
MarkLee131:fix/webp-inject-vp8x-height-check
Open

Fix copy-paste error in WebPImage::inject_VP8X height check#9280
MarkLee131 wants to merge 1 commit intoExiv2:mainfrom
MarkLee131:fix/webp-inject-vp8x-height-check

Conversation

@MarkLee131
Copy link
Copy Markdown

Fix #9279:

Line 773 checks width > 0 instead of height > 0. This was introduced in commit bf151a1. When height is 0, the enforce does not catch it and height - 1 wraps as an unsigned integer.

Change the check to validate height instead of width.

Line 773 checks width > 0 instead of height > 0. This was
introduced in commit bf151a1. When height is 0, the enforce
does not catch it and height - 1 wraps as an unsigned integer.

Change the check to validate height instead of width.
Copilot AI review requested due to automatic review settings March 29, 2026 14:48
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a copy/paste validation bug in WebPImage::inject_VP8X where the height field was not properly validated, allowing height - 1 to underflow and write an incorrect VP8X height value for malformed WebP inputs.

Changes:

  • Correct Internal::enforce(...) to validate height > 0 (instead of checking width > 0 twice) before computing height - 1.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 772 to 774
/* set height - stored in 24bits */
Internal::enforce(width > 0, Exiv2::ErrorCode::kerCorruptedMetadata);
Internal::enforce(height > 0, Exiv2::ErrorCode::kerCorruptedMetadata);
uint32_t h = height - 1;
Copy link

Copilot AI Mar 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding a regression/system test for this specific height==0 case (issue #9279). The repo already has WebP inject_VP8X regression coverage (e.g. tests/bugfixes/github/test_issue_2270.py), but there doesn't appear to be a test that exercises a malformed WebP leading to height==0 and verifies we fail with kerCorruptedMetadata rather than wrapping height-1.

Copilot uses AI. Check for mistakes.
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.

inject_VP8X checks width > 0 twice instead of checking height > 0

2 participants