fix(tokenizer): reject VP8X WebP dimensions overflowing 32 bits #4031
Approve. The check matches RFC 9649 section 2.2 (canvas width times height at most 2^32 - 1) and the arithmetic is safe: each side is at most 2^24, so the product fits int64 before the comparison.
Reviewed head 2abc4760 against main at c5429a30 (merge base f44cf142, 19 commits behind, no conflicts). Open, non-draft, mergeable at submission.
Validation: go test -race ./pkg/epp/framework/plugins/requesthandling/dataproducer/tokenizer/... on this head ok; golangci-lint on the package, 0 issues. Differential: the updated webp_dims_test.go applied on main alone fails the three new reject rows and the base64 fallback assertion (webp_dims_test.go:116-118), and passes here. Not run: make presubmit.
History: found by the review playbook on #3664, as the description says; no earlier fix in the all-state search for VP8X (100 results per query cap).
I'd merge this; the decision is with the maintainers.
Approved these changes.
blacksoxx
liu-cong
What type of PR is this?
/kind bug
What this PR does / why we need it:
webpDimensionsreads the 24-bitVP8Xcanvaswidth - 1andheight - 1fields without checking RFC 9649 Section 2.2's requirement thatCanvas Width Canvas Heightfits in 32 bits (<= 2^32 - 1). A malformed 30-byteVP8Xheader with0xffffffin both fields reports a16777216 x 16777216image (2^48pixels), inflating the multimodal image placeholder estimate to2^38tokens instead of falling back to the default resolution.Reject
VP8Xheaders whosewidth heightexceedsmath.MaxUint32.The review playbook (
docs/review/) caught this bug on PR #3664.Release note _(write
NONEif no user-facing change)_:``
release-note
`NONE
Test plan:
canvas product boundaries (65535 x 65536,16777216 x 255) and rejected overflows (65536 x 65536,16777216 x 256,16777216 x 16777216), plus fallback to the default image resolution inimageEstimator.placeholderCount`.