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 31bd0d215b433d22bd0ff65c32532e9b4c1045e4
Author: Damjan Jovanovic <dam...@apache.org>
AuthorDate: Sun Mar 17 15:56:38 2024 +0200

    Don't allow calls to OpenSSLCipher::blockSize() before the cipher
    is initialized.
    
    Patch by: me
    
    (cherry picked from commit 244f2bcc921bc5dc45e6c1970e27ac2409c44e17)
---
 main/oox/inc/oox/helper/openssl_wrapper.hxx | 5 -----
 main/oox/source/core/encryption.cxx         | 4 ++--
 2 files changed, 2 insertions(+), 7 deletions(-)

diff --git a/main/oox/inc/oox/helper/openssl_wrapper.hxx 
b/main/oox/inc/oox/helper/openssl_wrapper.hxx
index 88d6bf2143..8124dc1e04 100644
--- a/main/oox/inc/oox/helper/openssl_wrapper.hxx
+++ b/main/oox/inc/oox/helper/openssl_wrapper.hxx
@@ -142,11 +142,6 @@ public:
             throwOpenSSLException( "EVP_CipherFinal failed" );
     }
 
-    int blockSize()
-    {
-        return blockSize( cipher );
-    }
-
     static int blockSize( const EVP_CIPHER *cipherAlgorithm )
     {
         return EVP_CIPHER_block_size( cipherAlgorithm );
diff --git a/main/oox/source/core/encryption.cxx 
b/main/oox/source/core/encryption.cxx
index 2bdfa8e794..46ecf49d6d 100644
--- a/main/oox/source/core/encryption.cxx
+++ b/main/oox/source/core/encryption.cxx
@@ -802,7 +802,7 @@ static vector< sal_uInt8 > decryptAll( const EVP_CIPHER* 
cipherAlgorithm,
     OpenSSLCipher cipher;
     cipher.initialize( cipherAlgorithm, key, iv, 0 );
     cipher.setPadding( 0 );
-    const int blockSize = cipher.blockSize();
+    const int blockSize = OpenSSLCipher::blockSize( cipherAlgorithm );
     vector< sal_uInt8 > decryptedData( encryptedDataLength + 2*blockSize );
 
     int decryptedDataLength;
@@ -917,7 +917,7 @@ void AgileEncryptionInfo::decryptStream( BinaryXInputStream 
&aEncryptedPackage,
     const sal_uInt64 decryptedSize = aEncryptedPackage.readuInt64();
 
     sal_uInt8 inputBuffer[ 4096 ];
-    vector< sal_uInt8 > outputBuffer( 4096 + 2*cipher.blockSize() );
+    vector< sal_uInt8 > outputBuffer( 4096 + 2*OpenSSLCipher::blockSize( 
cipherAlgorithm ) );
     sal_Int32 bytesIn;
     int bytesOut;
     int finalBytesOut;

Reply via email to