Skip to content

odbc: check SQLColAttribute return codes in the field info functions - #23601

Open
iliaal wants to merge 1 commit into
php:PHP-8.4from
iliaal:promote/odbc-colattribute-checked
Open

odbc: check SQLColAttribute return codes in the field info functions#23601
iliaal wants to merge 1 commit into
php:PHP-8.4from
iliaal:promote/odbc-colattribute-checked

Conversation

@iliaal

@iliaal iliaal commented Sep 6, 2026

Copy link
Copy Markdown
Member

odbc_column_lengths() and odbc_field_type() ignored the SQLColAttribute return code and returned their output buffer regardless, so a driver that fails the call left odbc_field_len(), odbc_field_scale() and odbc_field_type() reporting uninitialized stack. They now check the code and warn with the driver's own SQLGetDiagRec diagnostic.

odbc_bindcols() gets the one-line zero-init of name for the same reason; it has no way to report an error, since it runs during result setup and returns void. No test: reaching the branch needs a driver that fails SQLColAttribute on a valid column index, and there is no existing php-src harness for injecting that.

odbc_column_lengths() and odbc_field_type() ignored the SQLColAttribute
return code and returned their output buffer regardless, so a driver that
fails the call left odbc_field_len(), odbc_field_scale() and
odbc_field_type() reporting uninitialized stack. Check the code, warn with
the driver's own diagnostic, and return 0 or false instead.

Closes phpGH-23601

@NattyNarwhal NattyNarwhal left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this makes sense. I think in master we should consider making odbc_sql_error a sprintf-type thing so we can do something like "SQLAttribute column #%d",, so we can get rid of odbc_colattribute_failed. There's a few places where SQLError is called too, so more cleanup there...

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.

2 participants