diff options
author | Julien Nabet <serval2412@yahoo.fr> | 2020-11-17 21:30:42 +0100 |
---|---|---|
committer | Lionel Mamane <lionel@mamane.lu> | 2020-11-18 19:19:04 +0100 |
commit | 5c6340d06b4e58529f6122ecf3b26c6d4456226b (patch) | |
tree | 5e2f2fc0f9f445c4658c446583c00c1fe634361e /connectivity/source | |
parent | 041c811b563f0839181e5339a5b417efd3574ad2 (diff) |
Related tdf#121886: Firebird Datatype Image(BLOB) is not working properly
xBlob->length() returns sal_Int64 not sal_Int32
so deal with it in:
- OResultSet::getBytes
- ODatabaseMetaData::getColumns
and warn if blob is more than SAL_MAX_INT32
also rename xDescriptionBlob into xBlob
Change-Id: Ib79930c4c8fb00b1682c9a9530a3dee9b040e7ef
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106029
Tested-by: Jenkins
Reviewed-by: Lionel Mamane <lionel@mamane.lu>
Diffstat (limited to 'connectivity/source')
-rw-r--r-- | connectivity/source/drivers/firebird/DatabaseMetaData.cxx | 22 | ||||
-rw-r--r-- | connectivity/source/drivers/firebird/ResultSet.cxx | 9 |
2 files changed, 23 insertions, 8 deletions
diff --git a/connectivity/source/drivers/firebird/DatabaseMetaData.cxx b/connectivity/source/drivers/firebird/DatabaseMetaData.cxx index 28880a378b0a..9aabd39cb52a 100644 --- a/connectivity/source/drivers/firebird/DatabaseMetaData.cxx +++ b/connectivity/source/drivers/firebird/DatabaseMetaData.cxx @@ -1246,13 +1246,23 @@ uno::Reference< XResultSet > SAL_CALL ODatabaseMetaData::getColumns( // 12. Comments -- may be omitted { OUString aDescription; - uno::Reference< XBlob > xDescriptionBlob = xRow->getBlob(3); - if (xDescriptionBlob.is()) + uno::Reference< XBlob > xBlob = xRow->getBlob(3); + if (xBlob.is()) { - sal_Int32 aBlobLength = static_cast<sal_Int32>(xDescriptionBlob->length()); - aDescription = OUString(reinterpret_cast<char*>(xDescriptionBlob->getBytes(1, aBlobLength).getArray()), - aBlobLength, - RTL_TEXTENCODING_UTF8); + const sal_Int64 aBlobLength = xBlob->length(); + if (aBlobLength > SAL_MAX_INT32) + { + SAL_WARN("connectivity.firebird", "getBytes can't return " << aBlobLength << " bytes but only max " << SAL_MAX_INT32); + aDescription = OUString(reinterpret_cast<char*>(xBlob->getBytes(1, SAL_MAX_INT32).getArray()), + SAL_MAX_INT32, + RTL_TEXTENCODING_UTF8); + } + else + { + aDescription = OUString(reinterpret_cast<char*>(xBlob->getBytes(1, static_cast<sal_Int32>(aBlobLength)).getArray()), + aBlobLength, + RTL_TEXTENCODING_UTF8); + } } aCurrentRow[12] = new ORowSetValueDecorator(aDescription); } diff --git a/connectivity/source/drivers/firebird/ResultSet.cxx b/connectivity/source/drivers/firebird/ResultSet.cxx index e1b5107ae42c..7ae77c607e0d 100644 --- a/connectivity/source/drivers/firebird/ResultSet.cxx +++ b/connectivity/source/drivers/firebird/ResultSet.cxx @@ -674,8 +674,13 @@ Sequence< sal_Int8 > SAL_CALL OResultSet::getBytes(sal_Int32 nColumnIndex) Reference< XBlob> xBlob = getBlob(nColumnIndex); if (xBlob.is()) { - sal_Int32 aBlobLength = static_cast<sal_Int32>(xBlob->length()); - return xBlob->getBytes(1, aBlobLength); + const sal_Int64 aBlobLength = xBlob->length(); + if (aBlobLength > SAL_MAX_INT32) + { + SAL_WARN("connectivity.firebird", "getBytes can't return " << aBlobLength << " bytes but only max " << SAL_MAX_INT32); + return xBlob->getBytes(1, SAL_MAX_INT32); + } + return xBlob->getBytes(1, static_cast<sal_Int32>(aBlobLength)); } else return Sequence< sal_Int8 >(); |