Skip to content

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

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

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

Conversation

@iliaal

@iliaal iliaal commented Jul 16, 2026

Copy link
Copy Markdown
Owner

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 force-pushed the fix/odbc-dsn-string-immutability branch from f03693a to 8327764 Compare July 16, 2026 19:15
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
@iliaal
iliaal force-pushed the fix/odbc-dsn-string-immutability branch from 8327764 to 7d70e5a Compare July 16, 2026 20:41
@iliaal

iliaal commented Jul 16, 2026

Copy link
Copy Markdown
Owner Author

Promoted upstream: php#22776

@iliaal iliaal closed this Jul 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant