[Libreoffice-commits] core.git: Branch 'distro/cib/libreoffice-6-1' - 3 commits - ucb/source

Mike Kaganski (via logerrit) logerrit at kemper.freedesktop.org
Tue Dec 17 23:47:39 UTC 2019


 ucb/source/ucp/webdav-neon/NeonLockStore.cxx |   13 ++++++++++-
 ucb/source/ucp/webdav-neon/NeonLockStore.hxx |    2 +
 ucb/source/ucp/webdav-neon/NeonSession.cxx   |   31 +++++++++++++++++++++++----
 ucb/source/ucp/webdav-neon/NeonSession.hxx   |    1 
 ucb/source/ucp/webdav-neon/webdavcontent.cxx |   10 +++-----
 5 files changed, 46 insertions(+), 11 deletions(-)

New commits:
commit d49602781e920c008ee3a38df5bd6c14552e0a24
Author:     Mike Kaganski <mike.kaganski at collabora.com>
AuthorDate: Mon Jul 8 23:47:12 2019 +1000
Commit:     Thorsten Behrens <Thorsten.Behrens at CIB.de>
CommitDate: Wed Dec 18 00:45:26 2019 +0100

    tdf#126279 related: remove locks from NeonLockStore after NE_AUTH error
    
    Change-Id: Idbbb9bb215e3a56e72a29f798c5a5f84afaf2213
    Reviewed-on: https://gerrit.libreoffice.org/75224
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>
    (cherry picked from commit 94e4695bcfcb9356d37942c47359b94531ef7b95)

diff --git a/ucb/source/ucp/webdav-neon/NeonLockStore.cxx b/ucb/source/ucp/webdav-neon/NeonLockStore.cxx
index 390d58c4e8cb..85b821b2bd87 100644
--- a/ucb/source/ucp/webdav-neon/NeonLockStore.cxx
+++ b/ucb/source/ucp/webdav-neon/NeonLockStore.cxx
@@ -153,7 +153,7 @@ void NeonLockStore::stopTicker(osl::ClearableMutexGuard & rGuard)
 
     rGuard.clear();
 
-    if (pTickerThread.is())
+    if (pTickerThread.is() && pTickerThread->getIdentifier() != osl::Thread::getCurrentIdentifier())
         pTickerThread->join(); // without m_aMutex locked (to prevent deadlock)
 }
 
@@ -198,6 +198,13 @@ void NeonLockStore::removeLock( NeonLock * pLock )
         stopTicker(aGuard);
 }
 
+void NeonLockStore::removeLockDeferred(NeonLock* pLock)
+{
+    osl::MutexGuard aGuard(m_aMutex);
+
+    m_aRemoveDeferred.push_back(pLock);
+}
+
 void NeonLockStore::refreshLocks()
 {
     osl::MutexGuard aGuard( m_aMutex );
@@ -233,6 +240,10 @@ void NeonLockStore::refreshLocks()
         }
         ++it;
     }
+    // removeLock will not need to actually release the lock, because this is run from TickerThread
+    for (auto pLock : m_aRemoveDeferred)
+        removeLock(pLock);
+    m_aRemoveDeferred.clear();
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/ucb/source/ucp/webdav-neon/NeonLockStore.hxx b/ucb/source/ucp/webdav-neon/NeonLockStore.hxx
index 7a76a321ced6..fa64cb320374 100644
--- a/ucb/source/ucp/webdav-neon/NeonLockStore.hxx
+++ b/ucb/source/ucp/webdav-neon/NeonLockStore.hxx
@@ -66,6 +66,7 @@ class NeonLockStore
     ne_lock_store    * m_pNeonLockStore;
     rtl::Reference< TickerThread > m_pTickerThread;
     LockInfoMap        m_aLockInfoMap;
+    std::vector<NeonLock*> m_aRemoveDeferred;
 
 public:
     NeonLockStore();
@@ -82,6 +83,7 @@ public:
                   sal_Int32 nLastChanceToSendRefreshRequest );
 
     void removeLock( NeonLock * pLock );
+    void removeLockDeferred(NeonLock* pLock);
 
     void refreshLocks();
 
