diff options
author | Lee *!* Clagett <code@leeclagett.com> | 2023-11-06 16:26:39 -0500 |
---|---|---|
committer | Lee *!* Clagett <code@leeclagett.com> | 2023-11-06 16:26:39 -0500 |
commit | 085fdea88cb48768ae6faec6d5fbf073344fb5f0 (patch) | |
tree | 76c9deda5aabe732ccd89d3e24c9bf2efddac79d | |
parent | Merge pull request #9050 (diff) | |
download | monero-085fdea88cb48768ae6faec6d5fbf073344fb5f0.tar.xz |
Add compile-time check for input iterators in ::wire array writing
-rw-r--r-- | contrib/epee/include/serialization/wire/write.h | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/contrib/epee/include/serialization/wire/write.h b/contrib/epee/include/serialization/wire/write.h index c18f7dbcc..c2359918c 100644 --- a/contrib/epee/include/serialization/wire/write.h +++ b/contrib/epee/include/serialization/wire/write.h @@ -30,6 +30,7 @@ #include <boost/utility/string_ref.hpp> #include <boost/range/size.hpp> #include <cstdint> +#include <iterator> #include <system_error> #include <type_traits> @@ -188,7 +189,13 @@ namespace wire_write template<typename T> inline std::size_t array_size(std::true_type, const T& source) - { return boost::size(source); } + { + static_assert( + !std::is_same<typename std::iterator_traits<typename T::const_iterator>::iterator_category, std::input_iterator_tag>{}, + "Input iterators must use json (or similar) derived classes directly" + ); + return boost::size(source); + } template<typename T> inline constexpr std::size_t array_size(std::false_type, const T&) noexcept |