Skip to content

[ODBC] Check SQLColAttribute return codes in field info functions - #293

Open
iliaal wants to merge 1 commit into
PHP-8.4from
fix/odbc-colattribute-unchecked-84
Open

[ODBC] Check SQLColAttribute return codes in field info functions#293
iliaal wants to merge 1 commit into
PHP-8.4from
fix/odbc-colattribute-unchecked-84

Conversation

@iliaal

@iliaal iliaal commented Aug 24, 2026

Copy link
Copy Markdown
Owner

odbc_field_len(), odbc_field_scale() and odbc_field_type() discarded the return code of SQLColAttribute and returned uninitialized stack memory when the call failed, which LD_PRELOAD interposition confirmed with garbage values such as pointer-sized integers. They now emit a warning carrying the failing field index and the driver diagnostic when one is available, and fall back to a safe default of 0 for length and scale and false for type. The sibling audit found odbc_bindcols() could leak uninitialized column-name bytes on failed name lookups, so it zero-terminates before the call, while the unchecked SQLColAttribute in odbc_result_all()'s long-column path is unaffected because its output is overwritten before use.

odbc_field_len(), odbc_field_scale() and odbc_field_type() discarded
the return code of SQLColAttribute and returned uninitialized stack
memory to the caller when the call failed. They now emit a warning with
the driver diagnostic when available and fall back to a safe default
(0 / false). odbc_bindcols() now zero-terminates column names before
the SQLColAttribute call so failed name lookups cannot leak garbage;
the unchecked call in odbc_result_all()'s long-column path is audited
and unaffected because its output is overwritten before use.
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