diff --git a/ucb/source/ucp/webdav-neon/NeonSession.cxx b/ucb/source/ucp/webdav-neon/NeonSession.cxx
index dfeba0acbabd..c1336c07a9c0 100644
--- a/ucb/source/ucp/webdav-neon/NeonSession.cxx
+++ b/ucb/source/ucp/webdav-neon/NeonSession.cxx
@@ -1631,6 +1631,7 @@ bool NeonSession::LOCK( NeonLock * pLock,
         {
             // tdf#126279: see handling of NE_AUTH in HandleError
             m_bNeedNewSession = true;
+            m_aNeonLockStore.removeLockDeferred(pLock);
         }
         return false;
     }
commit 6dcfaa015d1dfd345c396d756a476dba80f182a2
Author:     Mike Kaganski <mike.kaganski at collabora.com>
AuthorDate: Mon Jul 8 16:25:16 2019 +1000
Commit:     Thorsten Behrens <Thorsten.Behrens at CIB.de>
CommitDate: Wed Dec 18 00:43:49 2019 +0100

    tdf#126279: reinitialize session after NE_AUTH errors in (UN)LOCK
    
    This just fixes the crash; but there's still a problem left/TODO, because
    the lock is kept registered with NeonLockStore; following attempts to lock
    and unlock fail.
    
    The NE_AUTH error is returned from this call stack:
    
    neon.dll!clean_session(auth_session * sess) Line 275
            at C:\cygwin\home\user\lode\dev\core\workdir\UnpackedTarball\neon\src\ne_auth.c(275)
    neon.dll!ah_post_send(ne_request_s * req, void * cookie, const ne_status * status) Line 1554
            at C:\cygwin\home\user\lode\dev\core\workdir\UnpackedTarball\neon\src\ne_auth.c(1554)
    neon.dll!ne_end_request(ne_request_s * req) Line 1399
            at C:\cygwin\home\user\lode\dev\core\workdir\UnpackedTarball\neon\src\ne_request.c(1399)
    neon.dll!ne_xml_dispatch_request(ne_request_s * req, ne_xml_parser_s * parser) Line 105
            at C:\cygwin\home\user\lode\dev\core\workdir\UnpackedTarball\neon\src\ne_xmlreq.c(105)
    neon.dll!ne_lock_refresh(ne_session_s * sess, ne_lock * lock) Line 849
            at C:\cygwin\home\user\lode\dev\core\workdir\UnpackedTarball\neon\src\ne_locks.c(849)
    ucpdav1.dll!webdav_ucp::NeonSession::LOCK(ne_lock * pLock, long & rlastChanceToSendRefreshRequest) Line 1663
            at C:\cygwin\home\user\lode\dev\core\ucb\source\ucp\webdav-neon\NeonSession.cxx(1663)
    ucpdav1.dll!webdav_ucp::NeonLockStore::refreshLocks() Line 216
            at C:\cygwin\home\user\lode\dev\core\ucb\source\ucp\webdav-neon\NeonLockStore.cxx(216)
    ucpdav1.dll!webdav_ucp::TickerThread::execute() Line 78
            at C:\cygwin\home\user\lode\dev\core\ucb\source\ucp\webdav-neon\NeonLockStore.cxx(78)
    salhelper3MSC.dll!salhelper::Thread::run() Line 40
            at C:\cygwin\home\user\lode\dev\core\salhelper\source\thread.cxx(40)
    salhelper3MSC.dll!threadFunc(void * param) Line 186
            at C:\cygwin\home\user\lode\dev\core\include\osl\thread.hxx(186)
    sal3.dll!oslWorkerWrapperFunction(void * pData) Line 58
            at C:\cygwin\home\user\lode\dev\core\sal\osl\w32\thread.cxx(58)
    ucrtbased.dll!thread_start<unsigned int (__cdecl*)(void *),1>(void * const parameter) Line 97
            at minkernel\crts\ucrt\src\appcrt\startup\thread.cpp(97)
    kernel32.dll!BaseThreadInitThunk()
    ntdll.dll!RtlUserThreadStart()
    
    If not reinitialized, then on next access, it SEGFAULTs (hostname is nullptr):
    
    neon.dll!ne_addr_resolve(const char * hostname, int flags) Line 926
            at C:\cygwin\home\user\lode\dev\core\workdir\UnpackedTarball\neon\src\ne_socket.c(926)
    neon.dll!canonical_hostname(const char * serverName) Line 382
            at C:\cygwin\home\user\lode\dev\core\workdir\UnpackedTarball\neon\src\ne_sspi.c(382)
    neon.dll!ne_sspi_create_context(void * * context, char * serverName, int ntlm) Line 423
            at C:\cygwin\home\user\lode\dev\core\workdir\UnpackedTarball\neon\src\ne_sspi.c(423)
    neon.dll!continue_sspi(auth_session * sess, int ntlm, const char * hdr, int attempt, auth_challenge * parms, ne_buffer * * errmsg) Line 639
            at C:\cygwin\home\user\lode\dev\core\workdir\UnpackedTarball\neon\src\ne_auth.c(639)
    neon.dll!sspi_challenge(auth_session * sess, int attempt, auth_challenge * parms, ne_buffer * * errmsg) Line 675
            at C:\cygwin\home\user\lode\dev\core\workdir\UnpackedTarball\neon\src\ne_auth.c(675)
    neon.dll!auth_challenge(auth_session * sess, int attempt, const char * value) Line 1419
            at C:\cygwin\home\user\lode\dev\core\workdir\UnpackedTarball\neon\src\ne_auth.c(1419)
    neon.dll!ah_post_send(ne_request_s * req, void * cookie, const ne_status * status) Line 1550
            at C:\cygwin\home\user\lode\dev\core\workdir\UnpackedTarball\neon\src\ne_auth.c(1550)
    neon.dll!ne_end_request(ne_request_s * req) Line 1399
            at C:\cygwin\home\user\lode\dev\core\workdir\UnpackedTarball\neon\src\ne_request.c(1399)
    neon.dll!ne_request_dispatch(ne_request_s * req) Line 1458
            at C:\cygwin\home\user\lode\dev\core\workdir\UnpackedTarball\neon\src\ne_request.c(1458)
    ucpdav1.dll!webdav_ucp::NeonSession::OPTIONS(const rtl::OUString & inPath, webdav_ucp::DAVOptions & rOptions, const webdav_ucp::DAVRequestEnvironment & rEnv) Line 913
            at C:\cygwin\home\user\lode\dev\core\ucb\source\ucp\webdav-neon\NeonSession.cxx(913)
    ucpdav1.dll!webdav_ucp::DAVResourceAccess::OPTIONS(webdav_ucp::DAVOptions & rOptions, const com::sun::star::uno::Reference<com::sun::star::ucb::XCommandEnvironment> & xEnv) Line 187
            at C:\cygwin\home\user\lode\dev\core\ucb\source\ucp\webdav-neon\DAVResourceAccess.cxx(187)
    ucpdav1.dll!webdav_ucp::Content::getResourceOptions(const com::sun::star::uno::Reference<com::sun::star::ucb::XCommandEnvironment> & xEnv, webdav_ucp::DAVOptions & rDAVOptions, const std::unique_ptr<webdav_ucp::DAVResourceAccess,std::default_delete<webdav_ucp::DAVResourceAccess> > & rResAccess, bool * networkAccessAllowed) Line 3940
            at C:\cygwin\home\user\lode\dev\core\ucb\source\ucp\webdav-neon\webdavcontent.cxx(3940)
    ucpdav1.dll!webdav_ucp::Content::getProperties(const com::sun::star::uno::Reference<com::sun::star::ucb::XCommandEnvironment> & xEnv) Line 323
            at C:\cygwin\home\user\lode\dev\core\ucb\source\ucp\webdav-neon\webdavcontentcaps.cxx(323)
    ucbhelper.dll!ucbhelper::PropertySetInfo::getProperties() Line 106
            at C:\cygwin\home\user\lode\dev\core\ucbhelper\source\provider\contentinfo.cxx(106)
    ucbhelper.dll!ucbhelper::PropertySetInfo::queryProperty(const rtl::OUString & rName, com::sun::star::beans::Property & rProp) Line 187
            at C:\cygwin\home\user\lode\dev\core\ucbhelper\source\provider\contentinfo.cxx(187)
    ucbhelper.dll!ucbhelper::PropertySetInfo::hasPropertyByName(const rtl::OUString & Name) Line 168
            at C:\cygwin\home\user\lode\dev\core\ucbhelper\source\provider\contentinfo.cxx(168)
    sfxlo.dll!SfxBaseModel::getBoolPropertyValue(const rtl::OUString & rName) Line 2582
            at C:\cygwin\home\user\lode\dev\core\sfx2\source\doc\sfxbasemodel.cxx(2582)
    sfxlo.dll!SfxBaseModel::isVersionable() Line 2599
            at C:\cygwin\home\user\lode\dev\core\sfx2\source\doc\sfxbasemodel.cxx(2599)
    sfxlo.dll!SfxObjectShell::GetState_Impl(SfxItemSet & rSet) Line 1133
            at C:\cygwin\home\user\lode\dev\core\sfx2\source\doc\objserv.cxx(1133)
    sfxlo.dll!SfxStubSfxObjectShellGetState_Impl(SfxShell * pShell, SfxItemSet & rSet) Line 220
            at C:\cygwin\home\user\lode\dev\core\workdir\SdiTarget\sfx2\sdi\sfxslots.hxx(220)
    sfxlo.dll!SfxShell::CallState(void(*)(SfxShell *, SfxItemSet &) pFunc, SfxItemSet & rSet) Line 199
            at C:\cygwin\home\user\lode\dev\core\include\sfx2\shell.hxx(199)
    sfxlo.dll!SfxShell::GetSlotState(unsigned short nSlotId, const SfxInterface * pIF, SfxItemSet * pStateSet) Line 480
            at C:\cygwin\home\user\lode\dev\core\sfx2\source\control\shell.cxx(480)
    sfxlo.dll!SfxDispatcher::QueryState(unsigned short nSID, com::sun::star::uno::Any & rAny) Line 1967
            at C:\cygwin\home\user\lode\dev\core\sfx2\source\control\dispatch.cxx(1967)
    sfxlo.dll!SfxDispatchController_Impl::addStatusListener(const com::sun::star::uno::Reference<com::sun::star::frame::XStatusListener> & aListener, const com::sun::star::util::URL & aURL) Line 832
            at C:\cygwin\home\user\lode\dev\core\sfx2\source\control\unoctitm.cxx(832)
    sfxlo.dll!SfxOfficeDispatch::addStatusListener(const com::sun::star::uno::Reference<com::sun::star::frame::XStatusListener> & aListener, const com::sun::star::util::URL & aURL) Line 252
            at C:\cygwin\home\user\lode\dev\core\sfx2\source\control\unoctitm.cxx(252)
    fwklo.dll!framework::MenuBarManager::Activate(Menu * pMenu) Line 756
            at C:\cygwin\home\user\lode\dev\core\framework\source\uielement\menubarmanager.cxx(756)
    fwklo.dll!framework::MenuBarManager::LinkStubActivate(void * instance, Menu * data) Line 605
            at C:\cygwin\home\user\lode\dev\core\framework\source\uielement\menubarmanager.cxx(605)
    vcllo.dll!Link<Menu *,bool>::Call(Menu * data) Line 112
            at C:\cygwin\home\user\lode\dev\core\include\tools\link.hxx(112)
    vcllo.dll!Menu::Activate() Line 270
            at C:\cygwin\home\user\lode\dev\core\vcl\source\window\menu.cxx(270)
    vcllo.dll!PopupMenu::ImplExecute(const VclPtr<vcl::Window> & pW, const tools::Rectangle & rRect, FloatWinPopupFlags nPopupModeFlags, Menu * pSFrom, bool bPreSelectFirst) Line 2876
            at C:\cygwin\home\user\lode\dev\core\vcl\source\window\menu.cxx(2876)
    vcllo.dll!MenuBarWindow::ImplCreatePopup(bool bPreSelectFirst) Line 339
            at C:\cygwin\home\user\lode\dev\core\vcl\source\window\menubarwindow.cxx(339)
    vcllo.dll!MenuBarWindow::ChangeHighlightItem(unsigned short n, bool bSelectEntry, bool bAllowRestoreFocus, bool bDefaultToDocument) Line 558
            at C:\cygwin\home\user\lode\dev\core\vcl\source\window\menubarwindow.cxx(558)
    vcllo.dll!MenuBarWindow::MouseButtonDown(const MouseEvent & rMEvt) Line 403
            at C:\cygwin\home\user\lode\dev\core\vcl\source\window\menubarwindow.cxx(403)
    vcllo.dll!ImplHandleMouseEvent(const VclPtr<vcl::Window> & xWindow, MouseNotifyEvent nSVEvent, bool bMouseLeave, long nX, long nY, unsigned __int64 nMsgTime, unsigned short nCode, MouseEventModifiers nMode) Line 700
            at C:\cygwin\home\user\lode\dev\core\vcl\source\window\winproc.cxx(700)
    vcllo.dll!ImplHandleSalMouseButtonDown(vcl::Window * pWindow, const SalMouseEvent * pEvent) Line 2017
            at C:\cygwin\home\user\lode\dev\core\vcl\source\window\winproc.cxx(2017)
    vcllo.dll!ImplWindowFrameProc(vcl::Window * _pWindow, SalEvent nEvent, const void * pEvent) Line 2351
            at C:\cygwin\home\user\lode\dev\core\vcl\source\window\winproc.cxx(2351)
    vcllo.dll!SalFrame::CallCallback(SalEvent nEvent, const void * pEvent) Line 299
            at C:\cygwin\home\user\lode\dev\core\vcl\inc\salframe.hxx(299)
    vclplug_winlo.dll!ImplHandleMouseMsg(HWND__ * hWnd, unsigned int nMsg, unsigned __int64 wParam, __int64 lParam) Line 3132
            at C:\cygwin\home\user\lode\dev\core\vcl\win\window\salframe.cxx(3132)
    vclplug_winlo.dll!SalFrameWndProc(HWND__ * hWnd, unsigned int nMsg, unsigned __int64 wParam, __int64 lParam, bool & rDef) Line 5487
            at C:\cygwin\home\user\lode\dev\core\vcl\win\window\salframe.cxx(5487)
    vclplug_winlo.dll!SalFrameWndProcW(HWND__ * hWnd, unsigned int nMsg, unsigned __int64 wParam, __int64 lParam) Line 5840
            at C:\cygwin\home\user\lode\dev\core\vcl\win\window\salframe.cxx(5840)
    user32.dll!UserCallWinProcCheckWow()
    user32.dll!CallWindowProcW()
    opengl32.dll!wglWndProc()
    user32.dll!UserCallWinProcCheckWow()
    user32.dll!DispatchMessageWorker()
    vclplug_winlo.dll!ImplSalDispatchMessage(const tagMSG * pMsg) Line 411
            at C:\cygwin\home\user\lode\dev\core\vcl\win\app\salinst.cxx(411)
    vclplug_winlo.dll!ImplSalYield(bool bWait, bool bHandleAllCurrentEvents) Line 484
            at C:\cygwin\home\user\lode\dev\core\vcl\win\app\salinst.cxx(484)
    vclplug_winlo.dll!WinSalInstance::DoYield(bool bWait, bool bHandleAllCurrentEvents) Line 513
            at C:\cygwin\home\user\lode\dev\core\vcl\win\app\salinst.cxx(513)
    vcllo.dll!ImplYield(bool i_bWait, bool i_bAllEvents) Line 447
            at C:\cygwin\home\user\lode\dev\core\vcl\source\app\svapp.cxx(447)
    vcllo.dll!Application::Yield() Line 512
            at C:\cygwin\home\user\lode\dev\core\vcl\source\app\svapp.cxx(512)
    vcllo.dll!Application::Execute() Line 428
            at C:\cygwin\home\user\lode\dev\core\vcl\source\app\svapp.cxx(428)
    sofficeapp.dll!desktop::Desktop::Main() Line 1620
            at C:\cygwin\home\user\lode\dev\core\desktop\source\app\app.cxx(1620)
    vcllo.dll!ImplSVMain() Line 191
            at C:\cygwin\home\user\lode\dev\core\vcl\source\app\svmain.cxx(191)
    vcllo.dll!SVMain() Line 226
            at C:\cygwin\home\user\lode\dev\core\vcl\source\app\svmain.cxx(226)
    sofficeapp.dll!soffice_main() Line 170
            at C:\cygwin\home\user\lode\dev\core\desktop\source\app\sofficemain.cxx(170)
    soffice.bin!sal_main() Line 48
            at C:\cygwin\home\user\lode\dev\core\desktop\source\app\main.c(48)
    soffice.bin!main(int argc, char * * argv) Line 47
            at C:\cygwin\home\user\lode\dev\core\desktop\source\app\main.c(47)
    soffice.bin!invoke_main() Line 79
            at d:\agent\_work\2\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl(79)
    soffice.bin!__scrt_common_main_seh() Line 288
            at d:\agent\_work\2\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl(288)
    soffice.bin!__scrt_common_main() Line 331
            at d:\agent\_work\2\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl(331)
    soffice.bin!mainCRTStartup() Line 17
            at d:\agent\_work\2\s\src\vctools\crt\vcstartup\src\startup\exe_main.cpp(17)
    kernel32.dll!BaseThreadInitThunk()
    ntdll.dll!RtlUserThreadStart()
    
    Change-Id: I632d85b65406e29ad0e3d56d8481c651c64b2ec8
    Reviewed-on: https://gerrit.libreoffice.org/75194
    Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>
    Tested-by: Mike Kaganski <mike.kaganski at collabora.com>
    (cherry picked from commit 351b730e012fd4562f341967f740f8146aa0538e)

diff --git a/ucb/source/ucp/webdav-neon/NeonSession.cxx b/ucb/source/ucp/webdav-neon/NeonSession.cxx
index 9210096dd19b..dfeba0acbabd 100644
--- a/ucb/source/ucp/webdav-neon/NeonSession.cxx
+++ b/ucb/source/ucp/webdav-neon/NeonSession.cxx
@@ -1611,7 +1611,8 @@ bool NeonSession::LOCK( NeonLock * pLock,
     TimeValue startCall;
     osl_getSystemTime( &startCall );
 
-    if ( ne_lock_refresh( m_pHttpSession, pLock ) == NE_OK )
+    const int theRetVal = ne_lock_refresh(m_pHttpSession, pLock);
+    if (theRetVal == NE_OK)
     {
         rlastChanceToSendRefreshRequest
             = lastChanceToSendRefreshRequest( startCall, pLock->timeout );
@@ -1626,6 +1627,11 @@ bool NeonSession::LOCK( NeonLock * pLock,
         SAL_WARN( "ucb.ucp.webdav", "LOCK (refresh) - not refreshed! Relative URL: <" << p << "> token: <" << pLock->token << ">"  );
         ne_free( p );
 #endif
+        if (theRetVal == NE_AUTH)
+        {
+            // tdf#126279: see handling of NE_AUTH in HandleError
+            m_bNeedNewSession = true;
+        }
         return false;
     }
 }
@@ -1672,7 +1678,8 @@ bool NeonSession::UNLOCK( NeonLock * pLock )
     }
 #endif
 
