fixed issues reported by Klocwork

This commit is contained in:
Guenter Obiltschnig 2016-09-26 18:20:32 +02:00
parent 8d053e259c
commit caed8507f4
2 changed files with 24 additions and 12 deletions

View File

@ -98,15 +98,21 @@ void ZipFileInfo::parse(std::istream& inp, bool assumeHeaderRead)
_uncompressedSize = getUncompressedSizeFromHeader(); _uncompressedSize = getUncompressedSizeFromHeader();
parseDateTime(); parseDateTime();
Poco::UInt16 len = getFileNameLength(); Poco::UInt16 len = getFileNameLength();
Poco::Buffer<char> buf(len); if (len > 0)
inp.read(buf.begin(), len); {
_fileName = std::string(buf.begin(), len); Poco::Buffer<char> buf(len);
inp.read(buf.begin(), len);
_fileName = std::string(buf.begin(), len);
}
if (hasExtraField()) if (hasExtraField())
{ {
len = getExtraFieldLength(); len = getExtraFieldLength();
Poco::Buffer<char> xtra(len); if (len > 0)
inp.read(xtra.begin(), len); {
_extraField = std::string(xtra.begin(), len); Poco::Buffer<char> xtra(len);
inp.read(xtra.begin(), len);
_extraField = std::string(xtra.begin(), len);
}
} }
len = getFileCommentLength(); len = getFileCommentLength();
if (len > 0) if (len > 0)

View File

@ -117,15 +117,21 @@ void ZipLocalFileHeader::parse(std::istream& inp, bool assumeHeaderRead)
throw Poco::DataFormatException("bad ZIP file header", "invalid compression method"); throw Poco::DataFormatException("bad ZIP file header", "invalid compression method");
parseDateTime(); parseDateTime();
Poco::UInt16 len = getFileNameLength(); Poco::UInt16 len = getFileNameLength();
Poco::Buffer<char> buf(len); if (len > 0)
inp.read(buf.begin(), len); {
_fileName = std::string(buf.begin(), len); Poco::Buffer<char> buf(len);
inp.read(buf.begin(), len);
_fileName = std::string(buf.begin(), len);
}
if (hasExtraField()) if (hasExtraField())
{ {
len = getExtraFieldLength(); len = getExtraFieldLength();
Poco::Buffer<char> xtra(len); if (len > 0)
inp.read(xtra.begin(), len); {
_extraField = std::string(xtra.begin(), len); Poco::Buffer<char> xtra(len);
inp.read(xtra.begin(), len);
_extraField = std::string(xtra.begin(), len);
}
} }
if (!searchCRCAndSizesAfterData()) if (!searchCRCAndSizesAfterData())
{ {