Skip to content

Out of int range in Zend/zend_strtod.c #15712

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
YuanchengJiang opened this issue Sep 2, 2024 · 0 comments
Closed

Out of int range in Zend/zend_strtod.c #15712

YuanchengJiang opened this issue Sep 2, 2024 · 0 comments

Comments

@YuanchengJiang
Copy link

Description

The following code:

<?php
ini_set('precision', 1140973389);
echo "len=", strlen(strval(-1 * pow(2, -10))), "\n";
?>

Resulted in this output:

/php-src/Zend/zend_strtod.c:3617:5: runtime error: left shift of 1073741824 by 1 places cannot be represented in type 'int'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /php-src/Zend/zend_strtod.c:3617:5

PHP Version

PHP 8.4.0-dev

Operating System

ubuntu 22.04

@devnexen devnexen self-assigned this Sep 2, 2024
devnexen added a commit to devnexen/php-src that referenced this issue Sep 2, 2024
When allocating enough room for floats, the allocator used by overflows with
large ndigits/EG(precision) value which used an signed integer to double
the buffer. Testing with the zend operator directly is enough to trigger
 the issue rather than higher level math interface.
devnexen added a commit to devnexen/php-src that referenced this issue Sep 2, 2024
When allocating enough room for floats, the allocator used overflows with
large ndigits/EG(precision) value which used an signed integer to
increase the size of thebuffer.
Testing with the zend operator directly is enough to trigger
the issue rather than higher level math interface.
devnexen added a commit to devnexen/php-src that referenced this issue Sep 16, 2024
It triggered allocation overflow which, even fixed, in turn gives memory
leak on 32 bits but the allocator relies on signed integers so instead
of changing `j` type we exit if an overflow during the buffer increase
is going to happen.
devnexen added a commit that referenced this issue Nov 7, 2024
It triggered allocation overflow which, even fixed, in turn gives memory
leak on 32 bits but the allocator relies on signed integers.

close GH-15915
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants