diff options
Diffstat (limited to 'connectivity/source/drivers')
14 files changed, 29 insertions, 16 deletions
diff --git a/connectivity/source/drivers/file/FPreparedStatement.cxx b/connectivity/source/drivers/file/FPreparedStatement.cxx index 2ae516800b06..f2a8571b61e5 100644 --- a/connectivity/source/drivers/file/FPreparedStatement.cxx +++ b/connectivity/source/drivers/file/FPreparedStatement.cxx @@ -18,6 +18,7 @@ */ +#include <o3tl/safeint.hxx> #include <osl/diagnose.h> #include <file/FPreparedStatement.hxx> #include <com/sun/star/sdbc/DataType.hpp> @@ -392,7 +393,7 @@ void SAL_CALL OPreparedStatement::release() noexcept void OPreparedStatement::checkAndResizeParameters(sal_Int32 parameterIndex) { ::connectivity::checkDisposed(OStatement_BASE::rBHelper.bDisposed); - if ( m_aAssignValues.is() && (parameterIndex < 1 || parameterIndex >= static_cast<sal_Int32>(m_aParameterIndexes.size())) ) + if ( m_aAssignValues.is() && (parameterIndex < 1 || o3tl::make_unsigned(parameterIndex) >= m_aParameterIndexes.size()) ) throwInvalidIndexException(*this); else if ( static_cast<sal_Int32>(m_aParameterRow->size()) <= parameterIndex ) { diff --git a/connectivity/source/drivers/file/FResultSet.cxx b/connectivity/source/drivers/file/FResultSet.cxx index 43ad38739d5b..4d0e256b931e 100644 --- a/connectivity/source/drivers/file/FResultSet.cxx +++ b/connectivity/source/drivers/file/FResultSet.cxx @@ -29,6 +29,7 @@ #include <cppuhelper/typeprovider.hxx> #include <connectivity/dbtools.hxx> #include <cppuhelper/propshlp.hxx> +#include <o3tl/safeint.hxx> #include <sal/log.hxx> #include <iterator> #include <com/sun/star/sdbc/ResultSetType.hpp> @@ -921,7 +922,7 @@ bool OResultSet::Move(IResultSetHelper::Movement eCursorPosition, sal_Int32 nOff // The FileCursor is outside of the valid range, if: // a.) m_nRowPos < 1 // b.) a KeySet exists and m_nRowPos > m_pFileSet->size() - if (m_nRowPos < 0 || (m_pFileSet->isFrozen() && eCursorPosition != IResultSetHelper::BOOKMARK && m_nRowPos >= static_cast<sal_Int32>(m_pFileSet->size()) )) // && m_pFileSet->IsFrozen() + if (m_nRowPos < 0 || (m_pFileSet->isFrozen() && eCursorPosition != IResultSetHelper::BOOKMARK && o3tl::make_unsigned(m_nRowPos) >= m_pFileSet->size() )) // && m_pFileSet->IsFrozen() { goto Error; } diff --git a/connectivity/source/drivers/file/FResultSetMetaData.cxx b/connectivity/source/drivers/file/FResultSetMetaData.cxx index f68a06532bb7..fdc944043d2a 100644 --- a/connectivity/source/drivers/file/FResultSetMetaData.cxx +++ b/connectivity/source/drivers/file/FResultSetMetaData.cxx @@ -22,6 +22,7 @@ #include <comphelper/extract.hxx> #include <connectivity/dbexception.hxx> #include <comphelper/types.hxx> +#include <o3tl/safeint.hxx> using namespace ::comphelper; @@ -51,7 +52,7 @@ OResultSetMetaData::~OResultSetMetaData() void OResultSetMetaData::checkColumnIndex(sal_Int32 column) { - if(column <= 0 || column > static_cast<sal_Int32>(m_xColumns->size())) + if(column <= 0 || o3tl::make_unsigned(column) > m_xColumns->size()) throwInvalidIndexException(*this); } diff --git a/connectivity/source/drivers/mysqlc/mysqlc_preparedstatement.cxx b/connectivity/source/drivers/mysqlc/mysqlc_preparedstatement.cxx index a50b14bbb3b4..6ec6a89f175c 100644 --- a/connectivity/source/drivers/mysqlc/mysqlc_preparedstatement.cxx +++ b/connectivity/source/drivers/mysqlc/mysqlc_preparedstatement.cxx @@ -23,6 +23,7 @@ #include "mysqlc_propertyids.hxx" #include "mysqlc_resultsetmetadata.hxx" +#include <o3tl/safeint.hxx> #include <sal/log.hxx> #include <com/sun/star/sdbc/DataType.hpp> @@ -569,7 +570,7 @@ void OPreparedStatement::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, con void OPreparedStatement::checkParameterIndex(sal_Int32 column) { - if (column < 1 || column > static_cast<sal_Int32>(m_paramCount)) + if (column < 1 || o3tl::make_unsigned(column) > m_paramCount) { throw SQLException("Parameter index out of range", *this, OUString(), 1, Any()); } diff --git a/connectivity/source/drivers/mysqlc/mysqlc_resultset.cxx b/connectivity/source/drivers/mysqlc/mysqlc_resultset.cxx index 7410ad38e6fc..f1c23ca482ad 100644 --- a/connectivity/source/drivers/mysqlc/mysqlc_resultset.cxx +++ b/connectivity/source/drivers/mysqlc/mysqlc_resultset.cxx @@ -1095,7 +1095,7 @@ css::uno::Reference<css::beans::XPropertySetInfo> SAL_CALL OResultSet::getProper void OResultSet::checkColumnIndex(sal_Int32 index) { - if (index < 1 || index > static_cast<int>(m_aFields.size())) + if (index < 1 || o3tl::make_unsigned(index) > m_aFields.size()) { /* static object for efficiency or thread safety is a problem ? */ throw SQLException("index out of range", *this, OUString(), 1, Any()); diff --git a/connectivity/source/drivers/mysqlc/mysqlc_resultsetmetadata.cxx b/connectivity/source/drivers/mysqlc/mysqlc_resultsetmetadata.cxx index 6fc531fa943d..84cd6be2a3a7 100644 --- a/connectivity/source/drivers/mysqlc/mysqlc_resultsetmetadata.cxx +++ b/connectivity/source/drivers/mysqlc/mysqlc_resultsetmetadata.cxx @@ -22,6 +22,7 @@ #include <com/sun/star/sdbc/XRow.hpp> #include <com/sun/star/sdbcx/XColumnsSupplier.hpp> +#include <o3tl/safeint.hxx> using namespace connectivity::mysqlc; using namespace com::sun::star::uno; @@ -199,7 +200,7 @@ sal_Bool SAL_CALL OResultSetMetaData::isWritable(sal_Int32 column) void OResultSetMetaData::checkColumnIndex(sal_Int32 columnIndex) { auto nColCount = m_fields.size(); - if (columnIndex < 1 || columnIndex > static_cast<sal_Int32>(nColCount)) + if (columnIndex < 1 || o3tl::make_unsigned(columnIndex) > nColCount) { OUString str = "Column index out of range (expected 1 to " + OUString::number(sal_Int32(nColCount)) + ", got " diff --git a/connectivity/source/drivers/postgresql/pq_preparedstatement.cxx b/connectivity/source/drivers/postgresql/pq_preparedstatement.cxx index d7a73289b077..2f31b4226c08 100644 --- a/connectivity/source/drivers/postgresql/pq_preparedstatement.cxx +++ b/connectivity/source/drivers/postgresql/pq_preparedstatement.cxx @@ -40,6 +40,7 @@ #include "pq_statics.hxx" #include "pq_statement.hxx" +#include <o3tl/safeint.hxx> #include <rtl/strbuf.hxx> #include <rtl/ustrbuf.hxx> @@ -197,7 +198,7 @@ PreparedStatement::~PreparedStatement() void PreparedStatement::checkColumnIndex( sal_Int32 parameterIndex ) { - if( parameterIndex < 1 || parameterIndex > static_cast<sal_Int32>(m_vars.size()) ) + if( parameterIndex < 1 || o3tl::make_unsigned(parameterIndex) > m_vars.size() ) { throw SQLException( "pq_preparedstatement: parameter index out of range (expected 1 to " diff --git a/connectivity/source/drivers/postgresql/pq_xcolumns.cxx b/connectivity/source/drivers/postgresql/pq_xcolumns.cxx index 6caf1decc6c6..f1d3c0a53e88 100644 --- a/connectivity/source/drivers/postgresql/pq_xcolumns.cxx +++ b/connectivity/source/drivers/postgresql/pq_xcolumns.cxx @@ -38,6 +38,7 @@ #include <string_view> +#include <o3tl/safeint.hxx> #include <o3tl/string_view.hxx> #include <rtl/ref.hxx> #include <rtl/ustrbuf.hxx> @@ -492,7 +493,7 @@ void Columns::appendByDescriptor( void Columns::dropByIndex( sal_Int32 index ) { osl::MutexGuard guard( m_xMutex->GetMutex() ); - if( index < 0 || index >= static_cast<sal_Int32>(m_values.size()) ) + if( index < 0 || o3tl::make_unsigned(index) >= m_values.size() ) { throw css::lang::IndexOutOfBoundsException( "COLUMNS: Index out of range (allowed 0 to " diff --git a/connectivity/source/drivers/postgresql/pq_xcontainer.cxx b/connectivity/source/drivers/postgresql/pq_xcontainer.cxx index 993045d3a44d..fea88b682cdb 100644 --- a/connectivity/source/drivers/postgresql/pq_xcontainer.cxx +++ b/connectivity/source/drivers/postgresql/pq_xcontainer.cxx @@ -37,6 +37,7 @@ #include <com/sun/star/container/ElementExistException.hpp> #include <com/sun/star/lang/IndexOutOfBoundsException.hpp> #include <cppuhelper/implbase.hxx> +#include <o3tl/safeint.hxx> #include "pq_xcontainer.hxx" #include "pq_statics.hxx" @@ -155,7 +156,7 @@ Any Container::getByName( const OUString& aName ) "Element " + aName + " unknown in " + m_type + "-Container", *this ); } - OSL_ASSERT( ii->second >= 0 && ii->second < static_cast<int>(m_values.size()) ); + OSL_ASSERT( ii->second >= 0 && o3tl::make_unsigned(ii->second) < m_values.size() ); return m_values[ ii->second ]; } @@ -188,7 +189,7 @@ sal_Bool Container::hasElements( ) Any Container::getByIndex( sal_Int32 Index ) { - if( Index < 0 || Index >= static_cast<sal_Int32>(m_values.size()) ) + if( Index < 0 || o3tl::make_unsigned(Index) >= m_values.size() ) { throw IndexOutOfBoundsException( "Index " + OUString::number( Index ) @@ -298,7 +299,7 @@ void Container::dropByName( const OUString& elementName ) void Container::dropByIndex( sal_Int32 index ) { osl::MutexGuard guard( m_xMutex->GetMutex() ); - if( index < 0 || index >=static_cast<sal_Int32>(m_values.size()) ) + if( index < 0 || o3tl::make_unsigned(index) >=m_values.size() ) { throw css::lang::IndexOutOfBoundsException( "Index out of range (allowed 0 to " diff --git a/connectivity/source/drivers/postgresql/pq_xindexes.cxx b/connectivity/source/drivers/postgresql/pq_xindexes.cxx index d027e15b9d3c..ef1e7116a1b0 100644 --- a/connectivity/source/drivers/postgresql/pq_xindexes.cxx +++ b/connectivity/source/drivers/postgresql/pq_xindexes.cxx @@ -43,6 +43,7 @@ #include <com/sun/star/sdbc/XRow.hpp> #include <com/sun/star/sdbc/XParameters.hpp> #include <cppuhelper/exc_hlp.hxx> +#include <o3tl/safeint.hxx> #include "pq_xindexes.hxx" #include "pq_xindex.hxx" @@ -234,7 +235,7 @@ void Indexes::dropByIndex( sal_Int32 index ) osl::MutexGuard guard( m_xMutex->GetMutex() ); - if( index < 0 || index >= static_cast<sal_Int32>(m_values.size()) ) + if( index < 0 || o3tl::make_unsigned(index) >= m_values.size() ) { throw css::lang::IndexOutOfBoundsException( "Indexes: Index out of range (allowed 0 to " diff --git a/connectivity/source/drivers/postgresql/pq_xkeys.cxx b/connectivity/source/drivers/postgresql/pq_xkeys.cxx index 0aeb32446abb..dced2bc9baa5 100644 --- a/connectivity/source/drivers/postgresql/pq_xkeys.cxx +++ b/connectivity/source/drivers/postgresql/pq_xkeys.cxx @@ -49,6 +49,7 @@ #include <com/sun/star/sdbc/KeyRule.hpp> #include <com/sun/star/sdbcx/KeyType.hpp> #include <cppuhelper/exc_hlp.hxx> +#include <o3tl/safeint.hxx> #include "pq_xkeys.hxx" #include "pq_xkey.hxx" @@ -226,7 +227,7 @@ void Keys::appendByDescriptor( void Keys::dropByIndex( sal_Int32 index ) { osl::MutexGuard guard( m_xMutex->GetMutex() ); - if( index < 0 || index >= static_cast<sal_Int32>(m_values.size()) ) + if( index < 0 || o3tl::make_unsigned(index) >= m_values.size() ) { throw css::lang::IndexOutOfBoundsException( "TABLES: Index out of range (allowed 0 to " + OUString::number(m_values.size() -1) diff --git a/connectivity/source/drivers/postgresql/pq_xtables.cxx b/connectivity/source/drivers/postgresql/pq_xtables.cxx index f1a089ff031a..423ec81f2166 100644 --- a/connectivity/source/drivers/postgresql/pq_xtables.cxx +++ b/connectivity/source/drivers/postgresql/pq_xtables.cxx @@ -43,6 +43,7 @@ #include <com/sun/star/sdbcx/Privilege.hpp> #include <com/sun/star/sdbc/DataType.hpp> #include <cppuhelper/exc_hlp.hxx> +#include <o3tl/safeint.hxx> #include "pq_xtables.hxx" #include "pq_xviews.hxx" @@ -310,7 +311,7 @@ void Tables::appendByDescriptor( void Tables::dropByIndex( sal_Int32 index ) { osl::MutexGuard guard( m_xMutex->GetMutex() ); - if( index < 0 || index >= static_cast<sal_Int32>(m_values.size()) ) + if( index < 0 || o3tl::make_unsigned(index) >= m_values.size() ) { throw css::lang::IndexOutOfBoundsException( "TABLES: Index out of range (allowed 0 to " + OUString::number(m_values.size() -1) diff --git a/connectivity/source/drivers/postgresql/pq_xusers.cxx b/connectivity/source/drivers/postgresql/pq_xusers.cxx index a12c86ed2375..08cdf2d1c135 100644 --- a/connectivity/source/drivers/postgresql/pq_xusers.cxx +++ b/connectivity/source/drivers/postgresql/pq_xusers.cxx @@ -41,6 +41,7 @@ #include <com/sun/star/sdbc/SQLException.hpp> #include <com/sun/star/sdbc/XRow.hpp> #include <cppuhelper/exc_hlp.hxx> +#include <o3tl/safeint.hxx> #include "pq_xusers.hxx" #include "pq_xuser.hxx" @@ -151,7 +152,7 @@ void Users::dropByIndex( sal_Int32 index ) { osl::MutexGuard guard( m_xMutex->GetMutex() ); - if( index < 0 || index >= static_cast<sal_Int32>(m_values.size()) ) + if( index < 0 || o3tl::make_unsigned(index) >= m_values.size() ) { throw css::lang::IndexOutOfBoundsException( "USERS: Index out of range (allowed 0 to " diff --git a/connectivity/source/drivers/postgresql/pq_xviews.cxx b/connectivity/source/drivers/postgresql/pq_xviews.cxx index 3dfdfaa5fe64..1f5b6c4fa52c 100644 --- a/connectivity/source/drivers/postgresql/pq_xviews.cxx +++ b/connectivity/source/drivers/postgresql/pq_xviews.cxx @@ -41,6 +41,7 @@ #include <com/sun/star/sdbc/SQLException.hpp> #include <com/sun/star/sdbc/XRow.hpp> #include <cppuhelper/exc_hlp.hxx> +#include <o3tl/safeint.hxx> #include "pq_xviews.hxx" #include "pq_xview.hxx" @@ -175,7 +176,7 @@ void Views::dropByName( const OUString& elementName ) void Views::dropByIndex( sal_Int32 index ) { osl::MutexGuard guard( m_xMutex->GetMutex() ); - if( index < 0 || index >= static_cast<sal_Int32>(m_values.size()) ) + if( index < 0 || o3tl::make_unsigned(index) >= m_values.size() ) { throw css::lang::IndexOutOfBoundsException( "VIEWS: Index out of range (allowed 0 to " + OUString::number(m_values.size() -1) |