[Libreoffice-commits] core.git: sfx2/source

Michael Stahl mstahl at redhat.com
Wed Jan 17 12:59:46 UTC 2018


 sfx2/source/dialog/filedlghelper.cxx |   34 ++++++++++++++++++----------------
 1 file changed, 18 insertions(+), 16 deletions(-)

New commits:
commit 566b6f6ec007ef386ad41ced9f6317a4280b6c48
Author: Michael Stahl <mstahl at redhat.com>
Date:   Wed Jan 17 13:49:29 2018 +0100

    coverity#1427631 sfx2: fix silly infinite loop
    
    (regression from 9ef1734f03a008545a01fd394dd0e979bb230a0f)
    
    Change-Id: I31dc5e7aff80f647d8417c290f8f34c43e54486d

diff --git a/sfx2/source/dialog/filedlghelper.cxx b/sfx2/source/dialog/filedlghelper.cxx
index f19ea1488b63..738ab2564497 100644
--- a/sfx2/source/dialog/filedlghelper.cxx
+++ b/sfx2/source/dialog/filedlghelper.cxx
@@ -2669,25 +2669,27 @@ ErrCode RequestPassword(const std::shared_ptr<const SfxFilter>& pCurrentFilter,
     ::rtl::Reference< ::comphelper::DocPasswordRequest > pPasswordRequest( new ::comphelper::DocPasswordRequest( eType, css::task::PasswordRequestMode_PASSWORD_CREATE, aURL, bool( pCurrentFilter->GetFilterFlags() & SfxFilterFlags::PASSWORDTOMODIFY ) ) );
 
     uno::Reference< css::task::XInteractionRequest > rRequest( pPasswordRequest.get() );
-    do {
+    do
+    {
         xInteractionHandler->handle( rRequest );
-        if (pPasswordRequest->isPassword() && !bMSType)
+        if (!pPasswordRequest->isPassword() || bMSType)
         {
-            OString const utf8Pwd(OUStringToOString(pPasswordRequest->getPassword(), RTL_TEXTENCODING_UTF8));
-            OString const utf8Ptm(OUStringToOString(pPasswordRequest->getPasswordToModify(), RTL_TEXTENCODING_UTF8));
-            if (!(52 <= utf8Pwd.getLength() && utf8Pwd.getLength() <= 55
-                    && SvtSaveOptions().GetODFDefaultVersion() < SvtSaveOptions::ODFVER_012)
-                && !(52 <= utf8Ptm.getLength() && utf8Ptm.getLength() <= 55))
-            {
-                break;
-            }
-            ScopedVclPtrInstance<MessBox>(Application::GetDefDialogParent(),
-                MessBoxStyle::Ok, 0, "Password length",
-                "The password you have entered causes interoperability issues. Please enter a password that is shorter than 52 bytes, or longer than 55 bytes."
-                )->Execute();
-
+            break;
         }
-    } while (true);
+        OString const utf8Pwd(OUStringToOString(pPasswordRequest->getPassword(), RTL_TEXTENCODING_UTF8));
+        OString const utf8Ptm(OUStringToOString(pPasswordRequest->getPasswordToModify(), RTL_TEXTENCODING_UTF8));
+        if (!(52 <= utf8Pwd.getLength() && utf8Pwd.getLength() <= 55
+                && SvtSaveOptions().GetODFDefaultVersion() < SvtSaveOptions::ODFVER_012)
+            && !(52 <= utf8Ptm.getLength() && utf8Ptm.getLength() <= 55))
+        {
+            break;
+        }
+        ScopedVclPtrInstance<MessBox>(Application::GetDefDialogParent(),
+            MessBoxStyle::Ok, 0, "Password length",
+            "The password you have entered causes interoperability issues. Please enter a password that is shorter than 52 bytes, or longer than 55 bytes."
+            )->Execute();
+    }
+    while (true);
     if ( pPasswordRequest->isPassword() )
     {
         if ( pPasswordRequest->getPassword().getLength() )


More information about the Libreoffice-commits mailing list