-    if ( ne_unlock( m_pHttpSession, pLock ) == NE_OK )
+    const int theRetVal = ne_unlock(m_pHttpSession, pLock);
+    if (theRetVal == NE_OK)
     {
 #if defined SAL_LOG_INFO
     {
@@ -1692,6 +1699,11 @@ bool NeonSession::UNLOCK( NeonLock * pLock )
         ne_free( p );
     }
 #endif
+        if (theRetVal == NE_AUTH)
+        {
+            // tdf#126279: see handling of NE_AUTH in HandleError
+            m_bNeedNewSession = true;
+        }
         return false;
     }
 }
commit b57678be987f9b9df39ad8d7de9a0d87bc0c6ef3
Author:     Mike Kaganski <mike.kaganski at collabora.com>
AuthorDate: Tue Jan 8 05:47:04 2019 +0300
Commit:     Thorsten Behrens <Thorsten.Behrens at CIB.de>
CommitDate: Wed Dec 18 00:42:54 2019 +0100

    Don't crash when accessing WebDAV resource after auth failed
    
    In my testing on Windows, the crashing scenario was this:
    1. FileDialogHelper_Impl::updateVersions() creates storage calling
       comphelper::OStorageHelper::GetStorageFromURL;
    2. Content::openStream() calls isDocument first;
    3. Content::isDocument() indirectly initiates WebDAV session,
       creating a NeonSession;
    4. All operations of NeonSession call Init() first; its first call
       initializes m_pHttpSession using ne_session_create, and then
       adds auth callbacks using ne_add_server_auth/ne_add_proxy_auth
    5. Then NeonSession performs the rest of PROPFIND task, calling
       ah_post_send and auth_challenge; the latter fails, then
       ah_post_send calls clean_session, which cleans m_pHttpSession's
       auth_session's sspi_host;
    6. NeonSession::HandleError throws DAVException for NE_AUTH error;
    7. Content::isDocument() returns true to Content::openStream(),
       which proceeds to execute the command, which in turn re-uses
       the NeonSession and its m_pHttpSession;
    8. NeonSession::OPTIONS then indirectly calls continue_sspi, which
       tries to dereference the m_pHttpSession's auth_session's
       sspi_host which is nullptr at this point.
    
    So in case NeonSession detects the NE_AUTH error condition, let's
    set a flag indicating that the next Init() should reinitialize its
    m_pHttpSession.
    
    Also fixed a case when xProps was used before initialization in
    Content::getPropertyValues.
    
    Reviewed-on: https://gerrit.libreoffice.org/65950
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>
    (cherry picked from commit 162a472d55cf9fb9aaa6d5eae625b3da2273a516)
    
    Conflicts:
            ucb/source/ucp/webdav-neon/NeonSession.hxx
    
    Change-Id: Ifc9eec4fe0333ff6be17c5089068441b4a6eb78c

