summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFridrich Štrba <fridrich.strba@bluewin.ch>2012-08-27 16:01:55 +0200
committerAndras Timar <atimar@suse.com>2012-08-27 16:50:06 +0200
commit93a65b34adb99baea96aa85b7854aec2cf071647 (patch)
tree7590093f0213f239702fc0e015e7c85fa2a0dde6
parent2c1d36c575399fcd8743cfe3b96e107e821cbe65 (diff)
fdo#53533: don't seek to bogus offset
Change-Id: I27d056bdb8329dce302f2737bad5c5dc55791e74 Signed-off-by: Andras Timar <atimar@suse.com>
-rw-r--r--shell/inc/internal/zipfile.hxx1
-rw-r--r--shell/source/win32/zipfile/zipfile.cxx34
2 files changed, 14 insertions, 21 deletions
diff --git a/shell/inc/internal/zipfile.hxx b/shell/inc/internal/zipfile.hxx
index 24fba6542fcf..d39db0006a60 100644
--- a/shell/inc/internal/zipfile.hxx
+++ b/shell/inc/internal/zipfile.hxx
@@ -163,7 +163,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 452c17a3d83e..13b319cc749c 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;