diff options
author | MarcoFalke <falke.marco@gmail.com> | 2021-12-13 17:13:28 +0100 |
---|---|---|
committer | MarcoFalke <falke.marco@gmail.com> | 2021-12-13 17:13:42 +0100 |
commit | 5dd28e5cff8a8177b969181ecb58d045e7f80a72 (patch) | |
tree | 45b932286cb547067a028872ef8ba2d9150248b7 /src | |
parent | 42796742a45e3f12e82588afa77054c103fca05c (diff) | |
parent | fa24a3df8796cbf4eeb35d950a4c848d605e5b22 (diff) | |
download | bitcoin-5dd28e5cff8a8177b969181ecb58d045e7f80a72.tar.xz |
Merge bitcoin/bitcoin#23755: rpc: Quote user supplied strings in error messages
fa24a3df8796cbf4eeb35d950a4c848d605e5b22 rpc: Quote user supplied strings in error messages (MarcoFalke)
Pull request description:
I can't see a downside doing this and this fixes a fuzzing crash
Background:
This is a follow-up to commit 926fc2a0d4ff64cf2ff8e1dfa64eca2ebd24e090, which introduced the "starts_with-hack". Maybe an alternative to the hack would be to assign a unique error code to internal bugs? However, I think this can be done in an separate pull request and the changes here make sense even on their own.
ACKs for top commit:
fanquake:
ACK fa24a3df8796cbf4eeb35d950a4c848d605e5b22 - to fix the fuzzers.
Tree-SHA512: d998626406a64396a037a6d1fce22fce3dadb7567c2f9638e450ebe8fb8ae77d134e15dd02555326732208f698d77b0028bc62be9ceee9c43282b61fe95fccbd
Diffstat (limited to 'src')
-rw-r--r-- | src/rpc/blockchain.cpp | 4 | ||||
-rw-r--r-- | src/rpc/util.cpp | 2 |
2 files changed, 3 insertions, 3 deletions
diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 7b37635db0..050d9dd980 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -1134,7 +1134,7 @@ CoinStatsHashType ParseHashType(const std::string& hash_type_input) } else if (hash_type_input == "none") { return CoinStatsHashType::NONE; } else { - throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("%s is not a valid hash_type", hash_type_input)); + throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("'%s' is not a valid hash_type", hash_type_input)); } } @@ -2213,7 +2213,7 @@ static RPCHelpMan getblockstats() for (const std::string& stat : stats) { const UniValue& value = ret_all[stat]; if (value.isNull()) { - throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Invalid selected statistic %s", stat)); + throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Invalid selected statistic '%s'", stat)); } ret.pushKV(stat, value); } diff --git a/src/rpc/util.cpp b/src/rpc/util.cpp index 4a5cd0a4be..57e3da0351 100644 --- a/src/rpc/util.cpp +++ b/src/rpc/util.cpp @@ -210,7 +210,7 @@ CPubKey AddrToPubKey(const FillableSigningProvider& keystore, const std::string& } CKeyID key = GetKeyForDestination(keystore, dest); if (key.IsNull()) { - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, strprintf("%s does not refer to a key", addr_in)); + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, strprintf("'%s' does not refer to a key", addr_in)); } CPubKey vchPubKey; if (!keystore.GetPubKey(key, vchPubKey)) { |