Skip to content

Commit

Permalink
fixup! RPC: Strictly enforce the type of parameters passed by name
Browse files Browse the repository at this point in the history
  • Loading branch information
luke-jr committed Nov 17, 2024
1 parent 645d041 commit ebbde4f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/rpc/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -932,15 +932,15 @@ UniValue RPCArg::MatchesType(const UniValue& request, const std::optional<std::s
do {
// If parameter was passed by name, only allow the specified type for
// that name. Otherwise allow any of the specified types.
if (param_name && i < m_names.size() && *param_name != names[i]) {
if (param_name && i < names.size() && *param_name != names[i]) {
continue;
}
const auto exp_type{ExpectedType(i < m_type_per_name.size() ? m_type_per_name[i] : m_type)};
if (!exp_type) return true; // nothing to check
if (*exp_type == request.getType()) {
return true;
}
} while (++i < m_names.size());
} while (++i < names.size());
return strprintf("JSON value of type %s is not of expected type %s", uvTypeName(request.getType()), uvTypeName(*ExpectedType(m_type)));
}

Expand Down

0 comments on commit ebbde4f

Please sign in to comment.