[Libreoffice-commits] .: 3 commits - connectivity/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Tue Dec 25 04:07:58 PST 2012


 connectivity/source/drivers/odbcbase/ODatabaseMetaDataResultSet.cxx |    1 
 connectivity/source/drivers/odbcbase/OTools.cxx                     |   21 ++++------
 2 files changed, 11 insertions(+), 11 deletions(-)

New commits:
commit 5c0ca47ea05ac169c3aa6af5e95321b5de3e439d
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date:   Tue Dec 25 12:55:59 2012 +0100

    ODBC: binary data is not null-terminated
    
    Change-Id: Ibc90fabf7534b537948c12de76b611daf5ca9808

diff --git a/connectivity/source/drivers/odbcbase/OTools.cxx b/connectivity/source/drivers/odbcbase/OTools.cxx
index fbeeec6..d568b7f 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
         {
commit 12bad6a4e958d01bd5b6195e612543829aebe978
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date:   Tue Dec 25 13:05:04 2012 +0100

    no reason to treat CHAR differently than VARCHAR
    
    Change-Id: I19a9f1b26d36bc6eb9e878506e51e8a65b34da9a

diff --git a/connectivity/source/drivers/odbcbase/ODatabaseMetaDataResultSet.cxx b/connectivity/source/drivers/odbcbase/ODatabaseMetaDataResultSet.cxx
index c8e4156..642aba6 100644
--- a/connectivity/source/drivers/odbcbase/ODatabaseMetaDataResultSet.cxx
+++ b/connectivity/source/drivers/odbcbase/ODatabaseMetaDataResultSet.cxx
@@ -250,6 +250,7 @@ Sequence< sal_Int8 > SAL_CALL ODatabaseMetaDataResultSet::getBytes( sal_Int32 co
         sal_Int32 nType = getMetaData()->getColumnType(columnIndex);
         switch(nType)
         {
+            case DataType::CHAR:
             case DataType::VARCHAR:
             case DataType::LONGVARCHAR:
             {
commit 2f54f2a4ac508de3984d2865da984b9ecf30f602
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date:   Tue Dec 25 13:04:44 2012 +0100

    fdo#58693 ODBC SQLGetData returns byte length, not data size
    
    Change-Id: Icd2f6503d9452c36f858180e4193af993ae7e288

diff --git a/connectivity/source/drivers/odbcbase/OTools.cxx b/connectivity/source/drivers/odbcbase/OTools.cxx
index 290aa61..fbeeec6 100644
--- a/connectivity/source/drivers/odbcbase/OTools.cxx
+++ b/connectivity/source/drivers/odbcbase/OTools.cxx
@@ -447,6 +447,8 @@ Sequence<sal_Int8> OTools::getBytesValue(const OConnection* _pConnection,
                 return ::rtl::OUString();
 
             SQLLEN nReadChars;
+            OSL_ENSURE( (pcbValue < 0) || (pcbValue % 2 == 0),
+                        "ODBC: SQLGetData of SQL_C_WCHAR returned odd number of bytes");
             if ( (pcbValue == SQL_NO_TOTAL) || (pcbValue >= nMaxLen) )
             {
                 // we filled the buffer; remove the terminating null character
@@ -459,7 +461,7 @@ Sequence<sal_Int8> OTools::getBytesValue(const OConnection* _pConnection,
             }
             else
             {
-                nReadChars = pcbValue;
+                nReadChars = pcbValue/sizeof(sal_Unicode);
             }
 
             aData.append(waCharArray, nReadChars);


More information about the Libreoffice-commits mailing list