diff --git a/ucb/source/ucp/webdav-neon/NeonSession.cxx b/ucb/source/ucp/webdav-neon/NeonSession.cxx
index aac868e3d87a..9210096dd19b 100644
--- a/ucb/source/ucp/webdav-neon/NeonSession.cxx
+++ b/ucb/source/ucp/webdav-neon/NeonSession.cxx
@@ -615,7 +615,8 @@ void NeonSession::Init()
 {
     osl::Guard< osl::Mutex > theGuard( m_aMutex );
 
-    bool bCreateNewSession = false;
+    bool bCreateNewSession = m_bNeedNewSession;
+    m_bNeedNewSession = false;
 
     if ( m_pHttpSession == nullptr )
     {
@@ -669,13 +670,17 @@ void NeonSession::Init()
             m_aProxyName = rProxyCfg.aName;
             m_nProxyPort = rProxyCfg.nPort;
 
+            bCreateNewSession = true;
+        }
+
+        if (bCreateNewSession)
+        {
             // new session needed, destroy old first
             {
                 osl::Guard< osl::Mutex > theGlobalGuard( aGlobalNeonMutex );
                 ne_session_destroy( m_pHttpSession );
             }
             m_pHttpSession = nullptr;
-            bCreateNewSession = true;
         }
     }
 
