diff options
author | Sadie Powell <sadie@witchery.services> | 2025-02-25 23:13:54 +0000 |
---|---|---|
committer | Sadie Powell <sadie@witchery.services> | 2025-02-25 23:13:54 +0000 |
commit | 752f5e269e99acdd0c2795a2c2eedc44875d5fed (patch) | |
tree | b4b4ef22c9b5d8407612887b89051f9270f7c780 /modules/rpc/jsonrpc.cpp | |
parent | bb3e124bdb07cc12d51a0483b6cf913e4af58b8a (diff) |
Deduplicate RPC parameter count checks.
Diffstat (limited to 'modules/rpc/jsonrpc.cpp')
-rw-r--r-- | modules/rpc/jsonrpc.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/modules/rpc/jsonrpc.cpp b/modules/rpc/jsonrpc.cpp index fc4c40e83..1e7315984 100644 --- a/modules/rpc/jsonrpc.cpp +++ b/modules/rpc/jsonrpc.cpp @@ -150,7 +150,16 @@ public: return true; } - if (!event->second->Run(this, client, request)) + auto *eh = event->second; + if (request.data.size() < eh->GetMinParams()) + { + auto error = Anope::printf("Not enough parameters (given %zu, expected %zu)", + request.data.size(), eh->GetMinParams()); + SendError(reply, RPC::ERR_INVALID_PARAMS, error, id); + return true; + } + + if (!eh->Run(this, client, request)) return false; this->Reply(request); |