package/source/zipapi/ZipFile.cxx |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 1b6dcded77c7eae7da916bf73aeec8cb1c5621c7
Author:     Caolán McNamara <caolan.mcnam...@collabora.com>
AuthorDate: Wed Sep 11 12:06:21 2024 +0100
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Fri Sep 13 16:17:17 2024 +0200

    ofz: 22 byte .zip is min size
    
    at which point nPos is 0 on entering this test.
    
    If the buffer does not start with PK\x5\x6 then nPos is decremented
    before checking against 0, so nPos is -1 and doesn't throw as an
    unhandled .zip.
    
    Change-Id: I4a7fed6e863582324945a75bc077f6346ddd5c23
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173208
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>
    (cherry picked from commit d22d47e940da3bea13fe20199b5ab410d9d6ac50)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173298

diff --git a/package/source/zipapi/ZipFile.cxx 
b/package/source/zipapi/ZipFile.cxx
index 0a1a511df1c5..16268b6c28ab 100644
--- a/package/source/zipapi/ZipFile.cxx
+++ b/package/source/zipapi/ZipFile.cxx
@@ -1143,11 +1143,11 @@ std::tuple<sal_Int64, sal_Int64, sal_Int64> 
ZipFile::findCentralDirectory()
                 nEndPos = nPos + nEnd;
                 break;
             }
-            nPos--;
             if (nPos == 0)
             {
                 throw ZipException(u"Zip END signature not found!"_ustr);
             }
+            nPos--;
         }
 
         aGrabber.seek(nEndPos + 4);

Reply via email to