Skip to content

ext/odbc: do not mutate the caller's DSN string#22776

Open
iliaal wants to merge 1 commit into
php:PHP-8.4from
iliaal:fix/odbc-dsn-string-immutability
Open

ext/odbc: do not mutate the caller's DSN string#22776
iliaal wants to merge 1 commit into
php:PHP-8.4from
iliaal:fix/odbc-dsn-string-immutability

Conversation

@iliaal

@iliaal iliaal commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

odbc_sqlconnect() stripped a trailing ; by writing a NUL into the caller’s DSN zend_string. Shared variables, interned literals, and const values used as the DSN were permanently altered (strlen unchanged, last byte became NUL).

Compute a base length instead and pass it to spprintf with %.*s. Does not touch the argument buffer.

ext/pdo_odbc already copies before mutating and does not need a change.

@iliaal iliaal requested a review from NattyNarwhal as a code owner July 16, 2026 20:41
odbc_sqlconnect() stripped a trailing semicolon by writing a NUL into
the Z_PARAM_STRING buffer, which is a zend_string. Shared variables,
interned literals, and const values used as the DSN were permanently
altered (strlen unchanged, last byte became NUL). Compute the base
length instead and pass it to spprintf with %.*s, matching the
non-mutating approach used when assembling UID/PWD into the connect
string.

Closes phpGH-22776
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