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

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