Skip to content

Fix GH-15712: overflow on float print with precision ini large value. #15715

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
wants to merge 1 commit into from

Conversation

devnexen
Copy link
Member

@devnexen devnexen commented 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 devnexen changed the base branch from master to PHP-8.2 September 2, 2024 17:12
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 devnexen marked this pull request as ready for review September 2, 2024 17:55
@devnexen devnexen changed the title Fix GH-15712: overflow on float print with precision large value. Fix GH-15712: overflow on float print with precision ini large value. Sep 2, 2024
@devnexen devnexen requested a review from Girgias September 5, 2024 12:33
@devnexen devnexen linked an issue Sep 5, 2024 that may be closed by this pull request
for(k = 0;
sizeof(Bigint) - sizeof(ULong) - sizeof(int) + (size_t)j <= (size_t)i;
sizeof(Bigint) - sizeof(ULong) - sizeof(int) + j <= (size_t)i;
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't k and i also be size_t ? Seems like this file could make use of a bit of cleanup to get rid of all the K&R definitions

Copy link
Member Author

@devnexen devnexen Sep 9, 2024

Choose a reason for hiding this comment

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

I thought of it for sure but :

  • the issue is on j incrementation alone.
  • it is a stable branch, I think the cleanup you mention is more appropriate for master branch (thinking if there is more implications from int => size_t changes also, etc)

Copy link
Member

Choose a reason for hiding this comment

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

Ah right this targets 8.2... yeah sure then do the minimal changes

Comment on lines 3610 to 3614
#ifdef KR_headers
rv_alloc(i) int i;
#else
rv_alloc(int i)
rv_alloc(size_t i)
#endif
Copy link
Member

Choose a reason for hiding this comment

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

I thought you wanted to only do this change in master? As you didn't properly update the KR version here.

Copy link
Member Author

@devnexen devnexen Sep 10, 2024

Choose a reason for hiding this comment

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

no I do not want to, I think changing j (and eventually k) here should suffice wdyt ?

Copy link
Member

Choose a reason for hiding this comment

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

I think changing just j is fine.

@devnexen devnexen closed this in 503d914 Sep 11, 2024
devnexen added a commit to devnexen/php-src that referenced this pull request Nov 8, 2024
Choosing here to shrink the requested allocation to its max value.
devnexen added a commit that referenced this pull request Nov 8, 2024
Choosing here to shrink the requested allocation to its max value.
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.

Out of int range in Zend/zend_strtod.c
2 participants