connectivity/source/drivers/firebird/DatabaseMetaData.cxx | 22 ++++++++++---- connectivity/source/drivers/firebird/ResultSet.cxx | 9 ++++- 2 files changed, 23 insertions(+), 8 deletions(-)
New commits: commit 5c6340d06b4e58529f6122ecf3b26c6d4456226b Author: Julien Nabet <[email protected]> AuthorDate: Tue Nov 17 21:30:42 2020 +0100 Commit: Lionel Mamane <[email protected]> CommitDate: Wed Nov 18 19:19:04 2020 +0100 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 <[email protected]> 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 >(); _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
