plugin: Prevent plugins from registering native notification topics

They may already have subscribers, and they may crash if presented
with a malformed notification.
This commit is contained in:
Christian Decker
2021-04-28 15:58:46 +02:00
committed by Rusty Russell
parent f716c55983
commit c8c2c33952
3 changed files with 19 additions and 2 deletions

View File

@@ -1327,6 +1327,14 @@ static const char *plugin_notifications_add(const char *buffer,
i);
name = json_strdup(plugin->plugins, buffer, method);
if (notifications_topic_is_native(name))
return tal_fmt(plugin,
"plugin attempted to register a native "
"notification topic \"%s\", these may "
"however only be sent by lightningd",
name);
tal_arr_expand(&plugin->plugins->notification_topics, name);
}