[Libreoffice-commits] core.git: Branch 'libreoffice-6-1' - svl/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Sat Aug 25 18:35:37 UTC 2018


 svl/source/passwordcontainer/passwordcontainer.cxx |   11 ++++++-----
 svl/source/passwordcontainer/passwordcontainer.hxx |    2 +-
 2 files changed, 7 insertions(+), 6 deletions(-)

New commits:
commit 24b3d08018b6350d5e60615eb375b337ab1b4f75
Author:     Stephan Bergmann <sbergman at redhat.com>
AuthorDate: Thu Aug 23 16:45:34 2018 +0200
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Sat Aug 25 20:35:18 2018 +0200

    Related rhbz#1618703: Properly handle failure decoding master password
    
    ...when e.g. FIPS mode makes PasswordContainer::DecodePasswords fail by throwing
    an exception which needs to be caught in PasswordContainerHelper::addRecord (in
    uui/source/passwordcontainer.cxx, but which only catches NoMasterException, not
    generic RuntimeException)
    
    Change-Id: I877bb5126e79ac2c90b11ef6d31bf81a2927f409
    Reviewed-on: https://gerrit.libreoffice.org/59511
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <sbergman at redhat.com>
    (cherry picked from commit e17987f4bd54fec7e0d94bdefdb94809255b3436)
    Reviewed-on: https://gerrit.libreoffice.org/59568
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/svl/source/passwordcontainer/passwordcontainer.cxx b/svl/source/passwordcontainer/passwordcontainer.cxx
index 6becfd9be78d..514a01eb2ea5 100644
--- a/svl/source/passwordcontainer/passwordcontainer.cxx
+++ b/svl/source/passwordcontainer/passwordcontainer.cxx
@@ -409,7 +409,7 @@ void SAL_CALL PasswordContainer::disposing( const EventObject& )
     }
 }
 
-std::vector< OUString > PasswordContainer::DecodePasswords( const OUString& aLine, const OUString& aMasterPasswd )
+std::vector< OUString > PasswordContainer::DecodePasswords( const OUString& aLine, const OUString& aMasterPasswd, css::task::PasswordRequestMode mode )
 {
     if( !aMasterPasswd.isEmpty() )
     {
@@ -455,7 +455,8 @@ std::vector< OUString > PasswordContainer::DecodePasswords( const OUString& aLin
 
     // problems with decoding
     OSL_FAIL( "Problem with decoding" );
-    throw RuntimeException("Can't decode!" );
+    throw css::task::NoMasterException(
+        "Can't decode!", css::uno::Reference<css::uno::XInterface>(), mode);
 }
 
 OUString PasswordContainer::EncodePasswords(const std::vector< OUString >& lines, const OUString& aMasterPasswd )
@@ -578,7 +579,7 @@ UserRecord PasswordContainer::CopyToUserRecord( const NamePassRecord& aRecord, b
     {
         try
         {
-            ::std::vector< OUString > aDecodedPasswords = DecodePasswords( aRecord.GetPersPasswords(), GetMasterPassword( aHandler ) );
+            ::std::vector< OUString > aDecodedPasswords = DecodePasswords( aRecord.GetPersPasswords(), GetMasterPassword( aHandler ), css::task::PasswordRequestMode_PASSWORD_ENTER );
             aPasswords.insert( aPasswords.end(), aDecodedPasswords.begin(), aDecodedPasswords.end() );
         }
         catch( NoMasterException& )
@@ -840,7 +841,7 @@ OUString const & PasswordContainer::GetMasterPassword( const Reference< XInterac
                     }
                     else
                     {
-                        std::vector< OUString > aRM( DecodePasswords( aEncodedMP, aPass ) );
+                        std::vector< OUString > aRM( DecodePasswords( aEncodedMP, aPass, aRMode ) );
                         if( aRM.empty() || aPass != aRM[0] )
                         {
                             bAskAgain = true;
@@ -997,7 +998,7 @@ Sequence< UrlRecord > SAL_CALL PasswordContainer::getAllPersistent( const Refere
             {
                 sal_Int32 oldLen = aUsers.getLength();
                 aUsers.realloc( oldLen + 1 );
-                aUsers[ oldLen ] = UserRecord( aNP.GetUserName(), comphelper::containerToSequence( DecodePasswords( aNP.GetPersPasswords(), GetMasterPassword( xHandler ) ) ) );
+                aUsers[ oldLen ] = UserRecord( aNP.GetUserName(), comphelper::containerToSequence( DecodePasswords( aNP.GetPersPasswords(), GetMasterPassword( xHandler ), css::task::PasswordRequestMode_PASSWORD_ENTER ) ) );
             }
 
         if( aUsers.getLength() )
diff --git a/svl/source/passwordcontainer/passwordcontainer.hxx b/svl/source/passwordcontainer/passwordcontainer.hxx
index fee47518b01d..3da1e606d4d1 100644
--- a/svl/source/passwordcontainer/passwordcontainer.hxx
+++ b/svl/source/passwordcontainer/passwordcontainer.hxx
@@ -268,7 +268,7 @@ css::task::UrlRecord find(
                               const css::uno::Reference< css::task::XInteractionHandler >& Handler );
 
     /// @throws css::uno::RuntimeException
-    static ::std::vector< OUString > DecodePasswords( const OUString& aLine, const OUString& aMasterPassword );
+    static ::std::vector< OUString > DecodePasswords( const OUString& aLine, const OUString& aMasterPassword, css::task::PasswordRequestMode mode );
 
     /// @throws css::uno::RuntimeException
     static OUString EncodePasswords(const std::vector< OUString >& lines, const OUString& aMasterPassword );


More information about the Libreoffice-commits mailing list