Skip to content

ext/gmp: Fix GMP accepting integer strings with NUL bytes - #22798

Merged
LamentXU123 merged 1 commit into
php:masterfrom
LamentXU123:gmp-nul
Jul 18, 2026
Merged

ext/gmp: Fix GMP accepting integer strings with NUL bytes#22798
LamentXU123 merged 1 commit into
php:masterfrom
LamentXU123:gmp-nul

Conversation

@LamentXU123

@LamentXU123LamentXU123 commented Jul 18, 2026

Copy link
Copy Markdown
Member
<?phpvar_dump(gmp_strval(gmp_init("123\0abc")));
string(3) "123"

The logic of dealing with argument position is copied from

php-src/ext/gmp/gmp.c

Lines 667 to 675 in e3de8ed

if (-1==gmp_ret) {
if (arg_pos==0) {
zend_value_error("Number is not an integer string");
} else {
zend_argument_value_error(arg_pos, "is not an integer string");
}
returnFAILURE;
}

@LamentXU123
LamentXU123 merged commit 988eb99 into php:masterJul 18, 2026
18 checks passed
LamentXU123 added a commit that referenced this pull request Jul 18, 2026
LamentXU123 added a commit that referenced this pull request Jul 19, 2026
Sign up for freeto 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

@LamentXU123@Girgias