Skip to content

Fix GH-25955: reject stream filter line lengths above UINT_MAX - #25963

Open
jlu-lujing wants to merge 1 commit into
php:PHP-8.4from
jlu-lujing:fix/gh-25955-line-length-uint32
Open

jlu-lujing wants to merge 1 commit into
php:PHP-8.4from
jlu-lujing:fix/gh-25955-line-length-uint32

Conversation

@jlu-lujing

Copy link
Copy Markdown

Fixes GH-25955.

php_conv_get_uint_prop_ex() reads line-length as a zend_ulong and casts it to unsigned int, so values above UINT_MAX silently truncate. For example, 2^32 + 76 aliases to 76 and produces a line break at the wrong position.

The converter option parser now rejects values above UINT_MAX with a ValueError before the cast. Both base64 and quoted-printable encoders propagate this failure and release the borrowed line-break string. The stream filter factory also avoids appending a generic creation warning when the constructor already raised this ValueError, while preserving warnings for other user-filter construction failures.

Validation:

  • Added a PHPT test for both encoder filters, covering 2^32 and 2^32 + 76, exception messages, and unchanged stream contents.
  • make test TESTS=ext/standard/tests/filters: 58 passed, 5 skipped, 0 failed.
  • git diff --check: passed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

1 participant