2021-12-30 19:36:57 +02:00
|
|
|
// Copyright (c) 2009-2021 The Bitcoin Core developers
|
2019-10-03 09:11:40 +00:00
|
|
|
// Distributed under the MIT software license, see the accompanying
|
|
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
|
|
|
|
#include <chainparams.h>
|
|
|
|
#include <core_io.h>
|
|
|
|
#include <rpc/client.h>
|
|
|
|
#include <rpc/util.h>
|
|
|
|
#include <test/fuzz/fuzz.h>
|
|
|
|
|
|
|
|
#include <limits>
|
|
|
|
#include <string>
|
|
|
|
|
2020-12-03 16:42:49 +01:00
|
|
|
void initialize_parse_univalue()
|
2019-10-03 09:11:40 +00:00
|
|
|
{
|
2020-03-10 12:55:41 +00:00
|
|
|
static const ECCVerifyHandle verify_handle;
|
2019-10-03 09:11:40 +00:00
|
|
|
SelectParams(CBaseChainParams::REGTEST);
|
|
|
|
}
|
|
|
|
|
2020-12-03 16:42:49 +01:00
|
|
|
FUZZ_TARGET_INIT(parse_univalue, initialize_parse_univalue)
|
2019-10-03 09:11:40 +00:00
|
|
|
{
|
|
|
|
const std::string random_string(buffer.begin(), buffer.end());
|
|
|
|
bool valid = true;
|
|
|
|
const UniValue univalue = [&] {
|
|
|
|
try {
|
|
|
|
return ParseNonRFCJSONValue(random_string);
|
|
|
|
} catch (const std::runtime_error&) {
|
|
|
|
valid = false;
|
|
|
|
return NullUniValue;
|
|
|
|
}
|
|
|
|
}();
|
|
|
|
if (!valid) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
(void)ParseHashO(univalue, "A");
|
2020-03-10 11:22:48 +00:00
|
|
|
} catch (const UniValue&) {
|
|
|
|
} catch (const std::runtime_error&) {
|
|
|
|
}
|
|
|
|
try {
|
2019-10-03 09:11:40 +00:00
|
|
|
(void)ParseHashO(univalue, random_string);
|
|
|
|
} catch (const UniValue&) {
|
|
|
|
} catch (const std::runtime_error&) {
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
(void)ParseHashV(univalue, "A");
|
2020-03-10 11:22:48 +00:00
|
|
|
} catch (const UniValue&) {
|
|
|
|
} catch (const std::runtime_error&) {
|
|
|
|
}
|
|
|
|
try {
|
2019-10-03 09:11:40 +00:00
|
|
|
(void)ParseHashV(univalue, random_string);
|
|
|
|
} catch (const UniValue&) {
|
|
|
|
} catch (const std::runtime_error&) {
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
(void)ParseHexO(univalue, "A");
|
2020-03-10 11:22:48 +00:00
|
|
|
} catch (const UniValue&) {
|
|
|
|
}
|
|
|
|
try {
|
2019-10-03 09:11:40 +00:00
|
|
|
(void)ParseHexO(univalue, random_string);
|
|
|
|
} catch (const UniValue&) {
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
(void)ParseHexUV(univalue, "A");
|
|
|
|
(void)ParseHexUV(univalue, random_string);
|
|
|
|
} catch (const UniValue&) {
|
|
|
|
} catch (const std::runtime_error&) {
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
(void)ParseHexV(univalue, "A");
|
2020-03-10 11:22:48 +00:00
|
|
|
} catch (const UniValue&) {
|
|
|
|
} catch (const std::runtime_error&) {
|
|
|
|
}
|
|
|
|
try {
|
2019-10-03 09:11:40 +00:00
|
|
|
(void)ParseHexV(univalue, random_string);
|
|
|
|
} catch (const UniValue&) {
|
|
|
|
} catch (const std::runtime_error&) {
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
(void)ParseSighashString(univalue);
|
|
|
|
} catch (const std::runtime_error&) {
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
(void)AmountFromValue(univalue);
|
|
|
|
} catch (const UniValue&) {
|
|
|
|
} catch (const std::runtime_error&) {
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
FlatSigningProvider provider;
|
|
|
|
(void)EvalDescriptorStringOrObject(univalue, provider);
|
|
|
|
} catch (const UniValue&) {
|
|
|
|
} catch (const std::runtime_error&) {
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
(void)ParseConfirmTarget(univalue, std::numeric_limits<unsigned int>::max());
|
|
|
|
} catch (const UniValue&) {
|
|
|
|
} catch (const std::runtime_error&) {
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
(void)ParseDescriptorRange(univalue);
|
|
|
|
} catch (const UniValue&) {
|
|
|
|
} catch (const std::runtime_error&) {
|
|
|
|
}
|
|
|
|
}
|