Merge bitcoin/bitcoin#23992: fuzz: Limit fuzzed time to years 2000-2100

fa7238300c fuzz: Limit fuzzed time to years 2000-2100 (MarcoFalke)

Pull request description:

  It doesn't make sense to fuzz times in the past, as Bitcoin Core will refuse to start in the past.

  Fix that and also remove a sanitizer suppression, which would be hit in net_processing in `ProcessMessage`:

  ```cpp

               if (addr.nTime <= 100000000 || addr.nTime > nNow + 10 * 60)
                   addr.nTime = nNow - 5 * 24 * 60 * 60; // <-- Here
  ```

  This changes the format of fuzz inputs. Previously a time value was (de)serialized as 40 bytes, now it is 32 bytes.

ACKs for top commit:
  mzumsande:
    Code Review ACK fa7238300c

Tree-SHA512: ca6e7233beec2d9ef9fd481d8f1331942a4d2c8fe518b857629bebcc53a4f42ae123b994cf5d359384a0a8022098ff5a9c146600bc2593c6d88734e25bc240ad
This commit is contained in:
MarcoFalke 2022-01-17 08:43:12 +01:00
commit 7de2cf9b25
No known key found for this signature in database
GPG Key ID: CE2B75697E69A548
2 changed files with 2 additions and 3 deletions

View File

@ -281,8 +281,8 @@ CAmount ConsumeMoney(FuzzedDataProvider& fuzzed_data_provider, const std::option
int64_t ConsumeTime(FuzzedDataProvider& fuzzed_data_provider, const std::optional<int64_t>& min, const std::optional<int64_t>& max) noexcept
{
// Avoid t=0 (1970-01-01T00:00:00Z) since SetMockTime(0) disables mocktime.
static const int64_t time_min = ParseISO8601DateTime("1970-01-01T00:00:01Z");
static const int64_t time_max = ParseISO8601DateTime("9999-12-31T23:59:59Z");
static const int64_t time_min{ParseISO8601DateTime("2000-01-01T00:00:01Z")};
static const int64_t time_max{ParseISO8601DateTime("2100-12-31T23:59:59Z")};
return fuzzed_data_provider.ConsumeIntegralInRange<int64_t>(min.value_or(time_min), max.value_or(time_max));
}

View File

@ -96,7 +96,6 @@ implicit-signed-integer-truncation:chain.h
implicit-signed-integer-truncation:crypto/
implicit-signed-integer-truncation:node/miner.cpp
implicit-signed-integer-truncation:net.cpp
implicit-signed-integer-truncation:net_processing.cpp
implicit-signed-integer-truncation:streams.h
implicit-signed-integer-truncation:test/arith_uint256_tests.cpp
implicit-signed-integer-truncation:test/skiplist_tests.cpp