You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openoffice.apache.org by ms...@apache.org on 2021/09/23 11:19:39 UTC

[openoffice] branch AOO42X updated (b7425b8 -> e131dae)

This is an automated email from the ASF dual-hosted git repository.

mseidel pushed a change to branch AOO42X
in repository https://gitbox.apache.org/repos/asf/openoffice.git.


    from b7425b8  Fix missing shadow
     new 716d67a  Avoid setting fields multiple times
     new 0b813b1  Check on certificates must be insensitive to whitespace
     new e131dae  Whoops: removed temporary line (cherry picked from commit bdb20b2a644caf8c6da0dc8ab59650662275bb96)

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 main/xmlsecurity/source/helper/xsecctl.hxx    | 45 +++++++++++++++++
 main/xmlsecurity/source/helper/xsecverify.cxx | 71 +++++++++++++++++++++++++--
 2 files changed, 112 insertions(+), 4 deletions(-)

[openoffice] 03/03: Whoops: removed temporary line (cherry picked from commit bdb20b2a644caf8c6da0dc8ab59650662275bb96)

Posted by ms...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

mseidel pushed a commit to branch AOO42X
in repository https://gitbox.apache.org/repos/asf/openoffice.git

commit e131dae6723b2363d9e4012a482a4f5cf7ecfc09
Author: Arrigo Marchiori <ar...@yahoo.it>
AuthorDate: Mon Sep 20 06:57:43 2021 +0200

    Whoops: removed temporary line
    (cherry picked from commit bdb20b2a644caf8c6da0dc8ab59650662275bb96)
---
 main/xmlsecurity/source/helper/xsecverify.cxx | 1 -
 1 file changed, 1 deletion(-)

diff --git a/main/xmlsecurity/source/helper/xsecverify.cxx b/main/xmlsecurity/source/helper/xsecverify.cxx
index 718c1b8..101b944 100644
--- a/main/xmlsecurity/source/helper/xsecverify.cxx
+++ b/main/xmlsecurity/source/helper/xsecverify.cxx
@@ -219,7 +219,6 @@ void XSecController::setX509SerialNumber( rtl::OUString& ouX509SerialNumber )
 void XSecController::setX509Certificate( rtl::OUString& ouX509Certificate )
 {
 	InternalSignatureInformation &isi = m_vInternalSignatureInformations[m_vInternalSignatureInformations.size()-1];
-    setIfEmpty(isi.signatureInfor.ouX509Certificate, ouX509Certificate);
     if (isi.signatureInfor.ouX509Certificate.getLength()) {
         // We allow to re-set the same certificate only.
         // Whitespace may change.

[openoffice] 01/03: Avoid setting fields multiple times

Posted by ms...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

mseidel pushed a commit to branch AOO42X
in repository https://gitbox.apache.org/repos/asf/openoffice.git

commit 716d67a2df5b1ae2fa40cca3695ae3bc72ab0a41
Author: Arrigo Marchiori <ar...@yahoo.it>
AuthorDate: Sat Sep 4 18:01:41 2021 +0200

    Avoid setting fields multiple times
    
    (cherry picked from commit 55779ad04e2b81bf5880b90ea6492ca3adecfddb)
---
 main/xmlsecurity/source/helper/xsecctl.hxx    | 45 +++++++++++++++++++++++++++
 main/xmlsecurity/source/helper/xsecverify.cxx | 16 +++++++---
 2 files changed, 57 insertions(+), 4 deletions(-)

diff --git a/main/xmlsecurity/source/helper/xsecctl.hxx b/main/xmlsecurity/source/helper/xsecctl.hxx
index 30ba2aa..1eb46b8 100644
--- a/main/xmlsecurity/source/helper/xsecctl.hxx
+++ b/main/xmlsecurity/source/helper/xsecctl.hxx
@@ -405,12 +405,57 @@ private:
 		bool isBinary );
 	void setReferenceCount() const;
 	
+    /** Set a variable unless already set with a different value.
+     *
+     * @param variable variable to set.
+     * @param value value to set.
+     *
+     * @throw com::sun::star::uno::RuntimeException if the variable is not
+     * empty and its contents are different from value.
+     */
+    void setIfEmpty(rtl::OUString &variable, const rtl::OUString &value);
+    /** Set the X509 issuer name
+     *
+     * @param ouX509IssuerName value to set.
+     *
+     * This method should be called not more than once.
+     *
+     * @throw com::sun:star::uno::RuntimeException if a tampering is
+     * detected.
+     */
 	void setX509IssuerName( rtl::OUString& ouX509IssuerName );
+    /** Set the X509 serial number.
+     *
+     * @param ouX509SerialNumber value to set.
+     *
+     * This method should be called not more than once.
+     *
+     * @throw com::sun:star::uno::RuntimeException if a tampering is
+     * detected.
+     */
 	void setX509SerialNumber( rtl::OUString& ouX509SerialNumber );
+    /** Set the X509 certificate.
+     *
+     * @param ouX509Certificate value to set.
+     *
+     * This method should be called not more than once.
+     *
+     * @throw com::sun:star::uno::RuntimeException if a tampering is
+     * detected.
+     */
 	void setX509Certificate( rtl::OUString& ouX509Certificate );
 	void setSignatureValue( rtl::OUString& ouSignatureValue );
 	void setDigestValue( rtl::OUString& ouDigestValue );
 	
+    /** Set the signature date.
+     *
+     * @param ouDate value to set.
+     *
+     * This method should be called not more than once.
+     *
+     * @throw com::sun:star::uno::RuntimeException if a tampering is
+     * detected.
+     */
 	void setDate( rtl::OUString& ouDate );
 
 	void setId( rtl::OUString& ouId );
diff --git a/main/xmlsecurity/source/helper/xsecverify.cxx b/main/xmlsecurity/source/helper/xsecverify.cxx
index 7e556a1..4cc3870 100644
--- a/main/xmlsecurity/source/helper/xsecverify.cxx
+++ b/main/xmlsecurity/source/helper/xsecverify.cxx
@@ -177,22 +177,30 @@ void XSecController::setReferenceCount() const
 	}
 }
 
