refactor: Add sanity checks in LabelFromValue

This commit is contained in:
Aurèle Oulès
2022-12-15 11:02:32 +01:00
parent 67e7ba8e1a
commit 552b51e682
4 changed files with 15 additions and 23 deletions

View File

@@ -132,7 +132,10 @@ const LegacyScriptPubKeyMan& EnsureConstLegacyScriptPubKeyMan(const CWallet& wal
std::string LabelFromValue(const UniValue& value)
{
std::string label = value.get_str();
static const std::string empty_string;
if (value.isNull()) return empty_string;
const std::string& label{value.get_str()};
if (label == "*")
throw JSONRPCError(RPC_WALLET_INVALID_LABEL_NAME, "Invalid label name");
return label;