This is an automated email from the ASF dual-hosted git repository.

jimjag pushed a commit to branch AOO50X
in repository https://gitbox.apache.org/repos/asf/openoffice.git

commit 4b22bc79d86737a5b99a52a0854438382c2ff0b5
Author: Jim Jagielski <[email protected]>
AuthorDate: Tue Oct 27 11:26:18 2026 -0400

    SvMemoryStream::PutData: add bounds check before memcpy
    
    Add a bounds check before the memcpy so a failed buffer reallocation
    can't overflow the buffer.
    
    Only the stream.cxx hunk is taken; the checkdll RTLD_NOW -> RTLD_LAZY
    change from the original commit is left out, since it would stop checkdll
    from reporting unresolved symbols.
    
    (cherry picked from commit 72d1e63285c8ea992d28de3015eeceee115bea3f)
---
 main/tools/source/stream/stream.cxx | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/main/tools/source/stream/stream.cxx 
b/main/tools/source/stream/stream.cxx
index 6084f215b1..7481a912d7 100644
--- a/main/tools/source/stream/stream.cxx
+++ b/main/tools/source/stream/stream.cxx
@@ -2782,6 +2782,11 @@ sal_Size SvMemoryStream::PutData( const void* pData, 
sal_Size nCount )
             }
         }
     }
+    if (!pBuf || nCount > (nSize - nPos))
+    {
+        nCount = 0;
+        SetError( SVSTREAM_WRITE_ERROR );
+    }
     DBG_ASSERT(pBuf,"Possibly Reallocate failed");
     memcpy( pBuf+nPos, pData, (size_t)nCount);
 

Reply via email to