+void XSecController::setIfEmpty(rtl::OUString &variable, const rtl::OUString &value) {
+    if (variable.getLength() == 0) {
+        variable = value;
+    } else if (variable != value) {
+        throw cssu::RuntimeException(rtl::OUString::createFromAscii("Value already set. Tampering?"), *this);
+    }
+}
+
 void XSecController::setX509IssuerName( rtl::OUString& ouX509IssuerName )
 {
 	InternalSignatureInformation &isi = m_vInternalSignatureInformations[m_vInternalSignatureInformations.size()-1];
-	isi.signatureInfor.ouX509IssuerName = ouX509IssuerName;
+	setIfEmpty(isi.signatureInfor.ouX509IssuerName, ouX509IssuerName);
 }
 
 void XSecController::setX509SerialNumber( rtl::OUString& ouX509SerialNumber )
 {
 	InternalSignatureInformation &isi = m_vInternalSignatureInformations[m_vInternalSignatureInformations.size()-1];
-	isi.signatureInfor.ouX509SerialNumber = ouX509SerialNumber;
+	setIfEmpty(isi.signatureInfor.ouX509SerialNumber, ouX509SerialNumber);
 }
 
 void XSecController::setX509Certificate( rtl::OUString& ouX509Certificate )
 {
 	InternalSignatureInformation &isi = m_vInternalSignatureInformations[m_vInternalSignatureInformations.size()-1];
-	isi.signatureInfor.ouX509Certificate = ouX509Certificate;
+	setIfEmpty(isi.signatureInfor.ouX509Certificate, ouX509Certificate);
 }
 
 void XSecController::setSignatureValue( rtl::OUString& ouSignatureValue )
