forked from bitcoin/bitcoin
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
merge bitcoin#17071...#18206: fuzzing harness backports (part 1) #4710
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
f8faef1
merge bitcoin#18401: Initialize PrecomputedTransactionData in CheckIn…
kwvg 6522e99
partial bitcoin#19953: Keep spent outputs in PrecomputedTransactionData
kwvg bbbba97
merge bitcoin#17266: Rename DecodeDumpTime to ParseISO8601DateTime
kwvg fd4c6f8
merge bitcoin#17083: Add fuzzing harness for various CScript related …
kwvg 166232b
merge bitcoin#17291: Add fuzzing harness for ISO-8601 related functions
kwvg 27d70d2
merge bitcoin#17050: Add fuzzing harnesses for functions parsing scri…
kwvg 933efc3
merge bitcoin#17229: Add fuzzing harnesses for various Base{32,58,64}…
kwvg 347c0f7
merge bitcoin#17777: Add fuzzing harness for DecodeHexTx(...)
kwvg d3c28bf
merge bitcoin#17771: Add fuzzing harness for V1TransportDeserializer …
kwvg a9d0cbb
merge bitcoin#17113: Add fuzzing harness for descriptor Span-parsing …
kwvg 8dc6222
merge bitcoin#18009: Add fuzzing harness for strprintf(…)
kwvg c449130
merge bitcoin#18029: Add fuzzing harness for AS-mapping (asmap)
kwvg 55abb1e
merge bitcoin#18512: Improve asmap checks and add sanity check
kwvg 4678db1
merge bitcoin#17996: Add fuzzing harness for serialization/deserializ…
kwvg bc25f29
merge bitcoin#18206: Add fuzzing harness for bloom filter classes (CB…
kwvg feb4ce5
merge bitcoin#17972: Add fuzzing harness for CKey related functions
kwvg 38fd597
merge bitcoin#17851: Add std::to_string to list of locale dependent f…
kwvg b28395f
merge bitcoin#18126: Add fuzzing harness for locale independence testing
kwvg 9dc1c8e
ci: exclude fuzzing harnesses from resulting build artifact archive
kwvg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| // Copyright (c) 2020 The Bitcoin Core developers | ||
| // Distributed under the MIT software license, see the accompanying | ||
| // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||
|
|
||
| #include <netaddress.h> | ||
| #include <test/fuzz/fuzz.h> | ||
| #include <util/asmap.h> | ||
|
|
||
| #include <cstdint> | ||
| #include <vector> | ||
|
|
||
| //! asmap code that consumes nothing | ||
| static const std::vector<bool> IPV6_PREFIX_ASMAP = {}; | ||
|
|
||
| //! asmap code that consumes the 96 prefix bits of ::ffff:0/96 (IPv4-in-IPv6 map) | ||
| static const std::vector<bool> IPV4_PREFIX_ASMAP = { | ||
| true, true, false, true, true, true, true, true, true, true, false, false, false, false, false, false, false, false, // Match 0x00 | ||
| true, true, false, true, true, true, true, true, true, true, false, false, false, false, false, false, false, false, // Match 0x00 | ||
| true, true, false, true, true, true, true, true, true, true, false, false, false, false, false, false, false, false, // Match 0x00 | ||
| true, true, false, true, true, true, true, true, true, true, false, false, false, false, false, false, false, false, // Match 0x00 | ||
| true, true, false, true, true, true, true, true, true, true, false, false, false, false, false, false, false, false, // Match 0x00 | ||
| true, true, false, true, true, true, true, true, true, true, false, false, false, false, false, false, false, false, // Match 0x00 | ||
| true, true, false, true, true, true, true, true, true, true, false, false, false, false, false, false, false, false, // Match 0x00 | ||
| true, true, false, true, true, true, true, true, true, true, false, false, false, false, false, false, false, false, // Match 0x00 | ||
| true, true, false, true, true, true, true, true, true, true, false, false, false, false, false, false, false, false, // Match 0x00 | ||
| true, true, false, true, true, true, true, true, true, true, false, false, false, false, false, false, false, false, // Match 0x00 | ||
| true, true, false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, // Match 0xFF | ||
| true, true, false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true // Match 0xFF | ||
| }; | ||
|
|
||
| void test_one_input(const std::vector<uint8_t>& buffer) | ||
| { | ||
| // Encoding: [7 bits: asmap size] [1 bit: ipv6?] [3-130 bytes: asmap] [4 or 16 bytes: addr] | ||
| if (buffer.size() < 1 + 3 + 4) return; | ||
| int asmap_size = 3 + (buffer[0] & 127); | ||
| bool ipv6 = buffer[0] & 128; | ||
| const size_t addr_size = ipv6 ? ADDR_IPV6_SIZE : ADDR_IPV4_SIZE; | ||
| if (buffer.size() < size_t(1 + asmap_size + addr_size)) return; | ||
| std::vector<bool> asmap = ipv6 ? IPV6_PREFIX_ASMAP : IPV4_PREFIX_ASMAP; | ||
| asmap.reserve(asmap.size() + 8 * asmap_size); | ||
| for (int i = 0; i < asmap_size; ++i) { | ||
| for (int j = 0; j < 8; ++j) { | ||
| asmap.push_back((buffer[1 + i] >> j) & 1); | ||
| } | ||
| } | ||
| if (!SanityCheckASMap(asmap, 128)) return; | ||
|
|
||
| const uint8_t* addr_data = buffer.data() + 1 + asmap_size; | ||
| CNetAddr net_addr; | ||
| if (ipv6) { | ||
| assert(addr_size == ADDR_IPV6_SIZE); | ||
| net_addr.SetLegacyIPv6({addr_data, addr_size}); | ||
| } else { | ||
| assert(addr_size == ADDR_IPV4_SIZE); | ||
| in_addr ipv4; | ||
| memcpy(&ipv4, addr_data, addr_size); | ||
| net_addr.SetIP(CNetAddr{ipv4}); | ||
| } | ||
| (void)net_addr.GetMappedAS(asmap); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| // Copyright (c) 2020 The Bitcoin Core developers | ||
| // Distributed under the MIT software license, see the accompanying | ||
| // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||
|
|
||
| #include <util/asmap.h> | ||
| #include <test/fuzz/fuzz.h> | ||
|
|
||
| #include <cstdint> | ||
| #include <vector> | ||
|
|
||
| #include <assert.h> | ||
|
|
||
| void test_one_input(const std::vector<uint8_t>& buffer) | ||
| { | ||
| // Encoding: [asmap using 1 bit / byte] 0xFF [addr using 1 bit / byte] | ||
| bool have_sep = false; | ||
| size_t sep_pos; | ||
| for (size_t pos = 0; pos < buffer.size(); ++pos) { | ||
| uint8_t x = buffer[pos]; | ||
| if ((x & 0xFE) == 0) continue; | ||
| if (x == 0xFF) { | ||
| if (have_sep) return; | ||
| have_sep = true; | ||
| sep_pos = pos; | ||
| } else { | ||
| return; | ||
| } | ||
| } | ||
| if (!have_sep) return; // Needs exactly 1 separator | ||
| if (buffer.size() - sep_pos - 1 > 128) return; // At most 128 bits in IP address | ||
|
|
||
| // Checks on asmap | ||
| std::vector<bool> asmap(buffer.begin(), buffer.begin() + sep_pos); | ||
| if (SanityCheckASMap(asmap, buffer.size() - 1 - sep_pos)) { | ||
| // Verify that for valid asmaps, no prefix (except up to 7 zero padding bits) is valid. | ||
| std::vector<bool> asmap_prefix = asmap; | ||
| while (!asmap_prefix.empty() && asmap_prefix.size() + 7 > asmap.size() && asmap_prefix.back() == false) asmap_prefix.pop_back(); | ||
| while (!asmap_prefix.empty()) { | ||
| asmap_prefix.pop_back(); | ||
| assert(!SanityCheckASMap(asmap_prefix, buffer.size() - 1 - sep_pos)); | ||
| } | ||
| // No address input should trigger assertions in interpreter | ||
| std::vector<bool> addr(buffer.begin() + sep_pos + 1, buffer.end()); | ||
| (void)Interpret(asmap, addr); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.