Skip to content

Fix GH-22108: Accept integral float values when modifying LDAP entries - #25347

Open
Truta446 wants to merge 1 commit into
php:PHP-8.5from
Truta446:ldap-float-values
Open

Truta446 wants to merge 1 commit into
php:PHP-8.5from
Truta446:ldap-float-values

Conversation

@Truta446

@Truta446 Truta446 commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

Fixes GH-22108

Since 8.5, values passed to ldap_add(), ldap_mod_replace() and the other functions built on php_ldap_do_modify() go through php_ldap_try_get_ldap_value_from_zval(), which has no case for floats. Code like ['shadowLastChange' => round(time() / 86400)] worked on 8.4 and now throws a TypeError.

As @Girgias suggested on the issue, this accepts floats only when they have no fractional part and formats them as integers ("20400", not "20400.0"). Values that don't fit in a zend_long are printed in full (1e20 becomes 100000000000000000000), which also covers the 32-bit case from the issue. -0.0 is sent as "0". Fractional, NAN and INF values still throw the same TypeError.

The test needs a running server, so it is skipped without one like the other ldap_mod_* tests. I ran the ldap suite against a local slapd on PHP-8.5 and master (debug + ASan, also with opcache/tracing JIT): the new test fails before the change and passes after it, and nothing else changes (only the two TLS tests fail, because my slapd has no TLS set up).

…ries

Since 8.5 the values passed to ldap_add(), ldap_mod_replace() and friends
go through php_ldap_try_get_ldap_value_from_zval(), which rejects floats.
Code that passes round() results or ints that overflowed to float worked
before and now throws a TypeError.

LDAP has no float syntax, so only accept floats without a fractional part
and format them as integers. Other floats still throw.
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.

1 participant