File tree Expand file tree Collapse file tree 2 files changed +37
-0
lines changed Expand file tree Collapse file tree 2 files changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -35,6 +35,7 @@ FUZZ_TARGETS = \
35
35
test/fuzz/fee_rate \
36
36
test/fuzz/fee_rate_deserialize \
37
37
test/fuzz/flat_file_pos_deserialize \
38
+ test/fuzz/flatfile \
38
39
test/fuzz/float \
39
40
test/fuzz/hex \
40
41
test/fuzz/integer \
@@ -480,6 +481,12 @@ test_fuzz_flat_file_pos_deserialize_LDADD = $(FUZZ_SUITE_LD_COMMON)
480
481
test_fuzz_flat_file_pos_deserialize_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS)
481
482
test_fuzz_flat_file_pos_deserialize_SOURCES = $(FUZZ_SUITE) test/fuzz/deserialize.cpp
482
483
484
+ test_fuzz_flatfile_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES)
485
+ test_fuzz_flatfile_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
486
+ test_fuzz_flatfile_LDADD = $(FUZZ_SUITE_LD_COMMON)
487
+ test_fuzz_flatfile_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS)
488
+ test_fuzz_flatfile_SOURCES = $(FUZZ_SUITE) test/fuzz/flatfile.cpp
489
+
483
490
test_fuzz_float_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES)
484
491
test_fuzz_float_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
485
492
test_fuzz_float_LDADD = $(FUZZ_SUITE_LD_COMMON)
Original file line number Diff line number Diff line change
1
+ // Copyright (c) 2020 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 < flatfile.h>
6
+ #include < optional.h>
7
+ #include < test/fuzz/FuzzedDataProvider.h>
8
+ #include < test/fuzz/fuzz.h>
9
+ #include < test/fuzz/util.h>
10
+
11
+ #include < cassert>
12
+ #include < cstdint>
13
+ #include < string>
14
+ #include < vector>
15
+
16
+ void test_one_input (const std::vector<uint8_t >& buffer)
17
+ {
18
+ FuzzedDataProvider fuzzed_data_provider (buffer.data (), buffer.size ());
19
+ Optional<FlatFilePos> flat_file_pos = ConsumeDeserializable<FlatFilePos>(fuzzed_data_provider);
20
+ if (!flat_file_pos) {
21
+ return ;
22
+ }
23
+ Optional<FlatFilePos> another_flat_file_pos = ConsumeDeserializable<FlatFilePos>(fuzzed_data_provider);
24
+ if (another_flat_file_pos) {
25
+ assert ((*flat_file_pos == *another_flat_file_pos) != (*flat_file_pos != *another_flat_file_pos));
26
+ }
27
+ (void )flat_file_pos->ToString ();
28
+ flat_file_pos->SetNull ();
29
+ assert (flat_file_pos->IsNull ());
30
+ }
You can’t perform that action at this time.
0 commit comments