summaryrefslogtreecommitdiff
path: root/connectivity
diff options
context:
space:
mode:
authorLionel Elie Mamane <lionel@mamane.lu>2012-12-25 12:55:59 +0100
committerLionel Elie Mamane <lionel@mamane.lu>2012-12-25 13:06:50 +0100
commit3016e7d84433a1b3bfce91a7a78ffef3c3d71bd9 (patch)
tree708f85f3ab4537d9445ce96b648fd4a71cd0f77c /connectivity
parent917616f1e15f06533f7380a309b1ccea0920f8f6 (diff)
ODBC: binary data is not null-terminated
Change-Id: Ibc90fabf7534b537948c12de76b611daf5ca9808
Diffstat (limited to 'connectivity')
-rw-r--r--connectivity/source/drivers/odbcbase/OTools.cxx17
1 files changed, 7 insertions, 10 deletions
diff --git a/connectivity/source/drivers/odbcbase/OTools.cxx b/connectivity/source/drivers/odbcbase/OTools.cxx
index 290aa611d015..831eb3a1eba3 100644
--- a/connectivity/source/drivers/odbcbase/OTools.cxx
+++ b/connectivity/source/drivers/odbcbase/OTools.cxx
@@ -365,9 +365,11 @@ Sequence<sal_Int8> OTools::getBytesValue(const OConnection* _pConnection,
SQLLEN pcbValue = SQL_NO_TOTAL;
Sequence<sal_Int8> aData;
- // >= because if the data is nMaxLen long, our buffer is actually ONE byte short,
- // for the null byte terminator!
- while (pcbValue == SQL_NO_TOTAL || pcbValue >= nMaxLen)
+ OSL_ENSURE( _fSqlType != SQL_CHAR && _fSqlType != SQL_VARCHAR && _fSqlType != SQL_LONGVARCHAR &&
+ _fSqlType != SQL_WCHAR && _fSqlType != SQL_WVARCHAR && _fSqlType != SQL_WLONGVARCHAR,
+ "connectivity::odbc::OTools::getBytesValue called with character _fSqlType");
+
+ while (pcbValue == SQL_NO_TOTAL || pcbValue > nMaxLen)
{
OTools::ThrowException(_pConnection,
(*(T3SQLGetData)_pConnection->getOdbcFunction(ODBC3SQLGetData))(
@@ -388,13 +390,8 @@ Sequence<sal_Int8> OTools::getBytesValue(const OConnection* _pConnection,
// pcbValue will not be SQL_NO_TOTAL -> we have a reliable count
if ( (pcbValue == SQL_NO_TOTAL) || (pcbValue >= nMaxLen) )
{
- // we filled the buffer; remove the terminating null byte
- nReadBytes = nMaxLen-1;
- if ( aCharArray[nReadBytes] != 0)
- {
- OSL_FAIL("Buggy ODBC driver? Did not null-terminate (variable length) data!");
- ++nReadBytes;
- }
+ // we filled the buffer
+ nReadBytes = nMaxLen;
}
else
{