Skip to content

ext/standard: Fix setlocale() NUL byte truncation#22843

Open
LamentXU123 wants to merge 4 commits into
php:masterfrom
LamentXU123:NUL-standard
Open

ext/standard: Fix setlocale() NUL byte truncation#22843
LamentXU123 wants to merge 4 commits into
php:masterfrom
LamentXU123:NUL-standard

Conversation

@LamentXU123

Copy link
Copy Markdown
Member
<?php
var_dump(setlocale(LC_ALL, "C\0invalid"));
string(1) "C"

See: https://3v4l.org/rHId2#v
New argument logic in try_setlocale_zval is inevitable because we need to know the argument position when we raise the ValueError (both the second and the third parameter of the setlocale function have the truncation issue)

Comment thread ext/standard/string.c Outdated
Comment thread ext/standard/string.c Outdated
Comment thread ext/standard/tests/strings/setlocale_null_byte.phpt
Co-Authored-By: Jorg Adam Sowa <74921107+jorgsowa@users.noreply.github.com>
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.

3 participants