https://bugs.documentfoundation.org/show_bug.cgi?id=90520

--- Comment #3 from [email protected] ---
Is downloadable from oracle site (you need to register).  It's in the "oracle
client" package.

I've done a bit more debugging, however, and the problem seems due to a
combination of driver bug and incorrect LO handling of SQLGetData.

Oracle ODBC driver < 11.2.0.1.0 has a bug (Bug 6801797), returning wrong length
in SQLGetData last parameter (read as pcbValue by LO).
This bug is amplificated by LO incorrect behavior.

OTools::getStringValue tries to read a column with more than 2048 bytes by
iterating over SQLGetData, but uses only pcbValue to detect when stopping,
instead of looking also at the function return value.
Further, it iterates even with fixed-length column, while ODBC allows iterating
only over variable lenght columns (eg VARCHAR).
Calling multiple times SQLGetData on a fixed lenght columns results in the
driver doing nothing but returning SQL_NO_DATA for calls after the first.

When opening the filter/sort dialog for the first time, LO apparently asks the
driver about supported data types, thus getting CHAR data and triggering the
bug.
AFAIK the sequence is

1. first call to SQLGetData. Buggy oracle driver returns 2048 in pcbValue
2. LO thinks the column has more than 2048 bytes and tries to read another
chunk
- this time the call to SQLGetData returns SQL_NO_DATA and does nothing, but
pcbValue still contains 2048 from previous result
3. LO ignores the return value and looking only at pcbValue copies another 2048
bytes (of garbage) in the result buffer, then tries to read another chunk

repeat steps 2 and 3 until crash

So a workaround would be resetting pcbValue to zero just before calling
SQLGetData.
Something like
        while ((pcbValue == SQL_NO_TOTAL ) || (pcbValue >= nMaxLen) )
        {
            pcbValue = 0;  <--- insert 0 here
            OTools::ThrowException(_pConnection,
                          
(*(T3SQLGetData)_pConnection->getOdbcFunction(ODBC3SQLGetData))(
                                       _aStatementHandle,
                                       (SQLUSMALLINT)columnIndex,
                                       SQL_C_CHAR,
                                       &aCharArray,
                                       nMaxLen,
                                       &pcbValue),


A better fix should be check SQLGetData return value and act accordingly, but
perhaps LO does things this way as a workaround to other driver bugs ?

-- 
You are receiving this mail because:
You are the assignee for the bug.
_______________________________________________
Libreoffice-bugs mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/libreoffice-bugs

Reply via email to