[php-src] PHP-8.6: Merge branch 'PHP-8.4' into PHP-8.5
| From: | Weilin Du | Date: | Mon, 16 Nov 2026 09:19:51 +0000 |
| Subject: | [php-src] PHP-8.6: Merge branch 'PHP-8.4' into PHP-8.5 | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-143727@lists.php.net to get a copy of this message | ||
Author: Weilin Du (LamentXU123)
Date: 2026-11-16T17:11:12+08:00
Commit: https://github.com/php/php-src/commit/a787f17792032c5a45fad912e102a1d413d15bb5
Raw diff: https://github.com/php/php-src/commit/a787f17792032c5a45fad912e102a1d413d15bb5.diff
Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
Fix GH-25474: version_compare() numeric parts overflow long on Windows (#25475)
Changed paths:
A ext/standard/tests/versioning/gh25474.phpt
M NEWS
M ext/standard/versioning.c
Diff:
diff --git a/NEWS b/NEWS
index 71770cd4ae64..e401d22db604 100644
--- a/NEWS
+++ b/NEWS
@@ -105,6 +105,8 @@ PHP NEWS
(lacatoire)
- Standard:
+ . Fixed bug GH-25474 (version_compare() treats large numeric parts as equal
+ on 64-bit Windows). (lazerg)
. Fixed bug GH-25387 (Uploaded files leak in request_parse_body()).
(Kévin Dunglas)
. Fixed bug GH-24743 (var_export() ignores exceptions from lazy object
diff --git a/ext/standard/tests/versioning/gh25474.phpt b/ext/standard/tests/versioning/gh25474.phpt
new file mode 100644
index 000000000000..c055b69d88bf
--- /dev/null
+++ b/ext/standard/tests/versioning/gh25474.phpt
@@ -0,0 +1,18 @@
+--TEST--
+GH-25474 (version_compare() treats numeric parts > 2147483647 as equal on Windows)
+--CREDITS--
+HFigarella
+--SKIPIF--
+<?php
+if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only");
+?>
+--FILE--
+<?php
+var_dump(version_compare('2147483648', '2147483647'));
+var_dump(version_compare('5000000000', '6000000000'));
+var_dump(version_compare('16.5-a.2-43779010004', '16.5-a.2-43192679404'));
+?>
+--EXPECT--
+int(1)
+int(-1)
+int(1)
diff --git a/ext/standard/versioning.c b/ext/standard/versioning.c
index f82e3d2c07dc..4b3d4180096d 100644
--- a/ext/standard/versioning.c
+++ b/ext/standard/versioning.c
@@ -131,7 +131,7 @@ php_version_compare(const char *orig_ver1, const char *orig_ver2)
char *ver1;
char *ver2;
char *p1, *p2, *n1, *n2;
- long l1, l2;
+ zend_long l1, l2;
int compare = 0;
if (!*orig_ver1 || !*orig_ver2) {
@@ -162,8 +162,8 @@ php_version_compare(const char *orig_ver1, const char *orig_ver2)
}
if (isdigit((unsigned char)*p1) && isdigit((unsigned char)*p2)) {
/* compare element numerically */
- l1 = strtol(p1, NULL, 10);
- l2 = strtol(p2, NULL, 10);
+ l1 = ZEND_STRTOL(p1, NULL, 10);
+ l2 = ZEND_STRTOL(p2, NULL, 10);
compare = ZEND_NORMALIZE_BOOL(l1 - l2);
} else if (!isdigit((unsigned char)*p1) && !isdigit((unsigned char)*p2)) {
/* compare element names */