@@ -1921,6 +1926,11 @@ void NeonSession::HandleError( int nError,
                                     m_aHostName, m_nPort ) );
 
         case NE_AUTH:         // User authentication failed on server
+            // m_pHttpSession could get invalidated, e.g., as result of clean_session called in
+            // ah_post_send in case when auth_challenge failed, which invalidates the auth_session
+            // which we established in Init(): the auth_session's sspi_host gets disposed, and
+            // next attempt to authenticate would crash in continue_sspi trying to dereference it
+            m_bNeedNewSession = true;
             throw DAVException( DAVException::DAV_HTTP_AUTH,
                                 NeonUri::makeConnectionEndPointString(
                                     m_aHostName, m_nPort ) );
diff --git a/ucb/source/ucp/webdav-neon/NeonSession.hxx b/ucb/source/ucp/webdav-neon/NeonSession.hxx
index 87026ad23ec4..f66152fda6a7 100644
--- a/ucb/source/ucp/webdav-neon/NeonSession.hxx
+++ b/ucb/source/ucp/webdav-neon/NeonSession.hxx
@@ -54,6 +54,7 @@ private:
     sal_Int32         m_nProxyPort;
     css::uno::Sequence< css::beans::NamedValue > m_aFlags;
     HttpSession *     m_pHttpSession;
+    bool m_bNeedNewSession = false; // Something happened that could invalidate m_pHttpSession
     void *            m_pRequestData;
     const ucbhelper::InternetProxyDecider & m_rProxyDecider;
 
diff --git a/ucb/source/ucp/webdav-neon/webdavcontent.cxx b/ucb/source/ucp/webdav-neon/webdavcontent.cxx
index 3113b3c1f5f1..0f99aa1fe637 100644
--- a/ucb/source/ucp/webdav-neon/webdavcontent.cxx
+++ b/ucb/source/ucp/webdav-neon/webdavcontent.cxx
@@ -1628,12 +1628,10 @@ uno::Reference< sdbc::XRow > Content::getPropertyValues(
 
         if ( eType == DAV )
         {
-            //xProps.reset(
-            //    new ContentProperties( aUnescapedTitle ) );
-            xProps->addProperty(
-                "Title",
-                uno::makeAny( aUnescapedTitle ),
-                true );
+            if (!xProps)
+                xProps.reset(new ContentProperties(aUnescapedTitle));
+            else
+                xProps->addProperty("Title", uno::makeAny(aUnescapedTitle), true);
         }
         else
         {


More information about the Libreoffice-commits mailing list