From 503360143ad9ed91b127d488a95bf7747f725db3 Mon Sep 17 00:00:00 2001 From: Richard Bondi Date: Sun, 17 Feb 2019 14:44:10 -0600 Subject: [PATCH] fix crash with lightning charge and plugin opts (#2358) * fix crash with lightning charge and plugin opts --- lightningd/options.c | 3 ++- lightningd/plugin.c | 6 +----- lightningd/plugin.h | 12 ++++++++++++ 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/lightningd/options.c b/lightningd/options.c index 90b4786ae..7cf99accb 100644 --- a/lightningd/options.c +++ b/lightningd/options.c @@ -1027,7 +1027,8 @@ static void add_config(struct lightningd *ld, } else if (opt->cb_arg == (void *)opt_add_plugin) { json_add_opt_plugins(response, ld->plugins); } else if (opt->cb_arg == (void *)opt_add_plugin_dir - || opt->cb_arg == (void *)opt_disable_plugin) { + || opt->cb_arg == (void *)opt_disable_plugin + || opt->cb_arg == (void *)plugin_opt_set) { /* FIXME: We actually treat it as if they specified * --plugin for each one, so ignore these */ #if DEVELOPER diff --git a/lightningd/plugin.c b/lightningd/plugin.c index cd352e9e7..affb27507 100644 --- a/lightningd/plugin.c +++ b/lightningd/plugin.c @@ -81,8 +81,6 @@ struct plugins { struct lightningd *ld; }; -/* Simple storage for plugin options inbetween registering them on the - * command line and passing them off to the plugin */ struct plugin_opt { struct list_node list; const char *name; @@ -463,9 +461,7 @@ static struct io_plan *plugin_stdout_conn_init(struct io_conn *conn, plugin_read_json, plugin); } -/* Callback called when parsing options. It just stores the value in - * the plugin_opt */ -static char *plugin_opt_set(const char *arg, struct plugin_opt *popt) +char *plugin_opt_set(const char *arg, struct plugin_opt *popt) { tal_free(popt->value); popt->value = tal_strdup(popt, arg); diff --git a/lightningd/plugin.h b/lightningd/plugin.h index c9407b366..47b118786 100644 --- a/lightningd/plugin.h +++ b/lightningd/plugin.h @@ -18,6 +18,12 @@ struct plugins; */ struct plugin; +/** + * Simple storage for plugin options inbetween registering them on the + * command line and passing them off to the plugin + */ +struct plugin_opt; + /** * Create a new plugins context. */ @@ -93,4 +99,10 @@ void plugins_notify(struct plugins *plugins, void plugin_request_send(struct plugin *plugin, struct jsonrpc_request *req TAKES); +/** + * Callback called when parsing options. It just stores the value in + * the plugin_opt + */ +char *plugin_opt_set(const char *arg, struct plugin_opt *popt); + #endif /* LIGHTNING_LIGHTNINGD_PLUGIN_H */