tdf#138691: avoid buffer overflow
Change-Id: Ib5eaf6c658e1185c1e3eec7ce34f0ce54d6ce771
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129441
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
diff --git a/connectivity/source/drivers/firebird/PreparedStatement.cxx b/connectivity/source/drivers/firebird/PreparedStatement.cxx
index c665581..9225c3b 100644
--- a/connectivity/source/drivers/firebird/PreparedStatement.cxx
+++ b/connectivity/source/drivers/firebird/PreparedStatement.cxx
@@ -923,9 +923,12 @@ void SAL_CALL OPreparedStatement::setBytes(sal_Int32 nParameterIndex,
}
else if( dType == SQL_TEXT )
{
if (pVar->sqllen < xBytes.getLength())
dbtools::throwSQLException("Data too big for this field",
dbtools::StandardSQLState::INVALID_SQL_DATA_TYPE, *this);
setParameterNull(nParameterIndex, false);
memcpy(pVar->sqldata, xBytes.getConstArray(), xBytes.getLength() );
// Fill remainder with spaces
// Fill remainder with zeroes
memset(pVar->sqldata + xBytes.getLength(), 0, pVar->sqllen - xBytes.getLength());
}
else