Skip to content

Commit c46e63f

Browse files
committed
Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4: Fix GH-22395: Avoid truncating base_convert() output at 64 characters (#22406)
2 parents 6c1db26 + a3bcc86 commit c46e63f

3 files changed

Lines changed: 17 additions & 1 deletion

File tree

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ PHP NEWS
2525
. Fixed bug GH-22324 (Ignore leading namespace separator in
2626
ReflectionParameter::__construct()). (jorgsowa)
2727

28+
- Standard:
29+
. Fixed bug GH-22395 (base_convert() outputs at most 64 characters).
30+
(Weilin Du)
31+
2832
02 Jul 2026, PHP 8.5.8
2933

3034
- Core:

ext/standard/math.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "zend_exceptions.h"
2525
#include "zend_multiply.h"
2626
#include "zend_portability.h"
27+
#include "zend_strtod.h"
2728

2829
#include <float.h>
2930
#include <math.h>
@@ -949,7 +950,7 @@ PHPAPI zend_string * _php_math_zvaltobase(zval *arg, int base)
949950
if (Z_TYPE_P(arg) == IS_DOUBLE) {
950951
double fvalue = floor(Z_DVAL_P(arg)); /* floor it just in case */
951952
char *ptr, *end;
952-
char buf[(sizeof(double) << 3) + 1];
953+
char buf[ZEND_DOUBLE_MAX_LENGTH];
953954

954955
/* Don't try to convert +/- infinity */
955956
if (fvalue == ZEND_INFINITY || fvalue == -ZEND_INFINITY) {
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
--TEST--
2+
GH-22395 (base_convert outputs at most 64 characters)
3+
--FILE--
4+
<?php
5+
$result = base_convert(str_repeat("1", 61), 36, 16);
6+
var_dump(strlen($result));
7+
var_dump(substr($result, 0, 13));
8+
?>
9+
--EXPECT--
10+
int(78)
11+
string(13) "4b61b5e0639ff"

0 commit comments

Comments
 (0)