Skip to content

Commit

Permalink
lightningd/plugin: fix read-after-free on plugin options
Browse files Browse the repository at this point in the history
Thanks sanity checks ! :p
  • Loading branch information
darosior committed Feb 2, 2020
1 parent f48d24f commit fc74bef
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lightningd/plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -524,8 +524,13 @@ static bool plugin_opt_add(struct plugin *plugin, const char *buffer,
if (!defaulttok)
popt->description = json_strdup(popt, buffer, desctok);
list_add_tail(&plugin->plugin_opts, &popt->list);
opt_register_arg(popt->name, plugin_opt_set, NULL, popt,
popt->description);
/* We duplicate the name, as popt->name will be freed if we
* 'plugin stop' this plugin but it won't be removed from the global
* opt_table ! We could end up reading after free (json_listconfigs).
* FIXME: Cleaner to allow to unregister an option ? */
opt_register_arg(tal_strdup(plugin->plugins, popt->name),
plugin_opt_set, NULL, popt,
popt->description);
return true;
}

Expand Down

0 comments on commit fc74bef

Please sign in to comment.