Merge branch 'develop' into feature/mail-msg-decode

This commit is contained in:
Alex Fabijanic 2017-11-07 15:42:46 -06:00
commit a294e1fd88
9 changed files with 54 additions and 29 deletions

View File

@ -14,7 +14,7 @@ namespace CppUnit {
TestRunner::TestRunner(): TestRunner::TestRunner():
_ostr(std::clog) _ostr(std::cout)
{ {
} }

View File

@ -176,23 +176,27 @@ int DeflatingStreamBuf::sync()
if (BufferedStreamBuf::sync()) if (BufferedStreamBuf::sync())
return -1; return -1;
if (_pOstr && _zstr.next_out) if (_pOstr)
{ {
int rc = deflate(&_zstr, Z_SYNC_FLUSH); if (_zstr.next_out)
if (rc != Z_OK) throw IOException(zError(rc));
_pOstr->write(_buffer, DEFLATE_BUFFER_SIZE - _zstr.avail_out);
if (!_pOstr->good()) throw IOException(zError(rc));
while (_zstr.avail_out == 0)
{ {
_zstr.next_out = (unsigned char*) _buffer; int rc = deflate(&_zstr, Z_SYNC_FLUSH);
_zstr.avail_out = DEFLATE_BUFFER_SIZE;
rc = deflate(&_zstr, Z_SYNC_FLUSH);
if (rc != Z_OK) throw IOException(zError(rc)); if (rc != Z_OK) throw IOException(zError(rc));
_pOstr->write(_buffer, DEFLATE_BUFFER_SIZE - _zstr.avail_out); _pOstr->write(_buffer, DEFLATE_BUFFER_SIZE - _zstr.avail_out);
if (!_pOstr->good()) throw IOException(zError(rc)); if (!_pOstr->good()) throw IOException(zError(rc));
}; while (_zstr.avail_out == 0)
_zstr.next_out = (unsigned char*) _buffer; {
_zstr.avail_out = DEFLATE_BUFFER_SIZE; _zstr.next_out = (unsigned char*) _buffer;
_zstr.avail_out = DEFLATE_BUFFER_SIZE;
rc = deflate(&_zstr, Z_SYNC_FLUSH);
if (rc != Z_OK) throw IOException(zError(rc));
_pOstr->write(_buffer, DEFLATE_BUFFER_SIZE - _zstr.avail_out);
if (!_pOstr->good()) throw IOException(zError(rc));
};
_zstr.next_out = (unsigned char*) _buffer;
_zstr.avail_out = DEFLATE_BUFFER_SIZE;
}
_pOstr->flush();
} }
return 0; return 0;
} }

View File

@ -55,13 +55,13 @@ WebSocketImpl::~WebSocketImpl()
} }
} }
int WebSocketImpl::sendBytes(const void* buffer, int length, int flags) int WebSocketImpl::sendBytes(const void* buffer, int length, int flags)
{ {
Poco::Buffer<char> frame(length + MAX_HEADER_LENGTH); Poco::Buffer<char> frame(length + MAX_HEADER_LENGTH);
Poco::MemoryOutputStream ostr(frame.begin(), frame.size()); Poco::MemoryOutputStream ostr(frame.begin(), frame.size());
Poco::BinaryWriter writer(ostr, Poco::BinaryWriter::NETWORK_BYTE_ORDER); Poco::BinaryWriter writer(ostr, Poco::BinaryWriter::NETWORK_BYTE_ORDER);
if (flags == 0) flags = WebSocket::FRAME_BINARY; if (flags == 0) flags = WebSocket::FRAME_BINARY;
flags &= 0xff; flags &= 0xff;
writer << static_cast<Poco::UInt8>(flags); writer << static_cast<Poco::UInt8>(flags);
@ -105,7 +105,7 @@ int WebSocketImpl::sendBytes(const void* buffer, int length, int flags)
return length; return length;
} }
int WebSocketImpl::receiveHeader(char mask[4], bool& useMask) int WebSocketImpl::receiveHeader(char mask[4], bool& useMask)
{ {
char header[MAX_HEADER_LENGTH]; char header[MAX_HEADER_LENGTH];
@ -318,7 +318,7 @@ void WebSocketImpl::shutdownSend()
_pStreamSocketImpl->shutdownSend(); _pStreamSocketImpl->shutdownSend();
} }
void WebSocketImpl::shutdown() void WebSocketImpl::shutdown()
{ {
_pStreamSocketImpl->shutdown(); _pStreamSocketImpl->shutdown();
@ -375,8 +375,12 @@ Poco::Timespan WebSocketImpl::getReceiveTimeout()
int WebSocketImpl::available() int WebSocketImpl::available()
{ {
return _pStreamSocketImpl->available(); int n = _buffer.size() - _bufferOffset;
if (n > 0)
return n + _pStreamSocketImpl->available();
else
return _pStreamSocketImpl->available();
} }
} } // namespace Poco::Net } } // namespace Poco::Net

View File

@ -31,7 +31,7 @@ class Zip_API ZipCommon
public: public:
enum 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) static const Poco::UInt16 ZIP64_EXTRA_ID = 0x1; // Extra data id tag for Zip64 data (in extension for ZipLocalFileHeader and ZipFileInfo)

View File

