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

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Fri Mar 26 11:51:41 UTC 2021


 vcl/source/filter/png/PngImageReader.cxx |   11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

New commits:
commit 2f2475bb5da7f9fcc30ed35f8946932d69b11294
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Fri Mar 26 10:33:22 2021 +0000
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Fri Mar 26 12:50:55 2021 +0100

    ofz#32111 Timeout
    
    keep continuing on a short read, zeroing out the rest of the block, if
    something was read, but give up if nothing could be read.
    
    vcl/qa/cppunit/graphicfilter/data/png/pass/invalid-chunk.png remains
    working after this. Though to be honest it is also unchanged if
    we just png_error intead of png_warning
    
    Change-Id: I7dc24bcfc0b33e534a3f9665b11cd9aca8003a89
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113152
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/vcl/source/filter/png/PngImageReader.cxx b/vcl/source/filter/png/PngImageReader.cxx
index cdb90d93940a..fc60884f42c8 100644
--- a/vcl/source/filter/png/PngImageReader.cxx
+++ b/vcl/source/filter/png/PngImageReader.cxx
@@ -36,9 +36,14 @@ void lclReadStream(png_structp pPng, png_bytep pOutBytes, png_size_t nBytesToRea
 
     if (nBytesRead != nBytesToRead)
     {
-        // Make sure to not reuse old data (could cause infinite loop).
-        memset(pOutBytes + nBytesRead, 0, nBytesToRead - nBytesRead);
-        png_warning(pPng, "Error reading");
+        if (!nBytesRead)
+            png_error(pPng, "Error reading");
+        else
+        {
+            // Make sure to not reuse old data (could cause infinite loop).
+            memset(pOutBytes + nBytesRead, 0, nBytesToRead - nBytesRead);
+            png_warning(pPng, "Short read");
+        }
     }
 }
 


More information about the Libreoffice-commits mailing list