[Libreoffice-commits] .: shell/inc shell/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Mon Aug 27 07:05:03 PDT 2012


 shell/inc/internal/zipfile.hxx         |    1 
 shell/source/win32/zipfile/zipfile.cxx |   34 +++++++++++++--------------------
 2 files changed, 14 insertions(+), 21 deletions(-)

New commits:
commit d3300205918f87054c9dd399ac53ad1e979dcdc7
Author: Fridrich Å trba <fridrich.strba at bluewin.ch>
Date:   Mon Aug 27 16:01:55 2012 +0200

    fdo#53533: don't seek to bogus offset
    
    Change-Id: I27d056bdb8329dce302f2737bad5c5dc55791e74

diff --git a/shell/inc/internal/zipfile.hxx b/shell/inc/internal/zipfile.hxx
index aaf3c6c..dd786cc 100644
--- a/shell/inc/internal/zipfile.hxx
+++ b/shell/inc/internal/zipfile.hxx
@@ -162,7 +162,6 @@ private:
 private:
     StreamInterface *m_pStream;
     bool m_bShouldFree;
-    long m_iStartOffset;
 };
 
 #endif
diff --git a/shell/source/win32/zipfile/zipfile.cxx b/shell/source/win32/zipfile/zipfile.cxx
index 452c17a..13b319c 100644
--- a/shell/source/win32/zipfile/zipfile.cxx
+++ b/shell/source/win32/zipfile/zipfile.cxx
@@ -259,9 +259,9 @@ static bool areHeadersConsistent(const LocalFileHeader &header, const CentralDir
     return true;
 }
 
-static bool findCentralDirectoryEnd(StreamInterface *stream, long &startOffset)
+static bool findCentralDirectoryEnd(StreamInterface *stream)
 {
-    stream->sseek(startOffset, SEEK_SET);
+    stream->sseek(0, SEEK_SET);
     try
     {
         while (stream->stell() != -1)
@@ -270,7 +270,6 @@ static bool findCentralDirectoryEnd(StreamInterface *stream, long &startOffset)
             if (signature == CDIR_END_SIG)
             {
                 stream->sseek(-4, SEEK_CUR);
-                startOffset = stream->stell();
                 return true;
             }
             else
@@ -284,9 +283,9 @@ static bool findCentralDirectoryEnd(StreamInterface *stream, long &startOffset)
     return false;
 }
 
-static bool isZipStream(StreamInterface *stream, long &startOffset)
+static bool isZipStream(StreamInterface *stream)
 {
-    if (!findCentralDirectoryEnd(stream, startOffset))
+    if (!findCentralDirectoryEnd(stream))
         return false;
     CentralDirectoryEnd end;
     if (!readCentralDirectoryEnd(stream, end))
@@ -387,11 +386,10 @@ bool ZipFile::IsValidZipFileVersionNumber(void* /* stream*/)
 */
 ZipFile::ZipFile(const std::string &FileName) :
     m_pStream(0),
-    m_bShouldFree(true),
-    m_iStartOffset(0)
+    m_bShouldFree(true)
 {
     m_pStream = new FileStream(FileName.c_str());
-    if (m_pStream && !isZipStream(m_pStream, m_iStartOffset))
+    if (m_pStream && !isZipStream(m_pStream))
     {
         delete m_pStream;
         m_pStream = 0;
@@ -400,10 +398,9 @@ ZipFile::ZipFile(const std::string &FileName) :
 
 ZipFile::ZipFile(StreamInterface *stream) :
     m_pStream(stream),
-    m_bShouldFree(false),
-    m_iStartOffset(0)
+    m_bShouldFree(false)
 {
-    if (!isZipStream(stream, m_iStartOffset))
+    if (!isZipStream(stream))
         m_pStream = 0;
 }
 
@@ -424,15 +421,14 @@ ZipFile::~ZipFile()
 void ZipFile::GetUncompressedContent(
     const std::string &ContentName, /*inout*/ ZipContentBuffer_t &ContentBuffer)
 {
-    long startOffset = m_iStartOffset;
-    if (!findCentralDirectoryEnd(m_pStream, startOffset))
+    if (!findCentralDirectoryEnd(m_pStream))
         return;
     CentralDirectoryEnd end;
     if (!readCentralDirectoryEnd(m_pStream, end))
         return;
     m_pStream->sseek(end.cdir_offset, SEEK_SET);
     CentralDirectoryEntry entry;
-    while (m_pStream->stell() != -1 && m_pStream->stell() < startOffset && (unsigned long)m_pStream->stell() < end.cdir_offset + end.cdir_size)
+    while (m_pStream->stell() != -1 && (unsigned long)m_pStream->stell() < end.cdir_offset + end.cdir_size)
     {
         if (!readCentralDirectoryEntry(m_pStream, entry))
             return;
@@ -497,15 +493,14 @@ void ZipFile::GetUncompressedContent(
 ZipFile::DirectoryPtr_t ZipFile::GetDirectory() const
 {
     DirectoryPtr_t dir(new Directory_t());
-    long startOffset = m_iStartOffset;
-    if (!findCentralDirectoryEnd(m_pStream, startOffset))
+    if (!findCentralDirectoryEnd(m_pStream))
         return dir;
     CentralDirectoryEnd end;
     if (!readCentralDirectoryEnd(m_pStream, end))
         return dir;
     m_pStream->sseek(end.cdir_offset, SEEK_SET);
     CentralDirectoryEntry entry;
-    while (m_pStream->stell() != -1 && m_pStream->stell() < startOffset && (unsigned long)m_pStream->stell() < end.cdir_offset + end.cdir_size)
+    while (m_pStream->stell() != -1 && (unsigned long)m_pStream->stell() < end.cdir_offset + end.cdir_size)
     {
         if (!readCentralDirectoryEntry(m_pStream, entry))
             return dir;
@@ -537,15 +532,14 @@ bool ZipFile::HasContent(const std::string &ContentName) const
 long ZipFile::GetFileLongestFileNameLength() const
 {
     long lmax = 0;
-    long startOffset = m_iStartOffset;
-    if (!findCentralDirectoryEnd(m_pStream, startOffset))
+    if (!findCentralDirectoryEnd(m_pStream))
         return lmax;
     CentralDirectoryEnd end;
     if (!readCentralDirectoryEnd(m_pStream, end))
         return lmax;
     m_pStream->sseek(end.cdir_offset, SEEK_SET);
     CentralDirectoryEntry entry;
-    while (m_pStream->stell() != -1 && m_pStream->stell() < startOffset && (unsigned long)m_pStream->stell() < end.cdir_offset + end.cdir_size)
+    while (m_pStream->stell() != -1 && (unsigned long)m_pStream->stell() < end.cdir_offset + end.cdir_size)
     {
         if (!readCentralDirectoryEntry(m_pStream, entry))
             return lmax;


More information about the Libreoffice-commits mailing list