@ -213,7 +213,6 @@ private:
}; };
inline Poco::UInt32 ZipFileInfo::getCRCFromHeader() const inline Poco::UInt32 ZipFileInfo::getCRCFromHeader() const
{ {
return ZipUtil::get32BitValue(_rawInfo, CRC32_POS); return ZipUtil::get32BitValue(_rawInfo, CRC32_POS);

View File

@ -80,7 +80,7 @@ bool Decompress::handleZipEntry(std::istream& zipStream, const ZipLocalFileHeade
{ {
std::string dirName = hdr.getFileName(); std::string dirName = hdr.getFileName();
if (!ZipCommon::isValidPath(dirName)) if (!ZipCommon::isValidPath(dirName))
throw ZipException("Illegal entry name " + dirName); throw ZipException("Illegal entry name", dirName);
Poco::Path dir(_outDir, dirName); Poco::Path dir(_outDir, dirName);
dir.makeDirectory(); dir.makeDirectory();
Poco::File aFile(dir); Poco::File aFile(dir);
@ -100,7 +100,7 @@ bool Decompress::handleZipEntry(std::istream& zipStream, const ZipLocalFileHeade
} }
if (!ZipCommon::isValidPath(fileName)) if (!ZipCommon::isValidPath(fileName))
throw ZipException("Illegal entry name " + fileName); throw ZipException("Illegal entry name", fileName);
Poco::Path file(fileName); Poco::Path file(fileName);
file.makeFile(); file.makeFile();

View File

@ -22,9 +22,16 @@ namespace Zip {
bool ZipCommon::isValidPath(const std::string& path) bool ZipCommon::isValidPath(const std::string& path)
{ {
try
if (!Path(path).isRelative() || !Path(path, Path::PATH_WINDOWS).isRelative()) {
if (Path(path, Path::PATH_UNIX).isAbsolute() || Path(path, Path::PATH_WINDOWS).isAbsolute())
return false;
}
catch (...)
{
return false; return false;
}
if (path == "..") if (path == "..")
return false; return false;
if ((path.size() >= 3) && path.compare(0, 3, "../") == 0) if ((path.size() >= 3) && path.compare(0, 3, "../") == 0)
@ -41,8 +48,7 @@ bool ZipCommon::isValidPath(const std::string& path)
return false; return false;
if ((path.size() >= 2) && path.compare(0, 2, "~/") == 0) if ((path.size() >= 2) && path.compare(0, 2, "~/") == 0)
return false; return false;
if (path.size() > 0 && (path[0] == '/' || path[0] == '\\'))
return false;
return true; return true;
} }

View File

@ -11,6 +11,6 @@ objects = ZipTestSuite Driver \
target = testrunner target = testrunner
target_version = 1 target_version = 1
target_libs = PocoZip PocoNet PocoFoundation PocoCppUnit target_libs = PocoZip PocoFoundation PocoCppUnit
include $(POCO_BASE)/build/rules/exec include $(POCO_BASE)/build/rules/exec

View File

@ -17,17 +17,29 @@ if (WIN32)
get_filename_component(sdk_dir "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows;CurrentInstallFolder]" REALPATH) get_filename_component(sdk_dir "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows;CurrentInstallFolder]" REALPATH)
get_filename_component(kit_dir "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows Kits\\Installed Roots;KitsRoot]" REALPATH) get_filename_component(kit_dir "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows Kits\\Installed Roots;KitsRoot]" REALPATH)
get_filename_component(kit81_dir "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows Kits\\Installed Roots;KitsRoot81]" REALPATH) get_filename_component(kit81_dir "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows Kits\\Installed Roots;KitsRoot81]" REALPATH)
get_filename_component(kit10_dir "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows Kits\\Installed Roots;KitsRoot10]" REALPATH)
file(GLOB kit10_list ${kit10_dir}/bin/10.*)
if (X64) if (X64)
set(sdk_bindir "${sdk_dir}/bin/x64") set(sdk_bindir "${sdk_dir}/bin/x64")
set(kit_bindir "${kit_dir}/bin/x64") set(kit_bindir "${kit_dir}/bin/x64")
set(kit81_bindir "${kit81_dir}/bin/x64") set(kit81_bindir "${kit81_dir}/bin/x64")
foreach (tmp_elem ${kit10_list})
if (IS_DIRECTORY ${tmp_elem})
list(APPEND kit10_bindir "${tmp_elem}/x64")
endif()
endforeach()
else (X64) else (X64)
set(sdk_bindir "${sdk_dir}/bin") set(sdk_bindir "${sdk_dir}/bin")
set(kit_bindir "${kit_dir}/bin/x86") set(kit_bindir "${kit_dir}/bin/x86")
set(kit81_bindir "${kit81_dir}/bin/x86") set(kit81_bindir "${kit81_dir}/bin/x86")
foreach (tmp_elem ${kit10_list})
if (IS_DIRECTORY ${tmp_elem})
list(APPEND kit10_bindir "${tmp_elem}/x86")
endif()
endforeach()
endif (X64) endif (X64)
endif () endif ()
find_program(CMAKE_MC_COMPILER mc.exe HINTS "${sdk_bindir}" "${kit_bindir}" "${kit81_bindir}" find_program(CMAKE_MC_COMPILER mc.exe HINTS "${sdk_bindir}" "${kit_bindir}" "${kit81_bindir}" ${kit10_bindir}
DOC "path to message compiler") DOC "path to message compiler")
if (NOT CMAKE_MC_COMPILER) if (NOT CMAKE_MC_COMPILER)
message(FATAL_ERROR "message compiler not found: required to build") message(FATAL_ERROR "message compiler not found: required to build")