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

This commit is contained in:
Guenter Obiltschnig 2015-10-05 12:13:10 +02:00
parent 5e29ae31c1
commit 37aebb57b1
2 changed files with 17 additions and 1 deletions

View File

@ -81,6 +81,8 @@ private:
/// Stores directory info for all found disks
DirectoryInfos64 _disks64;
/// 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(),
@ -110,7 +113,18 @@ 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
{
DirectoryInfos64::const_iterator it64 = _disks64.begin();
if (it64 != _disks64.end())
return it->second.getZipComment();
else
return EMPTY_COMMENT;
}
}