Kaydet (Commit) 5c0ca47e authored tarafından Lionel Elie Mamane's avatar Lionel Elie Mamane

ODBC: binary data is not null-terminated

Change-Id: Ibc90fabf7534b537948c12de76b611daf5ca9808
üst 12bad6a4
...@@ -365,9 +365,11 @@ Sequence<sal_Int8> OTools::getBytesValue(const OConnection* _pConnection, ...@@ -365,9 +365,11 @@ Sequence<sal_Int8> OTools::getBytesValue(const OConnection* _pConnection,
SQLLEN pcbValue = SQL_NO_TOTAL; SQLLEN pcbValue = SQL_NO_TOTAL;
Sequence<sal_Int8> aData; Sequence<sal_Int8> aData;
// >= because if the data is nMaxLen long, our buffer is actually ONE byte short, OSL_ENSURE( _fSqlType != SQL_CHAR && _fSqlType != SQL_VARCHAR && _fSqlType != SQL_LONGVARCHAR &&
// for the null byte terminator! _fSqlType != SQL_WCHAR && _fSqlType != SQL_WVARCHAR && _fSqlType != SQL_WLONGVARCHAR,
while (pcbValue == SQL_NO_TOTAL || pcbValue >= nMaxLen) "connectivity::odbc::OTools::getBytesValue called with character _fSqlType");
while (pcbValue == SQL_NO_TOTAL || pcbValue > nMaxLen)
{ {
OTools::ThrowException(_pConnection, OTools::ThrowException(_pConnection,
(*(T3SQLGetData)_pConnection->getOdbcFunction(ODBC3SQLGetData))( (*(T3SQLGetData)_pConnection->getOdbcFunction(ODBC3SQLGetData))(
...@@ -388,13 +390,8 @@ Sequence<sal_Int8> OTools::getBytesValue(const OConnection* _pConnection, ...@@ -388,13 +390,8 @@ Sequence<sal_Int8> OTools::getBytesValue(const OConnection* _pConnection,
// pcbValue will not be SQL_NO_TOTAL -> we have a reliable count // pcbValue will not be SQL_NO_TOTAL -> we have a reliable count
if ( (pcbValue == SQL_NO_TOTAL) || (pcbValue >= nMaxLen) ) if ( (pcbValue == SQL_NO_TOTAL) || (pcbValue >= nMaxLen) )
{ {
// we filled the buffer; remove the terminating null byte // we filled the buffer
nReadBytes = nMaxLen-1; nReadBytes = nMaxLen;
if ( aCharArray[nReadBytes] != 0)
{
OSL_FAIL("Buggy ODBC driver? Did not null-terminate (variable length) data!");
++nReadBytes;
}
} }
else else
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment