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 SQLColAttribute return code and returned uninitialized stack memory on failure, garbage such as pointer-sized integers under LD_PRELOAD interposition. They now warn with the failing field index and any driver diagnostic, then return 0 for length and scale and false for type. Sibling audit: odbc_bindcols() could leak uninitialized column-name bytes on failed name lookups and now zero-terminates before the call; odbc_result_all()'s long-column SQLColAttribute is safe 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.
@iliaal
iliaal force-pushed the fix/odbc-colattribute-unchecked-84 branch from 22798d2 to 1f20578 Compare August 26, 2026 12:46
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