mirror of
https://github.com/pocoproject/poco.git
synced 2025-01-23 10:36:37 +01:00
minor fixes
This commit is contained in:
parent
b09b32a3de
commit
2b95e4d2ee
@ -31,7 +31,7 @@ class Zip_API ZipCommon
|
||||
public:
|
||||
enum
|
||||
{
|
||||
HEADER_SIZE = 4,
|
||||
HEADER_SIZE = 4
|
||||
};
|
||||
|
||||
static const Poco::UInt16 ZIP64_EXTRA_ID = 0x1; // Extra data id tag for Zip64 data (in extension for ZipLocalFileHeader and ZipFileInfo)
|
||||
|
@ -213,7 +213,6 @@ private:
|
||||
};
|
||||
|
||||
|
||||
|
||||
inline Poco::UInt32 ZipFileInfo::getCRCFromHeader() const
|
||||
{
|
||||
return ZipUtil::get32BitValue(_rawInfo, CRC32_POS);
|
||||
|
@ -80,7 +80,7 @@ bool Decompress::handleZipEntry(std::istream& zipStream, const ZipLocalFileHeade
|
||||
{
|
||||
std::string dirName = hdr.getFileName();
|
||||
if (!ZipCommon::isValidPath(dirName))
|
||||
throw ZipException("Illegal entry name " + dirName);
|
||||
throw ZipException("Illegal entry name", dirName);
|
||||
Poco::Path dir(_outDir, dirName);
|
||||
dir.makeDirectory();
|
||||
Poco::File aFile(dir);
|
||||
@ -100,7 +100,7 @@ bool Decompress::handleZipEntry(std::istream& zipStream, const ZipLocalFileHeade
|
||||
}
|
||||
|
||||
if (!ZipCommon::isValidPath(fileName))
|
||||
throw ZipException("Illegal entry name " + fileName);
|
||||
throw ZipException("Illegal entry name", fileName);
|
||||
|
||||
Poco::Path file(fileName);
|
||||
file.makeFile();
|
||||
|
@ -22,9 +22,16 @@ namespace Zip {
|
||||
|
||||
bool ZipCommon::isValidPath(const std::string& path)
|
||||
{
|
||||
|
||||
if (!Path(path).isRelative() || !Path(path, Path::PATH_WINDOWS).isRelative())
|
||||
try
|
||||
{
|
||||
if (Path(path, Path::PATH_UNIX).isAbsolute() || Path(path, Path::PATH_WINDOWS).isAbsolute())
|
||||
return false;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (path == "..")
|
||||
return false;
|
||||
if ((path.size() >= 3) && path.compare(0, 3, "../") == 0)
|
||||
@ -41,8 +48,7 @@ bool ZipCommon::isValidPath(const std::string& path)
|
||||
return false;
|
||||
if ((path.size() >= 2) && path.compare(0, 2, "~/") == 0)
|
||||
return false;
|
||||
if (path.size() > 0 && (path[0] == '/' || path[0] == '\\'))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -11,6 +11,6 @@ objects = ZipTestSuite Driver \
|
||||
|
||||
target = testrunner
|
||||
target_version = 1
|
||||
target_libs = PocoZip PocoNet PocoFoundation PocoCppUnit
|
||||
target_libs = PocoZip PocoFoundation PocoCppUnit
|
||||
|
||||
include $(POCO_BASE)/build/rules/exec
|
||||
|
Loading…
x
Reference in New Issue
Block a user