Skip to content

Commit 47997d9

Browse files
committed
Fix GH-19898: ubsan crash with zend_strtod()
When parsing the most significant numbers from a string, it can overflow with large inputs with the number of digits in this case we exit from the loop.
1 parent 7a1bb71 commit 47997d9

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Zend/zend_strtod.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2606,7 +2606,7 @@ zend_strtod
26062606
}
26072607
s0 = s;
26082608
y = z = 0;
2609-
for(nd = nf = 0; (c = *s) >= '0' && c <= '9'; nd++, s++)
2609+
for(nd = nf = 0; (c = *s) >= '0' && c <= '9' && nd < INT_MAX; nd++, s++)
26102610
if (nd < 9)
26112611
y = 10*y + c - '0';
26122612
else if (nd < DBL_DIG + 2)

0 commit comments

Comments
 (0)