sfx2/source/doc/oleprops.cxx |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit c615fba780da5ac3073fe5a00848824f59ee376a
Author:     Justin Luth <jl...@mail.com>
AuthorDate: Thu Mar 14 12:29:25 2024 -0400
Commit:     Justin Luth <jl...@mail.com>
CommitDate: Fri Mar 15 21:57:44 2024 +0100

    tdf#160192: avoid hang when trying to overwrite doc/lockfile in RO dir
    
    Bug exposed with 6.1 5259ab8104cfba60c40748ed0cd59d93df038c5b
    sfx2 store: create temp files next to local files
    
    tested on .doc format, code-read suggests it affects xls/ppt too,
    but they throw exceptions, apparently before hitting this section.
    
    I was seeing an infinite loop on SfxOleSection::SaveProperty's
        while((rStrm.Tell() & 3))
            rStrm.WriteUChar( 0 );
    
    because nothing checks to confirm that the tempfile
    is actually created/useable.
    
    Now, instead of an infinite loop, we get a crash...
    
    Change-Id: I9e093432361a8ad6f928ec9b47290274b3d4ef06
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164840
    Reviewed-by: Julien Nabet <serval2...@yahoo.fr>
    Tested-by: Jenkins
    Reviewed-by: Justin Luth <jl...@mail.com>

diff --git a/sfx2/source/doc/oleprops.cxx b/sfx2/source/doc/oleprops.cxx
index 891110c43780..714f58c2f1af 100644
--- a/sfx2/source/doc/oleprops.cxx
+++ b/sfx2/source/doc/oleprops.cxx
@@ -1110,7 +1110,7 @@ ErrCode const & SfxOlePropertySet::SavePropertySet( 
SotStorage* pStrg, const OUS
     if( pStrg )
     {
         rtl::Reference<SotStorageStream> xStrm = pStrg->OpenSotStream( 
rStrmName, StreamMode::TRUNC | StreamMode::STD_WRITE );
-        if( xStrm.is() )
+        if (xStrm.is() && xStrm->IsWritable())
             Save( *xStrm );
         else
             SetError( ERRCODE_IO_ACCESSDENIED );

Reply via email to