fixed GH# 966: Possible crash when processing a corrupted Zip file

This commit is contained in:
Guenter Obiltschnig 2015-10-05 11:49:43 +02:00
parent d334c7cf8b
commit 1582787868
2 changed files with 9 additions and 1 deletions

View File

@ -77,6 +77,8 @@ private:
/// Info generated by parsing the directory block of the zip file
DirectoryInfos _disks;
/// Stores directory info for all found disks
static const std::string EMPTY_COMMENT;
friend class Compress;
};

View File

@ -24,6 +24,9 @@ namespace Poco {
namespace Zip {
const std::string ZipArchive::EMPTY_COMMENT;
ZipArchive::ZipArchive(std::istream& in):
_entries(),
_infos(),
@ -102,7 +105,10 @@ const std::string& ZipArchive::getZipComment() const
{
// It seems that only the "first" disk is populated (look at Compress::close()), so getting the first ZipArchiveInfo
DirectoryInfos::const_iterator it = _disks.begin();
return it->second.getZipComment();
if (it != _disks.end())
return it->second.getZipComment();
else
return EMPTY_COMMENT;
}