Blame SOURCES/0001-Related-rhbz-1618703-Properly-handle-failure-decodin.patch

55db36
From 03ab9306c70df34d7824f700d5635e8b458e6d6d Mon Sep 17 00:00:00 2001
55db36
From: Stephan Bergmann <sbergman@redhat.com>
55db36
Date: Thu, 23 Aug 2018 16:45:34 +0200
55db36
Subject: [PATCH 1/5] Related rhbz#1618703: Properly handle failure decoding
55db36
 master password
55db36
MIME-Version: 1.0
55db36
Content-Type: text/plain; charset=UTF-8
55db36
Content-Transfer-Encoding: 8bit
55db36
55db36
...when e.g. FIPS mode makes PasswordContainer::DecodePasswords fail by throwing
55db36
an exception which needs to be caught in PasswordContainerHelper::addRecord (in
55db36
uui/source/passwordcontainer.cxx, but which only catches NoMasterException, not
55db36
generic RuntimeException)
55db36
55db36
Change-Id: I877bb5126e79ac2c90b11ef6d31bf81a2927f409
55db36
Reviewed-on: https://gerrit.libreoffice.org/59511
55db36
Tested-by: Jenkins
55db36
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
55db36
(cherry picked from commit e17987f4bd54fec7e0d94bdefdb94809255b3436)
55db36
Reviewed-on: https://gerrit.libreoffice.org/59568
55db36
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
55db36
Tested-by: Caolán McNamara <caolanm@redhat.com>
55db36
(cherry picked from commit 24b3d08018b6350d5e60615eb375b337ab1b4f75)
55db36
---
55db36
 svl/source/passwordcontainer/passwordcontainer.cxx | 11 ++++++-----
55db36
 svl/source/passwordcontainer/passwordcontainer.hxx |  2 +-
55db36
 2 files changed, 7 insertions(+), 6 deletions(-)
55db36
55db36
diff --git a/svl/source/passwordcontainer/passwordcontainer.cxx b/svl/source/passwordcontainer/passwordcontainer.cxx
55db36
index c2e8b7100028..6d4bb02427ac 100644
55db36
--- a/svl/source/passwordcontainer/passwordcontainer.cxx
55db36
+++ b/svl/source/passwordcontainer/passwordcontainer.cxx
55db36
@@ -417,7 +417,7 @@ void SAL_CALL PasswordContainer::disposing( const EventObject& )
55db36
     }
55db36
 }
55db36
 
55db36
-std::vector< OUString > PasswordContainer::DecodePasswords( const OUString& aLine, const OUString& aMasterPasswd )
55db36
+std::vector< OUString > PasswordContainer::DecodePasswords( const OUString& aLine, const OUString& aMasterPasswd, css::task::PasswordRequestMode mode )
55db36
 {
55db36
     if( !aMasterPasswd.isEmpty() )
55db36
     {
55db36
@@ -463,7 +463,8 @@ std::vector< OUString > PasswordContainer::DecodePasswords( const OUString& aLin
55db36
 
55db36
     // problems with decoding
55db36
     OSL_FAIL( "Problem with decoding" );
55db36
-    throw RuntimeException("Can't decode!" );
55db36
+    throw css::task::NoMasterException(
55db36
+        "Can't decode!", css::uno::Reference<css::uno::XInterface>(), mode);
55db36
 }
55db36
 
55db36
 OUString PasswordContainer::EncodePasswords(const std::vector< OUString >& lines, const OUString& aMasterPasswd )
55db36
@@ -586,7 +587,7 @@ UserRecord PasswordContainer::CopyToUserRecord( const NamePassRecord& aRecord, b
55db36
     {
55db36
         try
55db36
         {
55db36
-            ::std::vector< OUString > aDecodedPasswords = DecodePasswords( aRecord.GetPersPasswords(), GetMasterPassword( aHandler ) );
55db36
+            ::std::vector< OUString > aDecodedPasswords = DecodePasswords( aRecord.GetPersPasswords(), GetMasterPassword( aHandler ), css::task::PasswordRequestMode_PASSWORD_ENTER );
55db36
             aPasswords.insert( aPasswords.end(), aDecodedPasswords.begin(), aDecodedPasswords.end() );
55db36
         }
55db36
         catch( NoMasterException& )
55db36
@@ -848,7 +849,7 @@ OUString const & PasswordContainer::GetMasterPassword( const Reference< XInterac
55db36
                     }
55db36
                     else
55db36
                     {
55db36
-                        std::vector< OUString > aRM( DecodePasswords( aEncodedMP, aPass ) );
55db36
+                        std::vector< OUString > aRM( DecodePasswords( aEncodedMP, aPass, aRMode ) );
55db36
                         if( aRM.empty() || aPass != aRM[0] )
55db36
                         {
55db36
                             bAskAgain = true;
55db36
@@ -1005,7 +1006,7 @@ Sequence< UrlRecord > SAL_CALL PasswordContainer::getAllPersistent( const Refere
55db36
             {
55db36
                 sal_Int32 oldLen = aUsers.getLength();
55db36
                 aUsers.realloc( oldLen + 1 );
55db36
-                aUsers[ oldLen ] = UserRecord( aNP.GetUserName(), comphelper::containerToSequence( DecodePasswords( aNP.GetPersPasswords(), GetMasterPassword( xHandler ) ) ) );
55db36
+                aUsers[ oldLen ] = UserRecord( aNP.GetUserName(), comphelper::containerToSequence( DecodePasswords( aNP.GetPersPasswords(), GetMasterPassword( xHandler ), css::task::PasswordRequestMode_PASSWORD_ENTER ) ) );
55db36
             }
55db36
 
55db36
         if( aUsers.getLength() )
55db36
diff --git a/svl/source/passwordcontainer/passwordcontainer.hxx b/svl/source/passwordcontainer/passwordcontainer.hxx
55db36
index 67ad63e72722..a1190549eb77 100644
55db36
--- a/svl/source/passwordcontainer/passwordcontainer.hxx
55db36
+++ b/svl/source/passwordcontainer/passwordcontainer.hxx
55db36
@@ -268,7 +268,7 @@ css::task::UrlRecord find(
55db36
                               const css::uno::Reference< css::task::XInteractionHandler >& Handler );
55db36
 
55db36
     /// @throws css::uno::RuntimeException
55db36
-    static ::std::vector< OUString > DecodePasswords( const OUString& aLine, const OUString& aMasterPassword );
55db36
+    static ::std::vector< OUString > DecodePasswords( const OUString& aLine, const OUString& aMasterPassword, css::task::PasswordRequestMode mode );
55db36
 
55db36
     /// @throws css::uno::RuntimeException
55db36
     static OUString EncodePasswords(const std::vector< OUString >& lines, const OUString& aMasterPassword );
55db36
-- 
55db36
2.17.1
55db36