[Libreoffice-commits] core.git: Branch 'libreoffice-7-2' - connectivity/source

2022-04-12 Thread Caolán McNamara (via logerrit)
 connectivity/source/drivers/dbase/DTable.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 67851564d74bc8108e4802abfeb4fb88f4adf71d
Author: Caolán McNamara 
AuthorDate: Sat Apr 9 09:56:23 2022 +0100
Commit: Michael Stahl 
CommitDate: Tue Apr 12 11:31:48 2022 +0200

ofz#46526 Abrt

Change-Id: Iaec536b0989c4ec11b39b1534c7798e46715d7a0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132710
Tested-by: Jenkins
Reviewed-by: Michael Stahl 

diff --git a/connectivity/source/drivers/dbase/DTable.cxx 
b/connectivity/source/drivers/dbase/DTable.cxx
index ac51e4b53311..e9d626c415de 100644
--- a/connectivity/source/drivers/dbase/DTable.cxx
+++ b/connectivity/source/drivers/dbase/DTable.cxx
@@ -949,7 +949,7 @@ bool ODbaseTable::fetchRow(OValueRefRow& _rRow, const 
OSQLColumns & _rCols, bool
 {
 case DataType::DATE:
 {
-if (aStr.getLength() != nLen)
+if (nLen < 8 || aStr.getLength() != nLen)
 {
 (*_rRow)[i]->setNull();
 break;


[Libreoffice-commits] core.git: Branch 'libreoffice-7-2' - connectivity/source

2022-01-10 Thread Julien Nabet (via logerrit)
 connectivity/source/drivers/mysqlc/mysqlc_general.cxx|3 
 connectivity/source/drivers/mysqlc/mysqlc_prepared_resultset.cxx |   32 
+-
 2 files changed, 33 insertions(+), 2 deletions(-)

New commits:
commit 0dec041cb8156afb4d022d94c4c6a1d9fa222f91
Author: Julien Nabet 
AuthorDate: Mon Jan 3 21:19:56 2022 +0100
Commit: Xisco Fauli 
CommitDate: Mon Jan 10 16:56:48 2022 +0100

tdf#146432: fix crash with REGEXP_REPLACE() executed in query editor to 
MariaDB

See bt here:
https://bugs.documentfoundation.org/attachment.cgi?id=177292

Noticing:

warn:legacy.osl:7697:7697:connectivity/source/drivers/mysqlc/mysqlc_general.cxx:188:
 mysqlToOOOType: unhandled case, falling back to VARCHAR
I found REGEXP_REPLACE returned a MYSQL_TYPE_LONG_BLOB and some locations 
should be taught about it.

Also, let's also deal with MYSQL_TYPE_TINY_BLOB and MYSQL_TYPE_MEDIUM_BLOB

Change-Id: Ib7fd6ef747ce1b1851c788d2bb5a1d4ec673aee1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127919
(cherry picked from commit e43573aae0fa07d170fb042b7184156c851c1f77)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127952
Reviewed-by: Lionel Mamane 
Tested-by: Jenkins
Signed-off-by: Xisco Fauli 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128220

diff --git a/connectivity/source/drivers/mysqlc/mysqlc_general.cxx 
b/connectivity/source/drivers/mysqlc/mysqlc_general.cxx
index 878efdc3be24..c56bef962c7d 100644
--- a/connectivity/source/drivers/mysqlc/mysqlc_general.cxx
+++ b/connectivity/source/drivers/mysqlc/mysqlc_general.cxx
@@ -163,6 +163,9 @@ sal_Int32 mysqlToOOOType(int eType, int charsetnr) noexcept
 return css::sdbc::DataType::VARCHAR;
 
 case MYSQL_TYPE_BLOB:
+case MYSQL_TYPE_TINY_BLOB:
+case MYSQL_TYPE_MEDIUM_BLOB:
+case MYSQL_TYPE_LONG_BLOB:
 if (charsetnr == 63)
 return css::sdbc::DataType::LONGVARBINARY;
 return css::sdbc::DataType::LONGVARCHAR;
diff --git a/connectivity/source/drivers/mysqlc/mysqlc_prepared_resultset.cxx 
b/connectivity/source/drivers/mysqlc/mysqlc_prepared_resultset.cxx
index 22f5499ea9a2..0c4dba0559d5 100644
--- a/connectivity/source/drivers/mysqlc/mysqlc_prepared_resultset.cxx
+++ b/connectivity/source/drivers/mysqlc/mysqlc_prepared_resultset.cxx
@@ -106,12 +106,24 @@ bool OPreparedResultSet::fetchResult()
 }
 for (sal_Int32 i = 0; i < m_nColumnCount; ++i)
 {
+bool bIsBlobType = false;
+switch (m_aFields[i].type)
+{
+case MYSQL_TYPE_BLOB:
+case MYSQL_TYPE_TINY_BLOB:
+case MYSQL_TYPE_MEDIUM_BLOB:
+case MYSQL_TYPE_LONG_BLOB:
+bIsBlobType = true;
+break;
+default:
+bIsBlobType = false;
+}
 m_aMetaData[i].is_null = false;
 m_aMetaData[i].length = 0l;
 m_aMetaData[i].error = false;
 
 m_aData[i].is_null = _aMetaData[i].is_null;
-m_aData[i].buffer_length = m_aFields[i].type == MYSQL_TYPE_BLOB ? 0 : 
m_aFields[i].length;
+m_aData[i].buffer_length = bIsBlobType ? 0 : m_aFields[i].length;
 m_aData[i].length = _aMetaData[i].length;
 m_aData[i].error = _aMetaData[i].error;
 m_aData[i].buffer = nullptr;
@@ -303,8 +315,21 @@ template <> OUString 
OPreparedResultSet::retrieveValue(sal_Int32 column)
 {
 // redirect call to the appropriate method if needed
 // BLOB can be simply read out as string
+bool bIsBlobType = false;
+switch (m_aFields[column - 1].type)
+{
+case MYSQL_TYPE_BLOB:
+case MYSQL_TYPE_TINY_BLOB:
+case MYSQL_TYPE_MEDIUM_BLOB:
+case MYSQL_TYPE_LONG_BLOB:
+bIsBlobType = true;
+break;
+default:
+bIsBlobType = false;
+}
+
 if (getTypeFromMysqlType(m_aFields[column - 1].type) != 
std::type_index(typeid(OUString))
-&& m_aFields[column - 1].type != MYSQL_TYPE_BLOB)
+&& !bIsBlobType)
 return getRowSetValue(column);
 const char* sStr = static_cast(m_aData[column - 1].buffer);
 
@@ -341,6 +366,9 @@ ORowSetValue OPreparedResultSet::getRowSetValue(sal_Int32 
nColumnIndex)
 case MYSQL_TYPE_NEWDECIMAL:
 return getString(nColumnIndex);
 case MYSQL_TYPE_BLOB:
+case MYSQL_TYPE_TINY_BLOB:
+case MYSQL_TYPE_MEDIUM_BLOB:
+case MYSQL_TYPE_LONG_BLOB:
 throw SQLException("Column with type BLOB cannot be converted", 
*this, "22000", 1,
Any());
 default:


[Libreoffice-commits] core.git: Branch 'libreoffice-7-2' - connectivity/source

2021-12-27 Thread Julien Nabet (via logerrit)
 connectivity/source/drivers/firebird/PreparedStatement.cxx |6 ++
 1 file changed, 6 insertions(+)

New commits:
commit 30fb61f80bba3b119d2fbfb450e3cf1ae7e65d59
Author: Julien Nabet 
AuthorDate: Mon Dec 27 16:58:05 2021 +0100
Commit: Julien Nabet 
CommitDate: Mon Dec 27 20:39:59 2021 +0100

tdf#130595: Parameter query with :parameter IS NULL doesn't work

Problematic SQL here:
SELECT * FROM "Table1" WHERE "Name" = :name OR :name IS NULL

Firebird considers there are 2 parameters.

When providing an empty string, no pb, OPreparedStatement::setNull is 
called which is ok for both parameters

When providing a non empty string, we go to OPreparedStatement::setString. 
For first param no pb
but for second param, sql type is SQL_NULL so it must be taken into account
See 
https://www.firebirdsql.org/file/documentation/html/en/refdocs/fblangref25/firebird-25-language-reference.html#fblangref25-datatypes-special-sqlnull
for full details

Change-Id: I80dff259d85957e8547c098e4c48b642cce26804
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127572
Reviewed-by: Lionel Mamane 
Tested-by: Jenkins

diff --git a/connectivity/source/drivers/firebird/PreparedStatement.cxx 
b/connectivity/source/drivers/firebird/PreparedStatement.cxx
index 3b5511518957..db49ad2e4d8d 100644
--- a/connectivity/source/drivers/firebird/PreparedStatement.cxx
+++ b/connectivity/source/drivers/firebird/PreparedStatement.cxx
@@ -264,6 +264,12 @@ void SAL_CALL OPreparedStatement::setString(sal_Int32 
nParameterIndex,
 setBoolean(nParameterIndex, boolValue);
 break;
 }
+case SQL_NULL:
+{
+// See 
https://www.firebirdsql.org/file/documentation/html/en/refdocs/fblangref25/firebird-25-language-reference.html#fblangref25-datatypes-special-sqlnull
+pVar->sqldata = nullptr;
+break;
+}
 default:
 ::dbtools::throwSQLException(
 "Incorrect type for setString",


[Libreoffice-commits] core.git: Branch 'libreoffice-7-2' - connectivity/source

2021-12-27 Thread Julien Nabet (via logerrit)
 connectivity/source/drivers/firebird/Util.cxx |6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

New commits:
commit ead9112bb80d48d22f121ed79422acbc2ef6f296
Author: Julien Nabet 
AuthorDate: Mon Dec 27 11:34:27 2021 +0100
Commit: Julien Nabet 
CommitDate: Mon Dec 27 15:49:39 2021 +0100

Related tdf#130595: SQL_NULL means pVar->sqldata = nullptr

Fix this assertion:
0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:49
1  0x7fcc7f2b2536 in __GI_abort () at abort.c:79
2  0x7fcc7f2b241f in __assert_fail_base
   (fmt=0x7fcc7f418998 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", 
assertion=0x7fcc614a5de7 "false", file=0x7fcc614b3542 
"/home/julien/lo/libreoffice/connectivity/source/drivers/firebird/Util.cxx", 
line=346, function=) at assert.c:92
3  0x7fcc7f2c1212 in __GI___assert_fail
   (assertion=0x7fcc614a5de7 "false", file=0x7fcc614b3542 
"/home/julien/lo/libreoffice/connectivity/source/drivers/firebird/Util.cxx", 
line=346, function=0x7fcc614b3865 "void 
connectivity::firebird::mallocSQLVAR(XSQLDA *)") at assert.c:101
4  0x7fcc6149c715 in connectivity::firebird::mallocSQLVAR(XSQLDA*) 
(pSqlda=0x5bca950) at connectivity/source/drivers/firebird/Util.cxx:346
5  0x7fcc61470722 in 
connectivity::firebird::OPreparedStatement::ensurePrepared() (this=0x5bc6a10) 
at connectivity/source/drivers/firebird/PreparedStatement.cxx:110
6  0x7fcc614714df in 
connectivity::firebird::OPreparedStatement::getMetaData() (this=0x5bc6a10) at 
connectivity/source/drivers/firebird/PreparedStatement.cxx:147
7  0x7fcc6147165d in non-virtual thunk to 
connectivity::firebird::OPreparedStatement::getMetaData() () at 
connectivity/source/drivers/firebird/PreparedStatement.cxx:154
8  0x7fcc66694776 in dbaccess::OPreparedStatement::getMetaData() 
(this=0x5bc6cc0) at dbaccess/source/core/api/preparedstatement.cxx:178
9  0x7fcc6669480d in non-virtual thunk to 
dbaccess::OPreparedStatement::getMetaData() () at 
dbaccess/source/core/api/preparedstatement.cxx:179
10 0x7fcc667711bd in dbaccess::OSingleSelectQueryComposer::getColumns() 
(this=0x5bb99f0) at dbaccess/source/core/api/SingleSelectQueryComposer.cxx:824

Change-Id: I285c9bcd0b1fd059994d339ae4d419dec516f220
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127551
Tested-by: Jenkins
Reviewed-by: Julien Nabet 
(cherry picked from commit abaf2b4ac7faada914885d95c49b554f576d7cee)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127568
Reviewed-by: Lionel Mamane 

diff --git a/connectivity/source/drivers/firebird/Util.cxx 
b/connectivity/source/drivers/firebird/Util.cxx
index 6cc70b4270f4..2d8d6b80a888 100644
--- a/connectivity/source/drivers/firebird/Util.cxx
+++ b/connectivity/source/drivers/firebird/Util.cxx
@@ -342,8 +342,9 @@ void firebird::mallocSQLVAR(XSQLDA* pSqlda)
 case SQL_BOOLEAN:
 pVar->sqldata = static_cast(malloc(sizeof(sal_Bool)));
 break;
+// See 
https://www.firebirdsql.org/file/documentation/html/en/refdocs/fblangref25/firebird-25-language-reference.html#fblangref25-datatypes-special-sqlnull
 case SQL_NULL:
-assert(false); // TODO: implement
+pVar->sqldata = nullptr;
 break;
 case SQL_QUAD:
 assert(false); // TODO: implement
@@ -388,7 +389,8 @@ void firebird::freeSQLVAR(XSQLDA* pSqlda)
 }
 break;
 case SQL_NULL:
-assert(false); // TODO: implement
+// See SQL_NULL case in mallocSQLVAR
+assert(pVar->sqldata == nullptr);
 break;
 case SQL_QUAD:
 assert(false); // TODO: implement


[Libreoffice-commits] core.git: Branch 'libreoffice-7-2' - connectivity/source

2021-12-19 Thread Julien Nabet (via logerrit)
 connectivity/source/drivers/flat/EDatabaseMetaData.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 125e118d661a731caa7efb7ce69b2eb55e695c73
Author: Julien Nabet 
AuthorDate: Sat Dec 18 19:19:28 2021 +0100
Commit: Caolán McNamara 
CommitDate: Sun Dec 19 16:46:26 2021 +0100

Regression from e01786898406130aa81eadc32f7bc2fad65c5344

author  Julien Nabet   2021-05-14 18:46:57 +0200
committer   Julien Nabet   2021-05-14 23:09:11 
+0200
commit  e01786898406130aa81eadc32f7bc2fad65c5344 (patch)
tree6852a41ac21a081114f51f5c0272249eb5f962d6
parent  be96aa21aed3069775609780566541b3631cbbe1 (diff)
Directly initialize vector in connectivity (part 3)

Change-Id: Ib4097b3425e07de73abbc47ffefebb06b1458308
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127054
Tested-by: Caolán McNamara 
Reviewed-by: Caolán McNamara 

diff --git a/connectivity/source/drivers/flat/EDatabaseMetaData.cxx 
b/connectivity/source/drivers/flat/EDatabaseMetaData.cxx
index 0170c67ed3b0..d166ba58b304 100644
--- a/connectivity/source/drivers/flat/EDatabaseMetaData.cxx
+++ b/connectivity/source/drivers/flat/EDatabaseMetaData.cxx
@@ -53,7 +53,7 @@ Reference< XResultSet > 
OFlatDatabaseMetaData::impl_getTypeInfo_throw(  )
 
 static ODatabaseMetaDataResultSet::ORows aRows = [&]()
 {
-ODatabaseMetaDataResultSet::ORows tmp(10);
+ODatabaseMetaDataResultSet::ORows tmp;
 ODatabaseMetaDataResultSet::ORow aRow
 {
  ODatabaseMetaDataResultSet::getEmptyValue() ,


[Libreoffice-commits] core.git: Branch 'libreoffice-7-2' - connectivity/source

2021-12-17 Thread Julien Nabet (via logerrit)
 connectivity/source/drivers/evoab2/EApi.cxx  |   54 --
 connectivity/source/drivers/evoab2/EApi.h|2 
 connectivity/source/drivers/evoab2/NDatabaseMetaData.cxx |  121 +++---
 connectivity/source/drivers/evoab2/NResultSet.cxx|  125 ---
 4 files changed, 39 insertions(+), 263 deletions(-)

New commits:
commit 3b9210195b8d2ac9861a1e607455ff9d16eb68fd
Author: Julien Nabet 
AuthorDate: Wed Dec 15 22:45:47 2021 +0100
Commit: Caolán McNamara 
CommitDate: Fri Dec 17 09:51:13 2021 +0100

tdf#137101: fix e_book_client_connect_direct_sync signature in Evolution

since it changed in 2015, see all details from tdf#137101
Thank you to krumelmonster for having spotted this!

+ some cleanup to remove all eds_check_version calls
and dependencies

Change-Id: Iaf2437f8f5c04ab9674a380dac1dfb16ec8c7201
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126898
Tested-by: Jenkins
Tested-by: Caolán McNamara 
Reviewed-by: Caolán McNamara 
(cherry picked from commit 0661c796c767802c114441ad9a17fd0979d72ef4)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126920

diff --git a/connectivity/source/drivers/evoab2/EApi.cxx 
b/connectivity/source/drivers/evoab2/EApi.cxx
index 56a957fabb63..e5ce60e659e6 100644
--- a/connectivity/source/drivers/evoab2/EApi.cxx
+++ b/connectivity/source/drivers/evoab2/EApi.cxx
@@ -23,16 +23,7 @@
 static const char *eBookLibNames[] = {
 "libebook-1.2.so.20", // evolution-data-server 3.33.2+
 "libebook-1.2.so.19", // evolution-data-server 3.24+
-"libebook-1.2.so.16",
-"libebook-1.2.so.15",
-"libebook-1.2.so.14", // bumped again (evolution-3.6)
-"libebook-1.2.so.13", // bumped again (evolution-3.4)
-"libebook-1.2.so.12", // bumped again
-"libebook-1.2.so.10", // bumped again
-"libebook-1.2.so.9",  // evolution-2.8
-"libebook-1.2.so.5",  // evolution-2.4 and 2.6+
-"libebook-1.2.so.3",  // evolution-2.2
-"libebook.so.8"   // evolution-2.0
+"libebook-1.2.so.16"
 };
 
 typedef void (*SymbolFunc) ();
@@ -71,20 +62,6 @@ const ApiMap aCommonApiMap[] =
 SYM_MAP( e_book_query_field_exists )
 };
 
-//< 3.6 api
-const ApiMap aOldApiMap[] =
-{
-SYM_MAP( e_book_get_addressbooks ),
-SYM_MAP( e_book_get_uri ),
-SYM_MAP( e_book_authenticate_user ),
-SYM_MAP( e_source_group_peek_base_uri),
-SYM_MAP( e_source_peek_name ),
-SYM_MAP( e_source_get_property ),
-SYM_MAP( e_source_list_peek_groups ),
-SYM_MAP( e_source_group_peek_sources )
-};
-
-//>= 3.6 api
 const ApiMap aNewApiMap[] =
 {
 SYM_MAP( e_source_registry_list_sources ),
@@ -101,12 +78,6 @@ const ApiMap aNewApiMap[] =
 SYM_MAP( e_client_util_free_object_slist )
 };
 
-//== indirect read access (3.6 only)
-const ApiMap aClientApiMap36[] =
-{
-SYM_MAP( e_book_client_new )
-};
-
 //>= direct read access API (>= 3.8)
 const ApiMap aClientApiMap38[] =
 {
@@ -144,33 +115,14 @@ bool EApiInit()
 
 if (tryLink( aModule, eBookLibNames[ j ], aCommonApiMap))
 {
-if (eds_check_version( 3, 6, 0 ) != nullptr)
+if (tryLink( aModule, eBookLibNames[ j ], aNewApiMap))
 {
-if (tryLink( aModule, eBookLibNames[ j ], aOldApiMap))
+if (tryLink( aModule, eBookLibNames[ j ], aClientApiMap38))
 {
 aModule.release();
 return true;
 }
 }
-else if (tryLink( aModule, eBookLibNames[ j ], aNewApiMap))
-{
-if (eds_check_version( 3, 7, 6 ) != nullptr)
-{
-if (tryLink( aModule, eBookLibNames[ j ], aClientApiMap36))
-{
-aModule.release();
-return true;
-}
-}
-else
-{
-if (tryLink( aModule, eBookLibNames[ j ], aClientApiMap38))
-{
-aModule.release();
-return true;
-}
-}
-}
 }
 }
 fprintf( stderr, "Can find no compliant libebook client libraries\n" );
diff --git a/connectivity/source/drivers/evoab2/EApi.h 
b/connectivity/source/drivers/evoab2/EApi.h
index 4d17922aab30..9a2138eb2a26 100644
--- a/connectivity/source/drivers/evoab2/EApi.h
+++ b/connectivity/source/drivers/evoab2/EApi.h
@@ -146,7 +146,7 @@ EAPI_EXTERN const gchar* (*eds_check_version) (guint 
required_major, guint requi
 EAPI_EXTERN const gchar* (*e_source_get_uid) (ESource *source);
 EAPI_EXTERN ESource* (*e_source_registry_ref_source) (ESourceRegistry 
*registry, const gchar *uid);
 EAPI_EXTERN EBookClient* (*e_book_client_new) (ESource *source, GError 
**error);
-EAPI_EXTERN EBookClient* (*e_book_client_connect_direct_sync) (ESourceRegistry 
*registry, ESource *source, GCancellable 

[Libreoffice-commits] core.git: Branch 'libreoffice-7-2' - connectivity/source

2021-12-13 Thread Julien Nabet (via logerrit)
 connectivity/source/drivers/evoab2/NDatabaseMetaData.cxx |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

New commits:
commit cf3672dd1803edd435acbcd6aaaf07e7a0e8c74c
Author: Julien Nabet 
AuthorDate: Sat Dec 11 15:59:53 2021 +0100
Commit: Xisco Fauli 
CommitDate: Mon Dec 13 15:19:00 2021 +0100

Fix regression in connectivity/evoab2

Regression from 46d3e84d7a131f7c72cb536ab2f314cb55ffc155
Directly initialize vector in connectivity (part 2)

Pinpointed thanks to this log:

warn:dbaccess:612118:612118:dbaccess/source/core/dataaccess/connection.cxx:344: 
DBG_UNHANDLED_EXCEPTION in OConnection exception: 
com.sun.star.sdbc.SQLException message: Invalid descriptor index. 
/home/julien/lo/libreoffice/connectivity/source/commontools/dbexception.cxx:365 
SQLState: 07009 ErrorCode: 0
wrapped: void message: 
/home/julien/lo/libreoffice/tools/source/debug/debug.cxx:104
when launching Base then connecting to Evolution local.

Change-Id: Id4cb0fc322b0df24ed2b2d89a5595f4841db1845
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126672
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 
(cherry picked from commit 80eb86b7e697751d24ca12310e6b6e23a1bb54cf)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126682

diff --git a/connectivity/source/drivers/evoab2/NDatabaseMetaData.cxx 
b/connectivity/source/drivers/evoab2/NDatabaseMetaData.cxx
index 6c798e5a166c..3f6e00aa43bb 100644
--- a/connectivity/source/drivers/evoab2/NDatabaseMetaData.cxx
+++ b/connectivity/source/drivers/evoab2/NDatabaseMetaData.cxx
@@ -989,7 +989,7 @@ Reference< XResultSet > SAL_CALL 
OEvoabDatabaseMetaData::getTableTypes(  )
 
 // here we fill the rows which should be visible when ask for data from 
the resultset returned here
 auto nNbTypes = SAL_N_ELEMENTS(sTableTypes);
-ODatabaseMetaDataResultSet::ORows aRows(nNbTypes);
+ODatabaseMetaDataResultSet::ORows aRows;
 for(std::size_t i=0;i < nNbTypes;++i)
 {
 // bound row
@@ -1010,7 +1010,7 @@ Reference< XResultSet > 
OEvoabDatabaseMetaData::impl_getTypeInfo_throw(  )
 
 static ODatabaseMetaDataResultSet::ORows aRows = []()
 {
-ODatabaseMetaDataResultSet::ORows tmp(2);
+ODatabaseMetaDataResultSet::ORows tmp;
 ODatabaseMetaDataResultSet::ORow aRow
 {
  ODatabaseMetaDataResultSet::getEmptyValue() ,


[Libreoffice-commits] core.git: Branch 'libreoffice-7-2' - connectivity/source

2021-11-26 Thread Caolán McNamara (via logerrit)
 connectivity/source/drivers/postgresql/pq_databasemetadata.cxx |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 07830e04efe28b8be386a8944421e6e184eb444e
Author: Caolán McNamara 
AuthorDate: Thu Nov 25 10:09:42 2021 +
Commit: Michael Stahl 
CommitDate: Fri Nov 26 11:29:27 2021 +0100

stldebug assert in bad sort of postgresql schemas


/usr/bin/../lib/gcc/x86_64-redhat-linux/11/../../../../include/c++/11/debug/safe_iterator.h:305:
In function:
__gnu_debug::_Safe_iterator::reference
__gnu_debug::_Safe_iterator<__gnu_cxx::__normal_iterator>, std::vector,
std::forward_iterator_tag>::operator*() const [_Iterator =
__gnu_cxx::__normal_iterator>, _Sequence =
std::vector, _Category = std::forward_iterator_tag]

Error: attempt to dereference a past-the-end iterator.

Objects involved in the operation:
iterator "this" @ 0x0x7fff75a8 {
  type = __gnu_cxx::__normal_iterator > > 
(mutable iterator);
  state = past-the-end;
  references sequence with type 'std::__debug::vector >' @ 0x0x7fff7d10
}

Thread 1 "soffice.bin" received signal SIGABRT, Aborted.

a problem since...

commit 5cbb6631e6d4c1000bff936712b4bd4aafbe04d5
Date:   Fri Mar 4 13:01:57 2016 +0100

pgsql-sdbc: factorise common code

Change-Id: I7f7794e93224dfa946a7b5970c458fc3030fab73
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125726
Tested-by: Jenkins
Reviewed-by: Michael Stahl 

diff --git a/connectivity/source/drivers/postgresql/pq_databasemetadata.cxx 
b/connectivity/source/drivers/postgresql/pq_databasemetadata.cxx
index 8f2021608830..8940d08011d6 100644
--- a/connectivity/source/drivers/postgresql/pq_databasemetadata.cxx
+++ b/connectivity/source/drivers/postgresql/pq_databasemetadata.cxx
@@ -1229,7 +1229,7 @@ namespace
 OUString valueB;
 a[0] >>= valueA;
 b[0] >>= valueB;
-return compare_schema(valueA, valueB);
+return compare_schema(valueA, valueB) < 0;
 }
 };
 }


[Libreoffice-commits] core.git: Branch 'libreoffice-7-2' - connectivity/source sc/qa

2021-09-27 Thread Caolán McNamara (via logerrit)
 connectivity/source/drivers/dbase/DTable.cxx |   28 ++-
 sc/qa/unit/data/dbf/pass/ooo83401-1.dbf  |binary
 2 files changed, 19 insertions(+), 9 deletions(-)

New commits:
commit c43f185a81e667c5e34a91f5dd1fd1a4e5a33b58
Author: Caolán McNamara 
AuthorDate: Thu Sep 23 20:19:57 2021 +0100
Commit: Michael Stahl 
CommitDate: Mon Sep 27 12:27:39 2021 +0200

do some sanity checks on the number of records claimed

while retaining the fix of #i83401# to recovered a broken case

Change-Id: I283c45b10aaa24004a34bfe6faee517d4a443b98
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122543
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 
(cherry picked from commit cea0753e18171bf9bcdd857535b20e6ed0f5)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122445
Reviewed-by: Michael Stahl 

diff --git a/connectivity/source/drivers/dbase/DTable.cxx 
b/connectivity/source/drivers/dbase/DTable.cxx
index c9c2991589db..ac51e4b53311 100644
--- a/connectivity/source/drivers/dbase/DTable.cxx
+++ b/connectivity/source/drivers/dbase/DTable.cxx
@@ -510,6 +510,24 @@ void ODbaseTable::construct()
 return;
 }
 
+if (m_aHeader.recordLength)
+{
+std::size_t nMaxPossibleRecords = (nFileSize - m_aHeader.headerLength) 
/ m_aHeader.recordLength;
+// #i83401# seems to be empty or someone wrote nonsense into the dbase
+// file try and recover if m_aHeader.db_slng is sane
+if (m_aHeader.nbRecords == 0)
+{
+SAL_WARN("connectivity.drivers", "Parsing warning: 0 records 
claimed, recovering");
+m_aHeader.nbRecords = nMaxPossibleRecords;
+}
+else if (m_aHeader.nbRecords > nMaxPossibleRecords)
+{
+SAL_WARN("connectivity.drivers", "Parsing error: " << 
nMaxPossibleRecords <<
+ " max possible records, but " << m_aHeader.nbRecords << " 
claimed, truncating");
+m_aHeader.nbRecords = std::max(nMaxPossibleRecords, 
static_cast(1));
+}
+}
+
 if (HasMemoFields())
 {
 // Create Memo-Filename (.DBT):
@@ -533,16 +551,8 @@ void ODbaseTable::construct()
 }
 
 fillColumns();
-
 m_pFileStream->Seek(STREAM_SEEK_TO_BEGIN);
-// seems to be empty or someone wrote bullshit into the dbase file
-// try and recover if m_aHeader.db_slng is sane
-if (m_aHeader.nbRecords == 0 && m_aHeader.recordLength)
-{
-std::size_t nRecords = 
(nFileSize-m_aHeader.headerLength)/m_aHeader.recordLength;
-if (nRecords > 0)
-m_aHeader.nbRecords = nRecords;
-}
+
 
 // Buffersize dependent on the file size
 m_pFileStream->SetBufferSize(nFileSize > 100 ? 32768 :
diff --git a/sc/qa/unit/data/dbf/pass/ooo83401-1.dbf 
b/sc/qa/unit/data/dbf/pass/ooo83401-1.dbf
new file mode 100644
index ..c916dc923e51
Binary files /dev/null and b/sc/qa/unit/data/dbf/pass/ooo83401-1.dbf differ


[Libreoffice-commits] core.git: Branch 'libreoffice-7-2' - connectivity/source

2021-09-27 Thread Caolán McNamara (via logerrit)
 connectivity/source/drivers/dbase/DTable.cxx |   13 -
 1 file changed, 8 insertions(+), 5 deletions(-)

New commits:
commit d0e177b7019af7f023dbf8c68b74233fea7d3bd8
Author: Caolán McNamara 
AuthorDate: Sun Sep 26 14:05:37 2021 +0100
Commit: Michael Stahl 
CommitDate: Mon Sep 27 12:16:55 2021 +0200

ofz#39304 short timestamp record

Change-Id: I8f783473dd5d4679846c7c866cd1853ef7d919fc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122633
Tested-by: Jenkins
Reviewed-by: Michael Stahl 

diff --git a/connectivity/source/drivers/dbase/DTable.cxx 
b/connectivity/source/drivers/dbase/DTable.cxx
index b6b1e7a7c3d1..c9c2991589db 100644
--- a/connectivity/source/drivers/dbase/DTable.cxx
+++ b/connectivity/source/drivers/dbase/DTable.cxx
@@ -795,10 +795,8 @@ bool ODbaseTable::fetchRow(OValueRefRow& _rRow, const 
OSQLColumns & _rCols, bool
 for (std::size_t i = 1; aIter != aEnd && nByteOffset <= m_nBufferSize && i 
< nCount;++aIter, i++)
 {
 // Lengths depending on data type:
-sal_Int32 nLen = 0;
-sal_Int32 nType = 0;
-nLen= m_aPrecisions[i-1];
-nType   = m_aTypes[i-1];
+sal_Int32 nLen = m_aPrecisions[i-1];
+sal_Int32 nType = m_aTypes[i-1];
 
 switch(nType)
 {
@@ -857,8 +855,13 @@ bool ODbaseTable::fetchRow(OValueRefRow& _rRow, const 
OSQLColumns & _rCols, bool
 else if ( DataType::TIMESTAMP == nType )
 {
 sal_Int32 nDate = 0,nTime = 0;
+if (o3tl::make_unsigned(nLen) < 8)
+{
+SAL_WARN("connectivity.drivers", "short TIMESTAMP");
+return false;
+}
 memcpy(, pData, 4);
-memcpy(, pData+ 4, 4);
+memcpy(, pData + 4, 4);
 if ( !nDate && !nTime )
 {
 (*_rRow)[i]->setNull();


[Libreoffice-commits] core.git: Branch 'libreoffice-7-2' - connectivity/source

2021-09-27 Thread Caolán McNamara (via logerrit)
 connectivity/source/commontools/dbconversion.cxx |9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

New commits:
commit bc5dece13b5a78f3d8f9e699cd9dcf6bc7b2b7f8
Author: Caolán McNamara 
AuthorDate: Sun Sep 26 14:23:54 2021 +0100
Commit: Michael Stahl 
CommitDate: Mon Sep 27 12:16:21 2021 +0200

ofz#39301 month has to be in range [1-12]

Change-Id: I5a4ca534b24098342d8f465a32bc1887f40f5b63
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122635
Tested-by: Jenkins
Reviewed-by: Michael Stahl 

diff --git a/connectivity/source/commontools/dbconversion.cxx 
b/connectivity/source/commontools/dbconversion.cxx
index 13a799e55a9a..96b1f1dcfd0a 100644
--- a/connectivity/source/commontools/dbconversion.cxx
+++ b/connectivity/source/commontools/dbconversion.cxx
@@ -26,6 +26,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -163,10 +164,13 @@ namespace dbtools
 ;
 }
 
-
 static sal_Int32 implDaysInMonth(sal_Int32 _nMonth, sal_Int32 _nYear)
 {
-OSL_ENSURE(_nMonth > 0 && _nMonth < 13,"Month as invalid value!");
+SAL_WARN_IF(_nMonth < 1 || _nMonth > 12, "connectivity.commontools", 
"Month has invalid value: " << _nMonth);
+if (_nMonth < 1)
+_nMonth = 1;
+else if (_nMonth > 12)
+_nMonth = 12;
 if (_nMonth != 2)
 return aDaysInMonth[_nMonth-1];
 else
@@ -178,7 +182,6 @@ namespace dbtools
 }
 }
 
-
 static sal_Int32 implRelativeToAbsoluteNull(const css::util::Date& _rDate)
 {
 sal_Int32 nDays = 0;


[Libreoffice-commits] core.git: Branch 'libreoffice-7-2' - connectivity/source

2021-09-24 Thread Caolán McNamara (via logerrit)
 connectivity/source/drivers/dbase/DTable.cxx |6 +-
 1 file changed, 1 insertion(+), 5 deletions(-)

New commits:
commit 5b94d2f99fe4a80d53de28f15dbeec05f231bc90
Author: Caolán McNamara 
AuthorDate: Thu Sep 23 15:57:23 2021 +0100
Commit: Michael Stahl 
CommitDate: Fri Sep 24 11:19:30 2021 +0200

EOF isn't an error from SvStream::GetError perspective

Change-Id: Ib2bc2c35d78d92728d592676def300e28a8b9e2a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122442
Tested-by: Jenkins
Reviewed-by: Michael Stahl 

diff --git a/connectivity/source/drivers/dbase/DTable.cxx 
b/connectivity/source/drivers/dbase/DTable.cxx
index 34ea6dfe163c..b6b1e7a7c3d1 100644
--- a/connectivity/source/drivers/dbase/DTable.cxx
+++ b/connectivity/source/drivers/dbase/DTable.cxx
@@ -318,17 +318,13 @@ void ODbaseTable::fillColumns()
 for (; i < nFieldCount; i++)
 {
 DBFColumn aDBFColumn;
-#if !defined(NDEBUG)
-sal_uInt64 const nOldPos(m_pFileStream->Tell());
-#endif
 m_pFileStream->ReadBytes(aDBFColumn.db_fnm, 11);
 m_pFileStream->ReadUChar(aDBFColumn.db_typ);
 m_pFileStream->ReadUInt32(aDBFColumn.db_adr);
 m_pFileStream->ReadUChar(aDBFColumn.db_flng);
 m_pFileStream->ReadUChar(aDBFColumn.db_dez);
 m_pFileStream->ReadBytes(aDBFColumn.db_free2, 14);
-assert(m_pFileStream->GetError() || m_pFileStream->Tell() == nOldPos + 
sizeof(aDBFColumn));
-if (m_pFileStream->GetError())
+if (!m_pFileStream->good())
 {
 SAL_WARN("connectivity.drivers", "ODbaseTable::fillColumns: short 
read!");
 break;


[Libreoffice-commits] core.git: Branch 'libreoffice-7-2' - connectivity/source

2021-09-24 Thread Caolán McNamara (via logerrit)
 connectivity/source/drivers/dbase/DTable.cxx |   14 --
 1 file changed, 12 insertions(+), 2 deletions(-)

New commits:
commit e09f85ef08cd315bd5509ae4d47e82f81ac2a8c0
Author: Caolán McNamara 
AuthorDate: Thu Sep 23 20:07:21 2021 +0100
Commit: Michael Stahl 
CommitDate: Fri Sep 24 11:18:51 2021 +0200

check if headersize is greater than available data

Change-Id: I5d78da49436c7dfbe7cfb50e52549b61abc00ee9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122444
Tested-by: Jenkins
Reviewed-by: Michael Stahl 

diff --git a/connectivity/source/drivers/dbase/DTable.cxx 
b/connectivity/source/drivers/dbase/DTable.cxx
index 0872ff07e181..34ea6dfe163c 100644
--- a/connectivity/source/drivers/dbase/DTable.cxx
+++ b/connectivity/source/drivers/dbase/DTable.cxx
@@ -500,10 +500,20 @@ void ODbaseTable::construct()
 m_pFileStream = createStream_simpleError( sFileName, StreamMode::READ 
| StreamMode::NOCREATE | StreamMode::SHARE_DENYNONE);
 }
 
-if(!m_pFileStream)
+if (!m_pFileStream)
 return;
 
 readHeader();
+
+std::size_t nFileSize = lcl_getFileSize(*m_pFileStream);
+
+if (m_aHeader.headerLength > nFileSize)
+{
+SAL_WARN("connectivity.drivers", "Parsing error: " << nFileSize <<
+ " max possible size, but " << m_aHeader.headerLength << " 
claimed, abandoning");
+return;
+}
+
 if (HasMemoFields())
 {
 // Create Memo-Filename (.DBT):
@@ -525,9 +535,9 @@ void ODbaseTable::construct()
 if (m_pMemoStream)
 ReadMemoHeader();
 }
+
 fillColumns();
 
-std::size_t nFileSize = lcl_getFileSize(*m_pFileStream);
 m_pFileStream->Seek(STREAM_SEEK_TO_BEGIN);
 // seems to be empty or someone wrote bullshit into the dbase file
 // try and recover if m_aHeader.db_slng is sane


[Libreoffice-commits] core.git: Branch 'libreoffice-7-2' - connectivity/source

2021-09-24 Thread Caolán McNamara (via logerrit)
 connectivity/source/drivers/dbase/DTable.cxx |   23 ---
 1 file changed, 20 insertions(+), 3 deletions(-)

New commits:
commit 28a9bc70536a1319235f868c5f942f73cd5e6b21
Author: Caolán McNamara 
AuthorDate: Thu Sep 23 17:14:49 2021 +0100
Commit: Michael Stahl 
CommitDate: Fri Sep 24 11:11:11 2021 +0200

check claimed number of records against max possible with available data

Change-Id: I50d9354da00137c64c83970eb66792b37d7e545a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122443
Tested-by: Jenkins
Reviewed-by: Michael Stahl 

diff --git a/connectivity/source/drivers/dbase/DTable.cxx 
b/connectivity/source/drivers/dbase/DTable.cxx
index 5b1ea452f61a..0872ff07e181 100644
--- a/connectivity/source/drivers/dbase/DTable.cxx
+++ b/connectivity/source/drivers/dbase/DTable.cxx
@@ -273,7 +273,11 @@ void ODbaseTable::readHeader()
 void ODbaseTable::fillColumns()
 {
 m_pFileStream->Seek(STREAM_SEEK_TO_BEGIN);
-m_pFileStream->Seek(32);
+if (!checkSeek(*m_pFileStream, 32))
+{
+SAL_WARN("connectivity.drivers", "ODbaseTable::fillColumns: bad 
offset!");
+return;
+}
 
 if(!m_aColumns.is())
 m_aColumns = new OSQLColumns();
@@ -285,8 +289,21 @@ void ODbaseTable::fillColumns()
 m_aScales.clear();
 
 // Number of fields:
-const sal_Int32 nFieldCount = (m_aHeader.headerLength - 1) / 32 - 1;
-OSL_ENSURE(nFieldCount,"No columns in table!");
+sal_Int32 nFieldCount = (m_aHeader.headerLength - 1) / 32 - 1;
+if (nFieldCount <= 0)
+{
+SAL_WARN("connectivity.drivers", "No columns in table!");
+return;
+}
+
+auto nRemainingsize = m_pFileStream->remainingSize();
+auto nMaxPossibleRecords = nRemainingsize / 32;
+if (o3tl::make_unsigned(nFieldCount) > nMaxPossibleRecords)
+{
+SAL_WARN("connectivity.drivers", "Parsing error: " << 
nMaxPossibleRecords <<
+ " max possible entries, but " << nFieldCount << " claimed, 
truncating");
+nFieldCount = nMaxPossibleRecords;
+}
 
 m_aColumns->reserve(nFieldCount);
 m_aTypes.reserve(nFieldCount);


[Libreoffice-commits] core.git: Branch 'libreoffice-7-2' - connectivity/source

2021-09-15 Thread Stephan Bergmann (via logerrit)
 connectivity/source/parse/sqlbison.y |6 ++
 1 file changed, 6 insertions(+)

New commits:
commit 34be297edb6bb2fa7c0bca7504e5670d084ea782
Author: Stephan Bergmann 
AuthorDate: Tue Sep 14 12:20:48 2021 +0200
Commit: Michael Stahl 
CommitDate: Wed Sep 15 10:53:07 2021 +0200

Adapt to Bison 3.8 internal yyn -> yyrule rename

see


"glr2.cc: log the execution of deferred actions" including "Rename argument 
yyn
as yyrule for clarity."

YYBISON was defined as 1 rather than as a representation of the Bison 
version
prior to


"yacc.c: provide the Bison version as an integral macro", which shouldn't 
be a
problem here.  And YYBISON is apparently completely undefined with
/usr/bin/bison on macOS.

(The preceding comment always mentioned "yyi" and "yyrmap" in apparent 
mismatch
with the actually used "yyn" and "yyr1" ever since
c25ec0608a167bcf1d891043f02273761c351701 "initial import", so just leave it
untouched.)

Change-Id: I4f901407aa21ed4abec84e661d813ee7599f02f0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122082
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann 
(cherry picked from commit 45227d9b79dc4f2a2aa6874cd4e3c02b7934b197)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122069
Reviewed-by: Michael Stahl 

diff --git a/connectivity/source/parse/sqlbison.y 
b/connectivity/source/parse/sqlbison.y
index d14f36e7794f..c4be0bc00bd0 100644
--- a/connectivity/source/parse/sqlbison.y
+++ b/connectivity/source/parse/sqlbison.y
@@ -74,9 +74,15 @@ inline connectivity::OSQLInternalNode* newNode(const 
OUString& _newValue,
 
 // yyi is the internal number of the rule that is currently being reduced
 // This can be mapped to external rule number via the yyrmap.
+#if defined YYBISON && YYBISON >= 30800
+#define SQL_NEW_RULE   newNode("", SQLNodeType::Rule, 
yyr1[yyrule])
+#define SQL_NEW_LISTRULE   newNode("", SQLNodeType::ListRule, 
yyr1[yyrule])
+#define SQL_NEW_COMMALISTRULE   newNode("", SQLNodeType::CommaListRule, 
yyr1[yyrule])
+#else
 #define SQL_NEW_RULE   newNode("", SQLNodeType::Rule, 
yyr1[yyn])
 #define SQL_NEW_LISTRULE   newNode("", SQLNodeType::ListRule, 
yyr1[yyn])
 #define SQL_NEW_COMMALISTRULE   newNode("", SQLNodeType::CommaListRule, 
yyr1[yyn])
+#endif
 
 
 extern connectivity::OSQLParser* xxx_pGLOBAL_SQLPARSER;


[Libreoffice-commits] core.git: Branch 'libreoffice-7-2' - connectivity/source

2021-09-14 Thread Mike Kaganski (via logerrit)
 connectivity/source/drivers/firebird/Connection.cxx |   15 +++
 connectivity/source/drivers/firebird/Connection.hxx |5 +
 connectivity/source/drivers/firebird/Driver.cxx |6 --
 3 files changed, 24 insertions(+), 2 deletions(-)

New commits:
commit 19ac6869e129bf03737087eb32198026f9663894
Author: Mike Kaganski 
AuthorDate: Sat Sep 11 19:21:19 2021 +0200
Commit: Xisco Fauli 
CommitDate: Tue Sep 14 10:25:54 2021 +0200

tdf#117842: use XUnoTunnel to get wrapped connection reliably

XDataDefinitionSupplier::getDataDefinitionByConnection may take
not only direct reference to expected connection type, but also
connectivity::OConnectionWeakWrapper wrapping it.

Change-Id: I88925f9403b51f0cf13f02b5f00d3765a242230e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121890
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 
(cherry picked from commit ccc6c846eb7f6d334d0ab2e6b50c188c434caa19)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121986
Reviewed-by: Xisco Fauli 

diff --git a/connectivity/source/drivers/firebird/Connection.cxx 
b/connectivity/source/drivers/firebird/Connection.cxx
index 04f8d0a8185c..5e61aa5a0f0a 100644
--- a/connectivity/source/drivers/firebird/Connection.cxx
+++ b/connectivity/source/drivers/firebird/Connection.cxx
@@ -44,8 +44,10 @@
 #include 
 
 #include 
+#include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -361,6 +363,19 @@ Reference< XClob> Connection::createClob(ISC_QUAD const * 
pBlobId)
 return xReturn;
 }
 
+//- XUnoTunnel --
+// virtual
+sal_Int64 SAL_CALL Connection::getSomething(const 
css::uno::Sequence& rId)
+{
+return (isUnoTunnelId(rId)) ? 
reinterpret_cast(this) : sal_Int64(0);
+}
+
+// static
+css::uno::Sequence Connection::getUnoTunnelId()
+{
+static const cppu::OImplementationId implId;
+return implId.getImplementationId();
+}
 
 //- XConnection --
 Reference< XStatement > SAL_CALL Connection::createStatement( )
diff --git a/connectivity/source/drivers/firebird/Connection.hxx 
b/connectivity/source/drivers/firebird/Connection.hxx
index eba3b9710952..caf091146ae6 100644
--- a/connectivity/source/drivers/firebird/Connection.hxx
+++ b/connectivity/source/drivers/firebird/Connection.hxx
@@ -33,6 +33,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -45,6 +46,7 @@ namespace connectivity::firebird
 
 typedef ::cppu::WeakComponentImplHelper< 
css::document::XDocumentEventListener,
  css::lang::XServiceInfo,
+ css::lang::XUnoTunnel,
  css::sdbc::XConnection,
  css::sdbc::XWarningsSupplier
> Connection_BASE;
@@ -206,6 +208,9 @@ namespace connectivity::firebird
 
 // XServiceInfo
 DECLARE_SERVICE_INFO();
+// XUnoTunnel
+virtual sal_Int64 SAL_CALL getSomething(const 
css::uno::Sequence& rId) override;
+static css::uno::Sequence getUnoTunnelId();
 // XConnection
 virtual css::uno::Reference< css::sdbc::XStatement > SAL_CALL 
createStatement(  ) override;
 virtual css::uno::Reference< css::sdbc::XPreparedStatement > 
SAL_CALL prepareStatement( const OUString& sql ) override;
diff --git a/connectivity/source/drivers/firebird/Driver.cxx 
b/connectivity/source/drivers/firebird/Driver.cxx
index 1d452eb1c593..4a12953ae5f9 100644
--- a/connectivity/source/drivers/firebird/Driver.cxx
+++ b/connectivity/source/drivers/firebird/Driver.cxx
@@ -25,6 +25,7 @@
 #include 
 #include 
 
+#include 
 #include 
 #include 
 #include 
@@ -192,8 +193,9 @@ sal_Int32 SAL_CALL FirebirdDriver::getMinorVersion(  )
 uno::Reference< XTablesSupplier > SAL_CALL 
FirebirdDriver::getDataDefinitionByConnection(
 const uno::Reference< XConnection >& 
rConnection)
 {
-Connection* pConnection = static_cast< Connection* >(rConnection.get());
-return pConnection->createCatalog();
+if (Connection* pConnection = 
comphelper::getUnoTunnelImplementation(rConnection))
+return pConnection->createCatalog();
+return {};
 }
 
 uno::Reference< XTablesSupplier > SAL_CALL 
FirebirdDriver::getDataDefinitionByURL(


[Libreoffice-commits] core.git: Branch 'libreoffice-7-2' - connectivity/source

2021-09-13 Thread Mike Kaganski (via logerrit)
 connectivity/source/drivers/firebird/Connection.cxx |   12 +++-
 1 file changed, 7 insertions(+), 5 deletions(-)

New commits:
commit 9601ca71b485bba6221e1e0ab88accf3e89a325b
Author: Mike Kaganski 
AuthorDate: Fri Sep 10 18:15:48 2021 +0200
Commit: Xisco Fauli 
CommitDate: Mon Sep 13 12:34:19 2021 +0200

tdf#115547: Fix DB path handling

1. The code used wrong procedure to convert file URLs to local paths.
It assumed that it's enough to just strip the leading 'file://', which
is only sometimes true on Unix-like systems; on Windows, this converts
a valid 'file:///C:/path/file.ext' to '/C:/path/file.ext', where the
leading slash is then treated as a network path, resulting in errors.

2. It is incorrect to assume the same length for UTF-16 and UTF-8
encoded URLs coming from untrusted source (like user file). It may
contain non-ASCII characters (be an IRL), and then the assumption
would fail.

Change-Id: Ie2ea6c8cb9a690975db956fa025bf926a8010984
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121885
Reviewed-by: Lionel Mamane 
Tested-by: Jenkins
(cherry picked from commit 51269c4d28c04ebd2c0047772b7373e0bebec219)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121983
Reviewed-by: Xisco Fauli 

diff --git a/connectivity/source/drivers/firebird/Connection.cxx 
b/connectivity/source/drivers/firebird/Connection.cxx
index 5c5d03579c1e..04f8d0a8185c 100644
--- a/connectivity/source/drivers/firebird/Connection.cxx
+++ b/connectivity/source/drivers/firebird/Connection.cxx
@@ -49,6 +49,7 @@
 #include 
 #include 
 
+#include 
 #include 
 #include 
 
@@ -208,7 +209,7 @@ void Connection::construct(const OUString& url, const 
Sequence< PropertyValue >&
 if (!xFileAccess->exists(m_sFirebirdURL))
 bIsNewDatabase = true;
 
-m_sFirebirdURL = 
m_sFirebirdURL.copy(OUString("file://").getLength());
+osl::FileBase::getSystemPathFromFileURL(m_sFirebirdURL, 
m_sFirebirdURL);
 }
 }
 
@@ -263,11 +264,12 @@ void Connection::construct(const OUString& url, const 
Sequence< PropertyValue >&
 
 ISC_STATUS_ARRAY status;/* status vector */
 ISC_STATUS aErr;
+const OString sFirebirdURL = OUStringToOString(m_sFirebirdURL, 
RTL_TEXTENCODING_UTF8);
 if (bIsNewDatabase)
 {
 aErr = isc_create_database(status,
-   m_sFirebirdURL.getLength(),
-   
OUStringToOString(m_sFirebirdURL,RTL_TEXTENCODING_UTF8).getStr(),
+   sFirebirdURL.getLength(),
+   sFirebirdURL.getStr(),
_aDBHandle,
dpbBuffer.size(),
dpbBuffer.c_str(),
@@ -285,8 +287,8 @@ void Connection::construct(const OUString& url, const 
Sequence< PropertyValue >&
 }
 
 aErr = isc_attach_database(status,
-   m_sFirebirdURL.getLength(),
-   OUStringToOString(m_sFirebirdURL, 
RTL_TEXTENCODING_UTF8).getStr(),
+   sFirebirdURL.getLength(),
+   sFirebirdURL.getStr(),
_aDBHandle,
dpbBuffer.size(),
dpbBuffer.c_str());


[Libreoffice-commits] core.git: Branch 'libreoffice-7-2' - connectivity/source

2021-09-10 Thread Mike Kaganski (via logerrit)
 connectivity/source/drivers/firebird/Blob.cxx |3 +++
 1 file changed, 3 insertions(+)

New commits:
commit c3cdc29900574fefe4dc8b90e2941f2d3371d89c
Author: Mike Kaganski 
AuthorDate: Fri Sep 10 00:49:49 2021 +0200
Commit: Xisco Fauli 
CommitDate: Fri Sep 10 09:48:23 2021 +0200

tdf#120129: don't forget to update buffer size to actual length

Otherwise extra bytes get written to the resulting string from the
too long buffer.

Change-Id: Iccde16b8002f214df6f86f484f288ec464c6b674
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121872
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 
(cherry picked from commit 541ddf4580cac8c3f9590be26a487f5fc8e2553c)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121874
Reviewed-by: Xisco Fauli 

diff --git a/connectivity/source/drivers/firebird/Blob.cxx 
b/connectivity/source/drivers/firebird/Blob.cxx
index d254ba49431a..edcc0d233989 100644
--- a/connectivity/source/drivers/firebird/Blob.cxx
+++ b/connectivity/source/drivers/firebird/Blob.cxx
@@ -144,6 +144,9 @@ bool Blob::readOneSegment(uno::Sequence< sal_Int8 >& 
rDataOut)
 OUString sError(StatusVectorToString(m_statusVector, 
u"isc_get_segment"));
 throw IOException(sError, *this);
 }
+
+if (rDataOut.getLength() > nActualSize)
+rDataOut.realloc(nActualSize);
 m_nBlobPosition += nActualSize;
 return aRet == isc_segstr_eof;  // last segment read
 }


[Libreoffice-commits] core.git: Branch 'libreoffice-7-2' - connectivity/source

2021-09-02 Thread Mike Kaganski (via logerrit)
 connectivity/source/drivers/firebird/ResultSet.cxx |5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

New commits:
commit 1266d8bea7044b14177feb62241d96508363a2f9
Author: Mike Kaganski 
AuthorDate: Wed Sep 1 17:41:05 2021 +0200
Commit: Michael Stahl 
CommitDate: Thu Sep 2 17:04:55 2021 +0200

tdf#144230: sanitize string length embedded in SQL_VARYING data

It is unclear why the length may be wrong; but at least be safe to
avoid buffer overruns.

Wrt the validity of sqllen here: see SQLDAMetadata::scatterData in
firebird's src/yvalve/why.cpp.

Change-Id: Icc24c1cc0db66c20732188ab0621cde53c1ba5c2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121458
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 
(cherry picked from commit 2e5dad443a30055d93dbcb3bf9cac906e80b2e25)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121462
Reviewed-by: Michael Stahl 

diff --git a/connectivity/source/drivers/firebird/ResultSet.cxx 
b/connectivity/source/drivers/firebird/ResultSet.cxx
index 0e0361a7bbd8..17e87cf8a55d 100644
--- a/connectivity/source/drivers/firebird/ResultSet.cxx
+++ b/connectivity/source/drivers/firebird/ResultSet.cxx
@@ -579,10 +579,11 @@ OUString OResultSet::retrieveValue(const sal_Int32 
nColumnIndex, const ISC_SHORT
 else if (aSqlType == SQL_VARYING)
 {
 // First 2 bytes are a short containing the length of the string
-// No idea if sqllen is still valid here?
+// Under unclear conditions, it may be wrong and greater than sqllen.
 sal_uInt16 aLength = 
*reinterpret_cast(m_pSqlda->sqlvar[nColumnIndex-1].sqldata);
+// Use greater signed type sal_Int32 to get the minimum of two 16-bit 
values
 return OUString(m_pSqlda->sqlvar[nColumnIndex-1].sqldata + 2,
-aLength,
+std::min(aLength, 
m_pSqlda->sqlvar[nColumnIndex-1].sqllen),
 RTL_TEXTENCODING_UTF8);
 }
 else if ((aSqlType == SQL_SHORT || aSqlType == SQL_LONG ||


[Libreoffice-commits] core.git: Branch 'libreoffice-7-2' - connectivity/source

2021-08-16 Thread Julien Nabet (via logerrit)
 connectivity/source/drivers/mysqlc/mysqlc_general.cxx |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

New commits:
commit 5b6c96049d32475a249b0df184955aaa2747
Author: Julien Nabet 
AuthorDate: Mon Aug 16 12:48:14 2021 +0200
Commit: Julien Nabet 
CommitDate: Mon Aug 16 17:53:58 2021 +0200

Related tdf#143895: Mysql MEDIUMINT is DataType::INTEGER not 
DataType::SMALLINT

Change-Id: I324b18cc164cb2f38b7b8411c557c6c208e8d69d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120536
Reviewed-by: Lionel Mamane 
Tested-by: Jenkins
(cherry picked from commit 997ff7166ceca0a5af80297a0e789af2ff0c6617)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120447

diff --git a/connectivity/source/drivers/mysqlc/mysqlc_general.cxx 
b/connectivity/source/drivers/mysqlc/mysqlc_general.cxx
index 7ed11fe3ff13..878efdc3be24 100644
--- a/connectivity/source/drivers/mysqlc/mysqlc_general.cxx
+++ b/connectivity/source/drivers/mysqlc/mysqlc_general.cxx
@@ -193,11 +193,11 @@ sal_Int32 mysqlStrToOOOType(const OUString& sType)
 // TODO other types.
 if (sType.equalsIgnoreAsciiCase("tiny") || 
sType.equalsIgnoreAsciiCase("tinyint"))
 return css::sdbc::DataType::TINYINT;
-if (sType.equalsIgnoreAsciiCase("smallint") || 
sType.equalsIgnoreAsciiCase("mediumint"))
+if (sType.equalsIgnoreAsciiCase("smallint"))
 return css::sdbc::DataType::SMALLINT;
 if (sType.equalsIgnoreAsciiCase("longtext"))
 return css::sdbc::DataType::LONGVARCHAR;
-if (sType.equalsIgnoreAsciiCase("int"))
+if (sType.equalsIgnoreAsciiCase("int") || 
sType.equalsIgnoreAsciiCase("mediumint"))
 return css::sdbc::DataType::INTEGER;
 if (sType.equalsIgnoreAsciiCase("varchar") || 
sType.equalsIgnoreAsciiCase("set")
 || sType.equalsIgnoreAsciiCase("enum"))