|
12 | 12 | #include <rpc/server.h>
|
13 | 13 | #include <rpc/util.h>
|
14 | 14 | #include <script/descriptor.h>
|
| 15 | +#include <serialize.h> |
| 16 | +#include <streams.h> |
15 | 17 | #include <test/fuzz/FuzzedDataProvider.h>
|
16 | 18 | #include <test/fuzz/fuzz.h>
|
17 | 19 | #include <test/fuzz/util.h>
|
|
24 | 26 | #include <util/system.h>
|
25 | 27 | #include <util/translation.h>
|
26 | 28 | #include <util/url.h>
|
| 29 | +#include <version.h> |
27 | 30 |
|
28 | 31 | #include <cstdint>
|
29 | 32 | #include <string>
|
@@ -86,4 +89,30 @@ void test_one_input(const std::vector<uint8_t>& buffer)
|
86 | 89 | (void)urlDecode(random_string_1);
|
87 | 90 | (void)ValidAsCString(random_string_1);
|
88 | 91 | (void)_(random_string_1.c_str());
|
| 92 | + |
| 93 | + { |
| 94 | + CDataStream data_stream{SER_NETWORK, INIT_PROTO_VERSION}; |
| 95 | + std::string s; |
| 96 | + LimitedString<10> limited_string = LIMITED_STRING(s, 10); |
| 97 | + data_stream << random_string_1; |
| 98 | + try { |
| 99 | + data_stream >> limited_string; |
| 100 | + assert(data_stream.empty()); |
| 101 | + assert(s.size() <= random_string_1.size()); |
| 102 | + assert(s.size() <= 10); |
| 103 | + if (!random_string_1.empty()) { |
| 104 | + assert(!s.empty()); |
| 105 | + } |
| 106 | + } catch (const std::ios_base::failure&) { |
| 107 | + } |
| 108 | + } |
| 109 | + { |
| 110 | + CDataStream data_stream{SER_NETWORK, INIT_PROTO_VERSION}; |
| 111 | + const LimitedString<10> limited_string = LIMITED_STRING(random_string_1, 10); |
| 112 | + data_stream << limited_string; |
| 113 | + std::string deserialized_string; |
| 114 | + data_stream >> deserialized_string; |
| 115 | + assert(data_stream.empty()); |
| 116 | + assert(deserialized_string == random_string_1); |
| 117 | + } |
89 | 118 | }
|
0 commit comments