@@ -212,7 +220,7 @@ void XSecController::setDate( rtl::OUString& ouDate )
 {
 	InternalSignatureInformation &isi = m_vInternalSignatureInformations[m_vInternalSignatureInformations.size()-1];
 	convertDateTime( isi.signatureInfor.stDateTime, ouDate );
-	isi.signatureInfor.ouDateTime = ouDate;
+	setIfEmpty(isi.signatureInfor.ouDateTime, ouDate);
 }
 
 /*

[openoffice] 02/03: Check on certificates must be insensitive to whitespace

Posted by ms...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

mseidel pushed a commit to branch AOO42X
in repository https://gitbox.apache.org/repos/asf/openoffice.git

commit 0b813b10e184ff87eb5992d37c25bf2c8ad01f34
Author: Arrigo Marchiori <ar...@yahoo.it>
AuthorDate: Sun Sep 19 22:14:38 2021 +0200

    Check on certificates must be insensitive to whitespace
    
    TODO: have rtl_ImplIsWhitespace exported instead of copying it here
    (cherry picked from commit 202a5bb28b8553c75fb67284b7481a96b8e91cf2)
---
 main/xmlsecurity/source/helper/xsecverify.cxx | 58 ++++++++++++++++++++++++++-
 1 file changed, 57 insertions(+), 1 deletion(-)

diff --git a/main/xmlsecurity/source/helper/xsecverify.cxx b/main/xmlsecurity/source/helper/xsecverify.cxx
index 4cc3870..718c1b8 100644
--- a/main/xmlsecurity/source/helper/xsecverify.cxx
+++ b/main/xmlsecurity/source/helper/xsecverify.cxx
@@ -35,6 +35,25 @@
 #include <com/sun/star/xml/crypto/sax/XSignatureVerifyResultBroadcaster.hpp>
 #include <com/sun/star/xml/sax/SAXParseException.hpp>
 
+// FIXME: copied from main/sal/rtl/source/strimp.c
+static sal_Bool rtl_ImplIsWhitespace( sal_Unicode c )
+{
+	/* Space or Control character? */
+	if ( (c <= 32) && c )
+		return sal_True;
+
+	/* Only in the General Punctuation area Space or Control characters are included? */
+	if ( (c < 0x2000) || (c > 0x206F) )
+		return sal_False;
+
+	if ( ((c >= 0x2000) && (c <= 0x200B)) ||	/* All Spaces			*/
+		 (c == 0x2028) ||						/* LINE SEPARATOR		*/
+		 (c == 0x2029) )						/* PARAGRAPH SEPARATOR	*/
+		return sal_True;
+
+	return sal_False;
+}
+
 namespace cssu = com::sun::star::uno;
 namespace cssl = com::sun::star::lang;
 namespace cssxc = com::sun::star::xml::crypto;
@@ -200,7 +219,44 @@ void XSecController::setX509SerialNumber( rtl::OUString& ouX509SerialNumber )
 void XSecController::setX509Certificate( rtl::OUString& ouX509Certificate )
 {
 	InternalSignatureInformation &isi = m_vInternalSignatureInformations[m_vInternalSignatureInformations.size()-1];
-	setIfEmpty(isi.signatureInfor.ouX509Certificate, ouX509Certificate);
+    setIfEmpty(isi.signatureInfor.ouX509Certificate, ouX509Certificate);
+    if (isi.signatureInfor.ouX509Certificate.getLength()) {
+        // We allow to re-set the same certificate only.
+        // Whitespace may change.
+        const sal_Int32 l1 = isi.signatureInfor.ouX509Certificate.getLength();
+        const sal_Int32 l2 = ouX509Certificate.getLength();
+        const sal_Unicode *s1 = isi.signatureInfor.ouX509Certificate.getStr();
+        const sal_Unicode *s2 = ouX509Certificate.getStr();
+        sal_Int32 i1 = 0, i2 = 0;
+        while ((i1 < l1) && (i2 < l2)) {
+            const sal_Unicode &c1 = s1[i1];
+            const sal_Unicode &c2 = s2[i2];
+            if (rtl_ImplIsWhitespace(c1)) {
+                ++i1;
+                continue;
+            }
+            if (rtl_ImplIsWhitespace(c2)) {
+                ++i2;
+                continue;
+            }
+            if (c1 != c2) {
+                throw cssu::RuntimeException(rtl::OUString::createFromAscii("Value already set. Tampering?"), *this);
+            }
+            ++i1;
+            ++i2;
+        }
+        // We could still have whitespace at the end of both strings
+        while ((i1 < l1) && rtl_ImplIsWhitespace(s1[l1])) {
+            ++i1;
+        }
+        while ((i2 < l2) && rtl_ImplIsWhitespace(s2[l2])) {
+            ++i2;
+        }
+        if ((i1 != l1) || (i2 != l2)) {
+            throw cssu::RuntimeException(rtl::OUString::createFromAscii("Value already set. Tampering?"), *this);
+        }
+    }
+    isi.signatureInfor.ouX509Certificate = ouX509Certificate;
 }
 
 void XSecController::setSignatureValue( rtl::OUString& ouSignatureValue )