mirror of
https://github.com/pocoproject/poco.git
synced 2025-01-18 16:37:13 +01:00
fixed GH #966: Possible crash when processing a corrupted Zip file
This commit is contained in:
parent
5e29ae31c1
commit
37aebb57b1
@ -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;
|
||||
};
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user