diff --git a/CMakeLists.txt b/CMakeLists.txt
index 911d69c1..6adb8998 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -45,6 +45,10 @@ if (UNIX AND NOT APPLE)
find_package(Threads REQUIRED)
endif()
+# TODO(unassigned): expand on types and versions, and then refactor.
+if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
+ set(CLANG TRUE)
+endif()
if(MSVC)
add_definitions("/bigobj /Zm1000 /Z7 /MP /W3 /GS- /D_CRT_SECURE_NO_WARNINGS /wd4996 /wd4503 /wd4345 /wd4091 /D_WIN32_WINNT=0x0600 /DWIN32_LEAN_AND_MEAN /DGTEST_HAS_TR1_TUPLE=0 /FIinline_c.h /D__SSE4_1__")
@@ -66,7 +70,6 @@ else()
# if(NOT APPLE)
# set(WARNINGS "${WARNINGS} -Werror")
# endif()
-
if(CMAKE_C_COMPILER_ID STREQUAL "Clang")
set(WARNINGS "${WARNINGS} -Wno-shift-count-overflow -Wno-error=mismatched-tags -Wno-error=null-conversion -Wno-overloaded-shift-op-parentheses -Wno-error=shift-count-overflow -Wno-error=tautological-constant-out-of-range-compare -Wno-error=unused-private-field -Wno-error=unneeded-internal-declaration")
else()
@@ -103,13 +106,15 @@ else()
else()
set(STATIC_ASSERT_FLAG "-Dstatic_assert=_Static_assert")
endif()
- set(LINUX_LD_GOLD "")
- set(LINUX_STATIC_ICU "")
- if((NOT APPLE) AND (NOT MSVC))
- set(LINUX_LD_GOLD "-fuse-ld=gold")
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11 -D_GNU_SOURCE ${MINGW_FLAG} ${STATIC_ASSERT_FLAG} ${WARNINGS} ${C_WARNINGS} ${ARCH_FLAG}")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpermissive -ftemplate-depth-1024 -std=c++11 -D_GNU_SOURCE ${APPLE_FLAG} ${MINGW_FLAG} ${WARNINGS} ${CXX_WARNINGS} ${ARCH_FLAG}")
+ if (NOT APPLE AND NOT MSVC)
+ if (CLANG)
+ set(LLVM_USE_LINKER "gold")
+ else()
+ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=gold")
+ endif()
endif()
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${LINUX_LD_GOLD} -std=c11 -D_GNU_SOURCE ${MINGW_FLAG} ${STATIC_ASSERT_FLAG} ${WARNINGS} ${C_WARNINGS} ${ARCH_FLAG}")
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${LINUX_LD_GOLD} -fpermissive -ftemplate-depth-1024 -std=c++11 -D_GNU_SOURCE ${APPLE_FLAG} ${MINGW_FLAG} ${WARNINGS} ${CXX_WARNINGS} ${ARCH_FLAG}")
if(CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT (CMAKE_C_COMPILER_VERSION VERSION_LESS 4.8))
set(DEBUG_FLAGS "-g3 -O0") #set(DEBUG_FLAGS "-g3 -Og")
else()
diff --git a/README.md b/README.md
index ee524731..8d8c7a58 100644
--- a/README.md
+++ b/README.md
@@ -4,7 +4,8 @@ Building
### Dependencies
| component / version | minimum
(not recommended but may work) | recommended | most recent of what we have ever tested |
|--|--|--|--|
-| gcc (Linux) | 5.4.0 | 7.2.0 | 7.2.0 |
+| gcc (Linux) | 5.4.0 | 7.2.0 | 8.2.1 |
+| llvm/clang (Linux) | UNKNOWN | 7.0.1 | 7.0.1 |
| [MSVC](https://visualstudio.microsoft.com/downloads/) (Windows) | 2015 (14.0 update 1) | 2015 (14.0 update 3) | 2017 (15.5.7) |
| [XCode](https://developer.apple.com/downloads/) (macOS) | 7.3.1 | 9.2 | 9.2 |
| [CMake](https://cmake.org/download/) | 2.8.6 | 3.4.1 | 3.11.0 |
diff --git a/contrib/db/CMakeLists.txt b/contrib/db/CMakeLists.txt
index bdd4381b..eb5c8415 100644
--- a/contrib/db/CMakeLists.txt
+++ b/contrib/db/CMakeLists.txt
@@ -2,6 +2,6 @@ add_subdirectory(liblmdb)
if(MSVC)
target_compile_options(lmdb PRIVATE /wd4996 /wd4503 /wd4345 /wd4267 /wd4244 /wd4146 /wd4333 /wd4172)
else()
- target_compile_options(lmdb PRIVATE -Wno-discarded-qualifiers -Wno-empty-body -Wno-unused-but-set-variable)
+ # Warnings as used by LMDB itself (LMDB_0.9.23)
+ target_compile_options(lmdb PRIVATE -Wall -Wno-unused-parameter -Wbad-function-cast -Wuninitialized)
endif()
-
diff --git a/contrib/eos_portable_archive/eos/portable_archive_exception.hpp b/contrib/eos_portable_archive/eos/portable_archive_exception.hpp
index fad9ed5f..719fc004 100644
--- a/contrib/eos_portable_archive/eos/portable_archive_exception.hpp
+++ b/contrib/eos_portable_archive/eos/portable_archive_exception.hpp
@@ -35,12 +35,11 @@ namespace eos {
// version of the linked boost archive library
const archive_version_type archive_version(
- 11
-// #if BOOST_VERSION < 103700
-// boost::archive::ARCHIVE_VERSION()
-// #else
-// boost::archive::BOOST_ARCHIVE_VERSION()
-// #endif
+ #if BOOST_VERSION < 103700
+ boost::archive::ARCHIVE_VERSION()
+ #else
+ boost::archive::BOOST_ARCHIVE_VERSION()
+ #endif
);
/**
diff --git a/contrib/eos_portable_archive/eos/portable_iarchive.hpp b/contrib/eos_portable_archive/eos/portable_iarchive.hpp
index 54540989..5d34b1d1 100644
--- a/contrib/eos_portable_archive/eos/portable_iarchive.hpp
+++ b/contrib/eos_portable_archive/eos/portable_iarchive.hpp
@@ -3,7 +3,7 @@
* \file portable_iarchive.hpp
* \brief Provides an archive to read from portable binary files.
* \author christian.pfligersdorffer@gmx.at
- * \version 5.0
+ * \version 5.1
*
* This pair of archives brings the advantages of binary streams to the cross
* platform boost::serialization user. While being almost as fast as the native
@@ -23,6 +23,9 @@
* chance it will instantly work for your specific setup. If you encounter
* problems or have suggestions please contact the author.
*
+ * \note Version 5.1 is now compatible with boost up to version 1.59. Thanks to
+ * ecotax for pointing to the issue with shared_ptr_helper.
+ *
* \note Version 5.0 is now compatible with boost up to version 1.49 and enables
* serialization of std::wstring by converting it to/from utf8 (thanks to
* Arash Abghari for this suggestion). With that all unit tests from the
@@ -89,9 +92,7 @@
#include
#include
-#if BOOST_VERSION >= 105600
-#include
-#elif BOOST_VERSION >= 103500
+#if BOOST_VERSION >= 103500 && BOOST_VERSION < 105600
#include
#endif
@@ -115,14 +116,15 @@
#include
#elif BOOST_VERSION < 104800
#include
+// Boost 1.69 (Spirit.X2/X3) has dropped their own FP routines in favor of boost::math
+#elif BOOST_VERSION < 106900
#include
#else
#include
-#include
#endif
// namespace alias
-#if BOOST_VERSION < 103800
+#if BOOST_VERSION < 103800 || BOOST_VERSION >= 106900
namespace fp = boost::math;
#else
namespace fp = boost::spirit::math;
@@ -135,7 +137,7 @@ namespace endian = boost::detail;
namespace endian = boost::spirit::detail;
#endif
-#ifndef BOOST_NO_STD_WSTRING
+#if BOOST_VERSION >= 104500 && !defined BOOST_NO_STD_WSTRING
// used for wstring to utf8 conversion
#include
#include
@@ -190,9 +192,7 @@ namespace eos {
// load_override functions so we chose to stay one level higher
, public boost::archive::basic_binary_iarchive
- #if BOOST_VERSION >= 105600
- // mix-in helper class for serializing shared_ptr does not exist anymore
- #elif BOOST_VERSION >= 103500
+ #if BOOST_VERSION >= 103500 && BOOST_VERSION < 105600
// mix-in helper class for serializing shared_ptr
, public boost::archive::detail::shared_ptr_helper
#endif
@@ -349,7 +349,7 @@ namespace eos {
T temp = size < 0 ? -1 : 0;
load_binary(&temp, abs(size));
- // load the value from little endian - is is then converted
+ // load the value from little endian - it is then converted
// to the target type T and fits it because size <= sizeof(T)
t = endian::load_little_endian(&temp);
}
diff --git a/contrib/eos_portable_archive/eos/portable_oarchive.hpp b/contrib/eos_portable_archive/eos/portable_oarchive.hpp
index 67f3a695..ca94858b 100644
--- a/contrib/eos_portable_archive/eos/portable_oarchive.hpp
+++ b/contrib/eos_portable_archive/eos/portable_oarchive.hpp
@@ -3,7 +3,7 @@
* \file portable_oarchive.hpp
* \brief Provides an archive to create portable binary files.
* \author christian.pfligersdorffer@gmx.at
- * \version 5.0
+ * \version 5.1
*
* This pair of archives brings the advantages of binary streams to the cross
* platform boost::serialization user. While being almost as fast as the native
@@ -23,6 +23,9 @@
* chance it will instantly work for your specific setup. If you encounter
* problems or have suggestions please contact the author.
*
+ * \note Version 5.1 is now compatible with boost up to version 1.59. Thanks to
+ * ecotax for pointing to the issue with shared_ptr_helper.
+ *
* \note Version 5.0 is now compatible with boost up to version 1.49 and enables
* serialization of std::wstring by converting it to/from utf8 (thanks to
* Arash Abghari for this suggestion). With that all unit tests from the
@@ -91,15 +94,9 @@
#include
#include
#include
-#if BOOST_VERSION >= 105600
-#include
-#elif BOOST_VERSION >= 103500
-#include
-#endif
-#if BOOST_VERSION >= 104500
-#include
-#include
+#if BOOST_VERSION >= 103500 && BOOST_VERSION < 105600
+#include
#endif
// funny polymorphics
@@ -122,14 +119,15 @@
#include
#elif BOOST_VERSION < 104800
#include
+// Boost 1.69 (Spirit.X2/X3) has dropped their own FP routines in favor of boost::math
+#elif BOOST_VERSION < 106900
#include
#else
#include
-#include
#endif
// namespace alias fp_classify
-#if BOOST_VERSION < 103800
+#if BOOST_VERSION < 103800 || BOOST_VERSION >= 106900
namespace fp = boost::math;
#else
namespace fp = boost::spirit::math;
@@ -142,7 +140,7 @@ namespace endian = boost::detail;
namespace endian = boost::spirit::detail;
#endif
-#ifndef BOOST_NO_STD_WSTRING
+#if BOOST_VERSION >= 104500 && !defined BOOST_NO_STD_WSTRING
// used for wstring to utf8 conversion
#include
#include
@@ -195,9 +193,7 @@ namespace eos {
// save_override functions so we chose to stay one level higher
, public boost::archive::basic_binary_oarchive
- #if BOOST_VERSION >= 105600
- // mix-in helper class for serializing shared_ptr does not exist anymore
- #elif BOOST_VERSION >= 103500
+ #if BOOST_VERSION >= 103500 && BOOST_VERSION < 105600
// mix-in helper class for serializing shared_ptr
, public boost::archive::detail::shared_ptr_helper
#endif
diff --git a/contrib/epee/include/misc_log_ex.h b/contrib/epee/include/misc_log_ex.h
index c74378fc..412cb504 100644
--- a/contrib/epee/include/misc_log_ex.h
+++ b/contrib/epee/include/misc_log_ex.h
@@ -893,12 +893,10 @@ namespace log_space
FAST_CRITICAL_REGION_END();
return true;
}
-
std::string get_thread_prefix()
{
FAST_CRITICAL_REGION_LOCAL(m_critical_sec);
return m_thr_prefix_strings[misc_utils::get_thread_string_id()];
-
}
std::string get_default_log_file()
@@ -1160,7 +1158,6 @@ namespace log_space
}
-
static bool add_logger( ibase_log_stream* pstream, int log_level_limit = LOG_LEVEL_4 )
{
logger* plogger = get_or_create_instance();
@@ -1234,8 +1231,6 @@ POP_WARNINGS
}
-
-
#ifdef _MSC_VER
@@ -1290,8 +1285,6 @@ POP_WARNINGS
return plogger->get_thread_prefix();
}
-
-
static std::string get_prefix_entry()
{
std::stringstream str_prefix;
@@ -1587,8 +1580,6 @@ POP_WARNINGS
#endif
-
-
#define LOG_PRINT_NO_POSTFIX(mess, level) LOG_PRINT_NO_POSTFIX2(LOG_DEFAULT_TARGET, mess, level)
#define LOG_PRINT_NO_PREFIX(mess, level) LOG_PRINT_NO_PREFIX2(LOG_DEFAULT_TARGET, mess, level)
#define LOG_PRINT_NO_PREFIX_NO_POSTFIX(mess, level) LOG_PRINT_NO_PREFIX_NO_POSTFIX2(LOG_DEFAULT_TARGET, mess, level)
@@ -1694,7 +1685,6 @@ POP_WARNINGS
#define CHECK_AND_ASSERT_MES2(expr, message) do{if(!(expr)) {LOG_ERROR(message); };}while(0)
#endif
-
}
POP_WARNINGS
diff --git a/contrib/epee/include/net/http_protocol_handler.h b/contrib/epee/include/net/http_protocol_handler.h
index 569b6128..aa4dfa9a 100644
--- a/contrib/epee/include/net/http_protocol_handler.h
+++ b/contrib/epee/include/net/http_protocol_handler.h
@@ -137,6 +137,7 @@ namespace net_utils
bool m_is_stop_handling;
http::http_request_info m_query_info;
size_t m_len_summary, m_len_remain;
+ size_t m_precommand_line_chars;
config_type& m_config;
bool m_want_close;
protected:
diff --git a/contrib/epee/include/net/http_protocol_handler.inl b/contrib/epee/include/net/http_protocol_handler.inl
index d981cdc8..b84bf47c 100644
--- a/contrib/epee/include/net/http_protocol_handler.inl
+++ b/contrib/epee/include/net/http_protocol_handler.inl
@@ -33,8 +33,9 @@
#include "file_io_utils.h"
#include "net_parse_helpers.h"
-#define HTTP_MAX_URI_LEN 9000
-#define HTTP_MAX_HEADER_LEN 100000
+#define HTTP_MAX_URI_LEN 9000
+#define HTTP_MAX_PRE_COMMAND_LINE_CHARS 20
+#define HTTP_MAX_HEADER_LEN 100000
PUSH_WARNINGS
DISABLE_GCC_WARNING(maybe-uninitialized)
@@ -204,7 +205,8 @@ namespace net_utils
m_len_remain(0),
m_config(config),
m_want_close(false),
- m_psnd_hndlr(psnd_hndlr)
+ m_psnd_hndlr(psnd_hndlr),
+ m_precommand_line_chars(0)
{
}
@@ -217,6 +219,7 @@ namespace net_utils
m_body_transfer_type = http_body_transfer_undefined;
m_query_info.clear();
m_len_summary = 0;
+ m_precommand_line_chars = 0;
return true;
}
//--------------------------------------------------------------------------------------------
@@ -257,11 +260,19 @@ namespace net_utils
if((m_cache[0] == '\r' || m_cache[0] == '\n'))
{
//some times it could be that before query line cold be few line breaks
- //so we have to be calm without panic with assers
+ //so we have to be calm down without panic and asserts
m_cache.erase(0, 1);
+
+ //fixed bug with possible '\r\n' chars flood, thanks to @anonimal (https://github.com/anonimal) for pointing this
+ ++m_precommand_line_chars;
+ if (m_precommand_line_chars > HTTP_MAX_PRE_COMMAND_LINE_CHARS)
+ {
+ LOG_ERROR("simple_http_connection_handler::handle_buff_in: Too long URI line");
+ m_state = http_state_error;
+ return false;
+ }
break;
}
-
if(std::string::npos != m_cache.find('\n', 0))
handle_invoke_query_line();
else
@@ -269,7 +280,7 @@ namespace net_utils
m_is_stop_handling = true;
if(m_cache.size() > HTTP_MAX_URI_LEN)
{
- LOG_ERROR("simple_http_connection_handler::handle_buff_out: Too long URI line");
+ LOG_ERROR("simple_http_connection_handler::handle_buff_in: Too long URI line");
m_state = http_state_error;
return false;
}
@@ -297,10 +308,10 @@ namespace net_utils
case http_state_connection_close:
return false;
default:
- LOG_ERROR("simple_http_connection_handler::handle_char_out: Wrong state: " << m_state);
+ LOG_ERROR("simple_http_connection_handler::handle_buff_in: Wrong state: " << m_state);
return false;
case http_state_error:
- LOG_ERROR("simple_http_connection_handler::handle_char_out: Error state!!!");
+ LOG_ERROR("simple_http_connection_handler::handle_buff_in: Error state!!!");
return false;
}
@@ -334,10 +345,10 @@ namespace net_utils
template
bool simple_http_connection_handler::handle_invoke_query_line()
{
- LOG_FRAME("simple_http_connection_handler::handle_recognize_protocol_out(*)", LOG_LEVEL_3);
+ LOG_FRAME("simple_http_connection_handler::handle_invoke_query_line(*)", LOG_LEVEL_3);
STATIC_REGEXP_EXPR_1(rexp_match_command_line, "^(((OPTIONS)|(GET)|(HEAD)|(POST)|(PUT)|(DELETE)|(TRACE)) (\\S+) HTTP/(\\d+).(\\d+))\r?\n", boost::regex::icase | boost::regex::normal);
- // 123 4 5 6 7 8 9 10 11 12
+ // 123 4 5 6 7 8 9 10 11 12
//size_t match_len = 0;
boost::smatch result;
if(boost::regex_search(m_cache, result, rexp_match_command_line, boost::match_default) && result[0].matched)
@@ -682,4 +693,4 @@ namespace net_utils
POP_WARNINGS
//--------------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------------
-//--------------------------------------------------------------------------------------------
\ No newline at end of file
+//--------------------------------------------------------------------------------------------
diff --git a/contrib/epee/include/syncobj.h b/contrib/epee/include/syncobj.h
index f20bff07..c31b5e0c 100644
--- a/contrib/epee/include/syncobj.h
+++ b/contrib/epee/include/syncobj.h
@@ -701,6 +701,11 @@ namespace epee
#define CRITICAL_REGION_BEGIN1(x) CRITICAL_REGION_BEGIN_VAR(x, critical_region_var1)
#define CRITICAL_REGION_END() }
+#define SHARED_CRITICAL_REGION_LOCAL(x) boost::shared_lock< boost::shared_mutex > critical_region_var(x)
+#define EXCLUSIVE_CRITICAL_REGION_LOCAL(x) boost::unique_lock< boost::shared_mutex > critical_region_var(x)
+
+#define SHARED_CRITICAL_REGION_BEGIN(x) { SHARED_CRITICAL_REGION_LOCAL(x)
+#define EXCLUSIVE_CRITICAL_REGION_BEGIN(x) { EXCLUSIVE_CRITICAL_REGION_LOCAL(x)
}
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 44941fc2..85cb0d56 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -92,7 +92,7 @@ add_library(common ${COMMON})
add_dependencies(common version ${PCH_LIB_NAME})
ENABLE_SHARED_PCH(COMMON)
-if(NOT MSVC AND NOT APPLE)
+if(NOT MSVC AND NOT APPLE AND NOT CLANG) # TODO(unassigned): do we really need the clang equivalent?
target_compile_options(common PRIVATE -fno-var-tracking-assignments)
endif()
diff --git a/src/common/crypto_stream_operators.h b/src/common/crypto_stream_operators.h
new file mode 100644
index 00000000..8ae7f53a
--- /dev/null
+++ b/src/common/crypto_stream_operators.h
@@ -0,0 +1,36 @@
+// Copyright (c) 2018-2019 Zano Project
+// Distributed under the MIT/X11 software license, see the accompanying
+// file COPYING or http://www.opensource.org/licenses/mit-license.php.
+
+#pragma once
+#include
+#include
+#include "include_base_utils.h"
+#include "crypto/crypto.h"
+#include "crypto/hash.h"
+//------
+bool parse_hash256(const std::string str_hash, crypto::hash& hash);
+template
+std::ostream &print256(std::ostream &o, const T &v) {
+ return o << "<" << epee::string_tools::pod_to_hex(v) << ">";
+}
+
+template
+std::ostream &print16(std::ostream &o, const T &v) {
+ return o << "<" << epee::string_tools::pod_to_hex(v).substr(0, 5) << "..>";
+}
+
+template
+std::string print16(const T &v) {
+ return std::string("<") + epee::string_tools::pod_to_hex(v).substr(0, 5) + "..>";
+}
+
+
+namespace crypto {
+ inline std::ostream &operator <<(std::ostream &o, const crypto::public_key &v) { return print256(o, v); }
+ inline std::ostream &operator <<(std::ostream &o, const crypto::secret_key &v) { return print256(o, v); }
+ inline std::ostream &operator <<(std::ostream &o, const crypto::key_derivation &v) { return print256(o, v); }
+ inline std::ostream &operator <<(std::ostream &o, const crypto::key_image &v) { return print256(o, v); }
+ inline std::ostream &operator <<(std::ostream &o, const crypto::signature &v) { return print256(o, v); }
+ inline std::ostream &operator <<(std::ostream &o, const crypto::hash &v) { return print256(o, v); }
+}
\ No newline at end of file
diff --git a/src/common/mnemonic-encoding.cpp b/src/common/mnemonic-encoding.cpp
index 3b769860..e5f46641 100644
--- a/src/common/mnemonic-encoding.cpp
+++ b/src/common/mnemonic-encoding.cpp
@@ -34,11 +34,13 @@
// Copyright (c) 2014-2018 Zano Project
// Copyright (c) 2014-2018 The Louisdor Project
+
#include
#include