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

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Wed Sep 1 07:29:03 UTC 2021


 emfio/source/reader/emfreader.cxx |   19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

New commits:
commit 0a2ab8e9310e64a2c053a700a2e5574ec11a24fc
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Mon Aug 30 15:50:26 2021 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Wed Sep 1 09:28:30 2021 +0200

    ofz: MemorySanitizer: use-of-uninitialized-value
    
    Change-Id: I9e7be23fd8a52cfd0976ca358d848cbe11e84c2b
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121355
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/emfio/source/reader/emfreader.cxx b/emfio/source/reader/emfreader.cxx
index e6330987f1bc..a06e589f213b 100644
--- a/emfio/source/reader/emfreader.cxx
+++ b/emfio/source/reader/emfreader.cxx
@@ -1676,10 +1676,25 @@ namespace emfio
                                     .WriteUInt16( 0 )
                                     .WriteUInt16( 0 )
                                     .WriteUInt32( cbBmiSrc + 14 );
+
                                 mpInputStream->Seek( nStart + offBmiSrc );
-                                mpInputStream->ReadBytes(pBuf + 14, cbBmiSrc);
+                                char* pWritePos = pBuf + 14;
+                                auto nRead = mpInputStream->ReadBytes(pWritePos, cbBmiSrc);
+                                if (nRead != cbBmiSrc)
+                                {
+                                    // zero remainder if short read
+                                    memset(pWritePos + nRead, 0, cbBmiSrc - nRead);
+                                }
+
                                 mpInputStream->Seek( nStart + offBitsSrc );
-                                mpInputStream->ReadBytes(pBuf + 14 + cbBmiSrc, cbBitsSrc);
+                                pWritePos = pBuf + 14 + cbBmiSrc;
+                                nRead = mpInputStream->ReadBytes(pWritePos, cbBitsSrc);
+                                if (nRead != cbBitsSrc)
+                                {
+                                    // zero remainder if short read
+                                    memset(pWritePos + nRead, 0, cbBitsSrc - nRead);
+                                }
+
                                 aTmp.Seek( 0 );
                                 ReadDIB(aBitmap, aTmp, true);
 


More information about the Libreoffice-commits mailing list