From b624c530515b3966ae08b740eac35bbec19da5de Mon Sep 17 00:00:00 2001 From: Vincenzo Palazzo Date: Sat, 25 Jun 2022 23:44:02 +0000 Subject: [PATCH] plugin: add check on the type json object during the IO message handling --- lightningd/plugin.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lightningd/plugin.c b/lightningd/plugin.c index 07bb6fa01..9dcbd3aac 100644 --- a/lightningd/plugin.c +++ b/lightningd/plugin.c @@ -643,6 +643,11 @@ static const char *plugin_read_json_one(struct plugin *plugin, return NULL; } + if (plugin->toks->type != JSMN_OBJECT) + return tal_fmt( + plugin, + "JSON-RPC message is not a valid JSON object type"); + jrtok = json_get_member(plugin->buffer, plugin->toks, "jsonrpc"); idtok = json_get_member(plugin->buffer, plugin->toks, "id");