openlink / iODBC

An open-source ODBC driver manager and SDK that facilitates the development of database-independent applications on linux, freebsd, unix and MacOS X platforms.
http://www.iodbc.org/
Other
162 stars 52 forks source link

Silent truncation of 'long' diagnostic messages in SQLGetDiagRec #78

Closed matthew-wozniczka closed 2 years ago

matthew-wozniczka commented 2 years ago

See https://github.com/openlink/iODBC/blob/d6481a835d3a27cafa07302578dc8f25f03522dc/iodbc/herr.c#L1031

It's using a fixed size buffer, and there's no checks I could find on the size of a diagnostic message when being added via _iodbcdm_pushsqlerr(), so this will just silently truncate it

matthew-wozniczka commented 2 years ago

This could happen from https://github.com/openlink/iODBC/blob/d6481a835d3a27cafa07302578dc8f25f03522dc/iodbc/connect.c#L1181 for instance

matthew-wozniczka commented 2 years ago

I'm investigating a test failure where our driver fails to connect, and it seems (haven't verified yet) that iODBC is truncating the diagnostic message to "[iODBC][Driver Manager]dlopen(/Users/bamboo/bamboo-agent-home/x". The fact that it's 63 characters makes me think there's a 64 * CODEUNIT_SIZE limit somewhere. Looking more closely at what I pointed out, the 256 char buffer doesn't seem like it would be the cause... But I think it's still a possible issue.

Our driver is a unicode driver btw, and the application is calling into SQLGetDiagRecW, and we're using 3.52.15