summaryrefslogtreecommitdiff
path: root/xmlsecurity
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2022-05-24 15:26:06 +0200
committerStephan Bergmann <sbergman@redhat.com>2022-05-24 16:50:03 +0200
commit5060c5015882b7109c54598c4ea858949beafc43 (patch)
treec8c153d73f6c6ebbe2dae768c1da72d28312efd4 /xmlsecurity
parenta86818c15a6b4773ddd012db37d55b5204163c24 (diff)
Use o3tl::make_unsigned in some places
...where a signed and an unsigned value are compared, and the signed value has just been proven to be non-negative here Change-Id: I20600d61a5d59d739bc1bee838c0038e4611aec2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134875 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'xmlsecurity')
-rw-r--r--xmlsecurity/source/gpg/XMLSecurityContext.cxx5
-rw-r--r--xmlsecurity/source/xmlsec/nss/xmlsecuritycontext_nssimpl.cxx5
2 files changed, 6 insertions, 4 deletions
diff --git a/xmlsecurity/source/gpg/XMLSecurityContext.cxx b/xmlsecurity/source/gpg/XMLSecurityContext.cxx
index 79746d31b637..1fb407113f7a 100644
--- a/xmlsecurity/source/gpg/XMLSecurityContext.cxx
+++ b/xmlsecurity/source/gpg/XMLSecurityContext.cxx
@@ -10,6 +10,7 @@
#include "XMLSecurityContext.hxx"
#include <cppuhelper/supportsservice.hxx>
+#include <o3tl/safeint.hxx>
using namespace css::uno;
using namespace css::lang;
@@ -40,7 +41,7 @@ sal_Int32 SAL_CALL XMLSecurityContextGpg::getSecurityEnvironmentNumber()
Reference<XSecurityEnvironment>
SAL_CALL XMLSecurityContextGpg::getSecurityEnvironmentByIndex(sal_Int32 index)
{
- if (index < 0 || index >= static_cast<sal_Int32>(m_vSecurityEnvironments.size()))
+ if (index < 0 || o3tl::make_unsigned(index) >= m_vSecurityEnvironments.size())
throw RuntimeException("Invalid index");
return m_vSecurityEnvironments[index];
@@ -49,7 +50,7 @@ Reference<XSecurityEnvironment>
Reference<XSecurityEnvironment> SAL_CALL XMLSecurityContextGpg::getSecurityEnvironment()
{
if (m_nDefaultEnvIndex < 0
- || m_nDefaultEnvIndex >= static_cast<sal_Int32>(m_vSecurityEnvironments.size()))
+ || o3tl::make_unsigned(m_nDefaultEnvIndex) >= m_vSecurityEnvironments.size())
throw RuntimeException("Invalid index");
return getSecurityEnvironmentByIndex(m_nDefaultEnvIndex);
diff --git a/xmlsecurity/source/xmlsec/nss/xmlsecuritycontext_nssimpl.cxx b/xmlsecurity/source/xmlsec/nss/xmlsecuritycontext_nssimpl.cxx
index 42d03f2dd81a..9ccf0ab982e6 100644
--- a/xmlsecurity/source/xmlsec/nss/xmlsecuritycontext_nssimpl.cxx
+++ b/xmlsecurity/source/xmlsec/nss/xmlsecuritycontext_nssimpl.cxx
@@ -23,6 +23,7 @@
#include <cppuhelper/supportsservice.hxx>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/xml/crypto/XXMLSecurityContext.hpp>
+#include <o3tl/safeint.hxx>
namespace com::sun::star::uno { class XComponentContext; }
@@ -98,7 +99,7 @@ sal_Int32 SAL_CALL XMLSecurityContext_NssImpl::getSecurityEnvironmentNumber( )
uno::Reference< xml::crypto::XSecurityEnvironment > SAL_CALL
XMLSecurityContext_NssImpl::getSecurityEnvironmentByIndex( sal_Int32 index )
{
- if (index < 0 || index >= static_cast<sal_Int32>(m_vSecurityEnvironments.size()))
+ if (index < 0 || o3tl::make_unsigned(index) >= m_vSecurityEnvironments.size())
throw uno::RuntimeException();
uno::Reference< xml::crypto::XSecurityEnvironment > xSecurityEnvironment = m_vSecurityEnvironments[index];
@@ -108,7 +109,7 @@ uno::Reference< xml::crypto::XSecurityEnvironment > SAL_CALL
uno::Reference< xml::crypto::XSecurityEnvironment > SAL_CALL
XMLSecurityContext_NssImpl::getSecurityEnvironment( )
{
- if (m_nDefaultEnvIndex < 0 || m_nDefaultEnvIndex >= static_cast<sal_Int32>(m_vSecurityEnvironments.size()))
+ if (m_nDefaultEnvIndex < 0 || o3tl::make_unsigned(m_nDefaultEnvIndex) >= m_vSecurityEnvironments.size())
throw uno::RuntimeException();
return getSecurityEnvironmentByIndex(m_nDefaultEnvIndex);