Add fuzzing harnesses for functions in addrdb.h, net_permissions.h and timedata.h.
tests: Add fuzzing harnesses for functions in addrdb.h, net_permissions.h and timedata.h #18417
pull practicalswift wants to merge 3 commits into bitcoin:master from practicalswift:fuzzers-misc changing 4 files +144 −0-
practicalswift commented at 1:45 PM on March 24, 2020: contributor
- fanquake added the label Tests on Mar 24, 2020
-
in src/test/fuzz/net_permissions.cpp:20 in 39d387e92a outdated
15 | + 16 | +void test_one_input(const std::vector<uint8_t>& buffer) 17 | +{ 18 | + FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size()); 19 | + const std::string s = fuzzed_data_provider.ConsumeRandomLengthString(32); 20 | + const NetPermissionFlags net_permission_flags = fuzzed_data_provider.ConsumeBool() ? fuzzed_data_provider.PickValueInArray<NetPermissionFlags>({NetPermissionFlags::PF_NONE, NetPermissionFlags::PF_BLOOMFILTER, NetPermissionFlags::PF_RELAY, NetPermissionFlags::PF_FORCERELAY, NetPermissionFlags::PF_NOBAN, NetPermissionFlags::PF_MEMPOOL, NetPermissionFlags::PF_ISIMPLICIT, NetPermissionFlags::PF_ALL}) : static_cast<NetPermissionFlags>(fuzzed_data_provider.ConsumeIntegral<uint32_t>());
MarcoFalke commented at 1:57 PM on March 24, 2020:I'd prefer to have them in multiple lines, so that adding and removing values is easier to follow in the diff and in git blame
practicalswift commented at 2:54 PM on March 24, 2020:Now fixed. Considering updating
.clang-formatregarding this whitespace nit since it seems to be recurring (I agree with your rationale).Ideally the
.clang-formatshould be written such thatclang-format -imakes a PR immune against whitespace nits :)
MarcoFalke commented at 3:03 PM on March 24, 2020:I think the goal of clang-format is to only add whitespace, not commas or even normalize whitespace like black does for python
in src/test/fuzz/timedata.cpp:25 in 39d387e92a outdated
20 | + CMedianFilter<int64_t> median_filter{max_size, initial_value}; 21 | + while (fuzzed_data_provider.remaining_bytes() > 0) { 22 | + (void)median_filter.median(); 23 | + assert(median_filter.size() > 0); 24 | + assert(static_cast<size_t>(median_filter.size()) == median_filter.sorted().size()); 25 | + assert(static_cast<unsigned int>(median_filter.size()) <= max_size || max_size == 0);
MarcoFalke commented at 2:02 PM on March 24, 2020:Why is this needed?
assert(static_cast<unsigned int>(median_filter.size()) <= max_size);
practicalswift commented at 2:54 PM on March 24, 2020:It is needed since
max_size == 0means unbounded size asCMedianFilteris currently implemented :)tests: Add fuzzing harness for functions in addrdb.h a8695db785tests: Add fuzzing harness for functions in timedata.h 43ff0d91f8tests: Add fuzzing harness for functions in net_permissions.h 4308aa67e3practicalswift force-pushed on Mar 24, 2020in src/test/fuzz/addrdb.cpp:42 in 4308aa67e3
37 | + break; 38 | + } 39 | + } 40 | + return CBanEntry{}; 41 | + }(); 42 | + assert(!ban_entry.banReasonToString().empty());
MarcoFalke commented at 3:02 PM on March 24, 2020:Would it make sense to also add an
AssertEqualAfterSerializeDeserializehere?
practicalswift commented at 3:24 PM on March 24, 2020:I'm afraid equality is not defined for
CBanEntry. That goes for quite a few of our classes :)MarcoFalke merged this on Mar 24, 2020MarcoFalke closed this on Mar 24, 2020deadalnix referenced this in commit 72db0cf0f5 on Aug 6, 2020jasonbcox referenced this in commit 951ffba58f on Aug 6, 2020practicalswift deleted the branch on Apr 10, 2021kittywhiskers referenced this in commit 99f71fd6eb on May 7, 2022kittywhiskers referenced this in commit 33591a25be on May 7, 2022kittywhiskers referenced this in commit b053eadd52 on Jun 14, 2022kittywhiskers referenced this in commit 72e1b6a9bf on Jun 14, 2022kittywhiskers referenced this in commit a658087d5f on Jun 18, 2022kittywhiskers referenced this in commit 70e2ae1bf2 on Jul 4, 2022kittywhiskers referenced this in commit 5a67fd250e on Jul 6, 2022kittywhiskers referenced this in commit 6ee033b2da on Jul 6, 2022PastaPastaPasta referenced this in commit eefdae1a53 on Jul 12, 2022knst referenced this in commit bc81ac8806 on Jul 21, 2022DrahtBot locked this on Aug 18, 2022ContributorsLabels
This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-16 15:14 UTC
More mirrored repositories can be found on mirror.b10c.me