Skip to content

Fix GH-25474: version_compare() numeric parts overflow long on Windows - #25475

Closed
lazerg wants to merge 1 commit into
php:PHP-8.4from
lazerg:fix/gh-25474
Closed

lazerg wants to merge 1 commit into
php:PHP-8.4from
lazerg:fix/gh-25474

Conversation

@lazerg

@lazerg lazerg commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

php_version_compare() parsed numeric parts with strtol() into a long, which is 32 bits on Windows. Any part above 2147483647 clamped to LONG_MAX, so two different large build numbers compared as equal. It now uses ZEND_STRTOL() and zend_long, so the range matches PHP's int on every 64-bit platform.

Fixes #25474

prateekbhujel pushed a commit to prateekbhujel/php-src that referenced this pull request Nov 16, 2026
* PHP-8.4:
  Fix phpGH-25474: version_compare() numeric parts overflow long on Windows (php#25475)
arnaud-lb added a commit to pavimus/php-src that referenced this pull request Nov 16, 2026
* PHP-8.4: (262 commits)
  Fix phpGH-25474: version_compare() numeric parts overflow long on Windows (php#25475)
  ext/session: prevent creation of fixed sid in php_session_rfc1867 (phpGH-22113)
  Forbid \C in patterns enabling UTF mode with (*UTF) (phpGH-25452)
  Fix phpGH-24743: var_export() ignores exception from lazy object init (php#24746)
  ext/snmp: Copy the context name in SNMP::setSecurity()
  Fix phpGH-25434: C14NFile() skips namespace relinking on success
  Fix uploaded files leak in request_parse_body() (php#25387)
  Fix phpGH-25094: NULL dereference in SOAP get_doc_function() with missing parts
  Pin Linux x86 CI to Ubuntu 24.04 (php#25416)
  Fix phpGH-25359: tracing JIT drops reference type of a named by-ref argument
  Fix AST export of by-reference property hooks (phpGH-25069)
  fix test when tmp-php.ini is used
  Fix stack overflow in filter_var() and filter_var_array() (php#25349)
  Align the Windows OPcache JIT buffer (php#25262)
  Fix phpGH-25311: Assertion ret == SUCCESS in array_map()/array_filter() after delayed out-of-memory
  Fix tracing JIT reading the int result of ++/-- on a reference as a double
  Fix error buffer cleanup in phar_open_parsed_phar() (php#25376)
  Fix phpGH-25306: Assertion status == LXB_STATUS_OK in dom_parse_selector when lexbor allocation fails
  Fix AST printing dropping readonly on promoted parameters (phpGH-25207)
  ext/gd: blame the points array when a polygon has too few points
  ...
@TimWolla

Copy link
Copy Markdown
Member

This does not seem to be the correct fix: On 32-bit builds of PHP the comparison would still be wrong (as the test itself acknowledges by its SKIPIF). Version numbers are not integers and should be be treated as such. At the very least it should use uint64_t on every platform, but ideally it would compare the numeric strings directly.

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.

3 participants