diff options
author | B Stack <bgstack15@gmail.com> | 2020-03-18 14:13:41 -0400 |
---|---|---|
committer | B Stack <bgstack15@gmail.com> | 2020-03-18 14:13:41 -0400 |
commit | 37d3442dc789d22fa802c9513c7fefbd2614b3a2 (patch) | |
tree | a43b1c04f9947fe02d7d5444354f0176c28ed594 /zen | |
parent | add upstream 10.21 (diff) | |
download | FreeFileSync-37d3442dc789d22fa802c9513c7fefbd2614b3a2.tar.gz FreeFileSync-37d3442dc789d22fa802c9513c7fefbd2614b3a2.tar.bz2 FreeFileSync-37d3442dc789d22fa802c9513c7fefbd2614b3a2.zip |
add upstream 10.22
Diffstat (limited to 'zen')
-rw-r--r-- | zen/format_unit.cpp | 2 | ||||
-rw-r--r-- | zen/open_ssl.cpp | 17 | ||||
-rw-r--r-- | zen/string_base.h | 7 | ||||
-rw-r--r-- | zen/zstring.cpp | 2 |
4 files changed, 18 insertions, 10 deletions
diff --git a/zen/format_unit.cpp b/zen/format_unit.cpp index 91a881dc..eeebda53 100644 --- a/zen/format_unit.cpp +++ b/zen/format_unit.cpp @@ -191,7 +191,7 @@ std::wstring zen::formatNumber(int64_t n) std::wstring zen::formatUtcToLocalTime(time_t utcTime) { - auto errorMsg = [&] { return _("Error") + L" (time_t: " + numberTo<std::wstring>(utcTime) + L")"; }; + auto errorMsg = [&] { return _("Error") + L" (time_t: " + numberTo<std::wstring>(utcTime) + L')'; }; TimeComp loc = getLocalTime(utcTime); diff --git a/zen/open_ssl.cpp b/zen/open_ssl.cpp index b823f8ca..0f1da3fc 100644 --- a/zen/open_ssl.cpp +++ b/zen/open_ssl.cpp @@ -18,7 +18,7 @@ using namespace zen; #error FFS, we are royally screwed! #endif -static_assert(OPENSSL_VERSION_NUMBER >= 0x10100000L, "OpenSSL version too old"); +static_assert(OPENSSL_VERSION_NUMBER >= 0x1010105fL, "OpenSSL version too old"); void zen::openSslInit() @@ -68,7 +68,7 @@ std::wstring formatOpenSSLError(const std::wstring& functionName, unsigned long std::wstring formatLastOpenSSLError(const std::wstring& functionName) { - const unsigned long ec = ::ERR_peek_last_error(); + const auto ec = ::ERR_peek_last_error(); ::ERR_clear_error(); //clean up for next OpenSSL operation on this thread return formatOpenSSLError(functionName, ec); } @@ -566,9 +566,16 @@ public: if (rv != 1) { const int sslError = ::SSL_get_error(ssl_, rv); - if (sslError == SSL_ERROR_ZERO_RETURN || //EOF + close_notify alert - (sslError == SSL_ERROR_SYSCALL && ::ERR_peek_last_error() == 0)) //EOF: only expected for HTTP/1.0 + if (sslError == SSL_ERROR_ZERO_RETURN) + return 0; //EOF + close_notify alert + + warn_static("find a better solution for SSL_read_ex + EOF") + //"sslError == SSL_ERROR_SYSCALL && ::ERR_peek_last_error() == 0" => obsolete as of OpenSSL 1.1.1e + //https://github.com/openssl/openssl/issues/10880#issuecomment-575746226 + const auto ec = ::ERR_peek_last_error(); + if (sslError == SSL_ERROR_SSL && ERR_GET_REASON(ec) == SSL_R_UNEXPECTED_EOF_WHILE_READING) //EOF: only expected for HTTP/1.0 return 0; + throw SysError(formatLastOpenSSLError(L"SSL_read_ex") + L' ' + formatSslErrorCode(sslError)); } assert(bytesReceived > 0); //SSL_read_ex() considers EOF an error! @@ -764,7 +771,7 @@ std::string zen::convertPuttyKeyToPkix(const std::string& keyStream, const std:: auto numToBeString = [](size_t n) -> std::string { - static_assert(usingLittleEndian() && sizeof(n) >= 4); + static_assert(usingLittleEndian()&& sizeof(n) >= 4); const char* numStr = reinterpret_cast<const char*>(&n); return { numStr[3], numStr[2], numStr[1], numStr[0] }; //big endian! }; diff --git a/zen/string_base.h b/zen/string_base.h index d2e00baf..42e1bdf3 100644 --- a/zen/string_base.h +++ b/zen/string_base.h @@ -328,11 +328,11 @@ template <class Char, template <class> class SP> inline Zbase<Char, SP> operator template <class Char, template <class> class SP> inline Zbase<Char, SP> operator+(Zbase<Char, SP>&& lhs, const Char* rhs) { return std::move(lhs += rhs); } //lhs, is an l-value parameter... template <class Char, template <class> class SP> inline Zbase<Char, SP> operator+(Zbase<Char, SP>&& lhs, Char rhs) { return std::move(lhs += rhs); } //and not a local variable => no copy elision -template <class Char, template <class> class SP> inline Zbase<Char, SP> operator+( Char lhs, const Zbase<Char, SP>& rhs) { return Zbase<Char, SP>(&lhs, 1) += rhs; } template <class Char, template <class> class SP> inline Zbase<Char, SP> operator+(const Char* lhs, const Zbase<Char, SP>& rhs) { return Zbase<Char, SP>(lhs ) += rhs; } +template <class Char, template <class> class SP> inline Zbase<Char, SP> operator+( Char lhs, const Zbase<Char, SP>& rhs) { return Zbase<Char, SP>(&lhs, 1) += rhs; } - - +template <class Char, template <class> class SP> inline Zbase<Char, SP> operator+(const Zbase<Char, SP>&, int) = delete; //detect usage errors +template <class Char, template <class> class SP> inline Zbase<Char, SP> operator+(int, const Zbase<Char, SP>&) = delete; // @@ -567,6 +567,7 @@ template <class Char, template <class> class SP> inline Char& Zbase<Char, SP>::operator[](size_t pos) { assert(pos < length()); //design by contract! no runtime check! + reserve(length()); //make unshared! return rawStr_[pos]; } diff --git a/zen/zstring.cpp b/zen/zstring.cpp index 046a3bd4..82082df0 100644 --- a/zen/zstring.cpp +++ b/zen/zstring.cpp @@ -59,7 +59,7 @@ Zstring getUnicodeNormalForm(const Zstring& str) { gchar* outStr = ::g_utf8_normalize(str.c_str(), str.length(), G_NORMALIZE_DEFAULT_COMPOSE); if (!outStr) - throw SysError(L"g_utf8_normalize: conversion failed. (" + utfTo<std::wstring>(str) + L")"); + throw SysError(L"g_utf8_normalize: conversion failed. (" + utfTo<std::wstring>(str) + L')'); ZEN_ON_SCOPE_EXIT(::g_free(outStr)); return outStr; |