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
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Zend/tests/gh15712.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
--TEST--
GH-15712: overflow on real number printing
--FILE--
<?php
ini_set('precision', 1100000000);
echo -1 * (2 ** -10);
?>
--EXPECTF--
%s
6 changes: 3 additions & 3 deletions Zend/zend_strtod.c
Original file line number Diff line number Diff line change
Expand Up @@ -3613,11 +3613,11 @@ rv_alloc(i) int i;
rv_alloc(int i)
#endif
{
int j, k, *r;
int k, *r;

j = sizeof(ULong);
size_t j = sizeof(ULong);
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

j <<= 1)
k++;
r = (int*)Balloc(k);
Expand Down
Loading