File tree Expand file tree Collapse file tree 3 files changed +41
-2
lines changed Expand file tree Collapse file tree 3 files changed +41
-2
lines changed Original file line number Diff line number Diff line change @@ -77,13 +77,13 @@ will print an error and suggestion if so.
77
77
78
78
## libFuzzer
79
79
80
- A recent version of ` clang ` , the address sanitizer and libFuzzer is needed (all
80
+ A recent version of ` clang ` , the address/undefined sanitizers (ASan/UBSan) and libFuzzer is needed (all
81
81
found in the ` compiler-rt ` runtime libraries package).
82
82
83
83
To build all fuzz targets with libFuzzer, run
84
84
85
85
```
86
- ./configure --disable-ccache --enable-fuzz --with-sanitizers=fuzzer,address CC=clang CXX=clang++
86
+ ./configure --disable-ccache --enable-fuzz --with-sanitizers=fuzzer,address,undefined CC=clang CXX=clang++
87
87
make
88
88
```
89
89
Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ FUZZ_TARGETS = \
22
22
test/fuzz/inv_deserialize \
23
23
test/fuzz/messageheader_deserialize \
24
24
test/fuzz/netaddr_deserialize \
25
+ test/fuzz/parse_iso8601 \
25
26
test/fuzz/script \
26
27
test/fuzz/script_flags \
27
28
test/fuzz/service_deserialize \
@@ -269,6 +270,12 @@ test_fuzz_netaddr_deserialize_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
269
270
test_fuzz_netaddr_deserialize_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS)
270
271
test_fuzz_netaddr_deserialize_LDADD = $(FUZZ_SUITE_LD_COMMON)
271
272
273
+ test_fuzz_parse_iso8601_SOURCES = $(FUZZ_SUITE) test/fuzz/parse_iso8601.cpp
274
+ test_fuzz_parse_iso8601_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES)
275
+ test_fuzz_parse_iso8601_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
276
+ test_fuzz_parse_iso8601_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS)
277
+ test_fuzz_parse_iso8601_LDADD = $(FUZZ_SUITE_LD_COMMON)
278
+
272
279
test_fuzz_script_SOURCES = $(FUZZ_SUITE) test/fuzz/script.cpp
273
280
test_fuzz_script_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES)
274
281
test_fuzz_script_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
Original file line number Diff line number Diff line change
1
+ // Copyright (c) 2019 The Bitcoin Core developers
2
+ // Distributed under the MIT software license, see the accompanying
3
+ // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
+
5
+ #include < test/fuzz/FuzzedDataProvider.h>
6
+ #include < test/fuzz/fuzz.h>
7
+ #include < util/time.h>
8
+
9
+ #include < cassert>
10
+ #include < cstdint>
11
+ #include < string>
12
+ #include < vector>
13
+
14
+ void test_one_input (const std::vector<uint8_t >& buffer)
15
+ {
16
+ FuzzedDataProvider fuzzed_data_provider (buffer.data (), buffer.size ());
17
+
18
+ const int64_t random_time = fuzzed_data_provider.ConsumeIntegral <int64_t >();
19
+ const std::string random_string = fuzzed_data_provider.ConsumeRemainingBytesAsString ();
20
+
21
+ const std::string iso8601_datetime = FormatISO8601DateTime (random_time);
22
+ const int64_t parsed_time_1 = ParseISO8601DateTime (iso8601_datetime);
23
+ if (random_time >= 0 ) {
24
+ assert (parsed_time_1 >= 0 );
25
+ if (iso8601_datetime.length () == 20 ) {
26
+ assert (parsed_time_1 == random_time);
27
+ }
28
+ }
29
+
30
+ const int64_t parsed_time_2 = ParseISO8601DateTime (random_string);
31
+ assert (parsed_time_2 >= 0 );
32
+ }
You can’t perform that action at this time.
0 commit comments