Skip to content

ext/standard: Minor NUL byte rejection fixes - #25171

Open
LamentXU123 wants to merge 2 commits into
php:masterfrom
LamentXU123:fix/nul-string-apis
Open

LamentXU123 wants to merge 2 commits into
php:masterfrom
LamentXU123:fix/nul-string-apis

Conversation

@LamentXU123

Copy link
Copy Markdown
Member

This reject NUL bytes in parameters in quoted_printable_decode and version_compare function

@iliaal iliaal left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The version_compare() part looks g2g, php_version_compare() works on C strings so rejecting is the only sane option. I'd split it into its own PR so it can land while quoted_printable_decode() gets reworked.

For quoted_printable_decode() I'd rather fix the truncation than reject. The decoder already passes through everything else that isn't valid QP, =00 decodes to a NUL anyway, and the convert.quoted-printable-decode filter keeps a raw NUL: "abc\0d=41f" gives abc\0dAf from the filter and abc from the function. Walking the input by ZSTR_LEN() instead of stopping at the terminator would make the two agree.

try {
quoted_printable_decode($input);
} catch (ValueError $e) {
echo $e->getMessage(), "\n";

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: echo $e::class along with the message, same in version_compare_null_bytes.phpt.

@LamentXU123

Copy link
Copy Markdown
Member Author

I'd split it into its own PR so it can land while quoted_printable_decode() gets reworked.

Don't worry, I will rebase & merge so it will appears in different commit.

@LamentXU123

Copy link
Copy Markdown
Member Author

The mac test failure seems to be unrelated.

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.

2 participants