From 8369ca71b109f56290e6a6eb2e0cbd0ad7621407 Mon Sep 17 00:00:00 2001 From: Vincenzo Palazzo Date: Mon, 6 Feb 2023 09:35:36 +0100 Subject: [PATCH] cli: accepts long paths as options This allows to accept safely long paths as options and does not truncate them as https://github.com/ElementsProject/lightning/issues/5576 described Changelog-Fixed: cli: accepts long paths as options Suggested-by: @rustyrussell Signed-off-by: Vincenzo Palazzo --- lightningd/options.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/lightningd/options.c b/lightningd/options.c index a6f4bdc20fde..0928897f02e7 100644 --- a/lightningd/options.c +++ b/lightningd/options.c @@ -1644,6 +1644,9 @@ static void add_config(struct lightningd *ld, } else if (opt->type & OPT_HASARG) { if (opt->desc == opt_hidden) { /* Ignore hidden options (deprecated) */ + } else if (opt->show == (void *)opt_show_charp) { + /* Don't truncate! */ + answer = tal_strdup(tmpctx, *(char **)opt->u.carg); } else if (opt->show) { opt->show(buf, opt->u.carg); strcpy(buf + OPT_SHOW_LEN - 1, "..."); @@ -1655,14 +1658,7 @@ static void add_config(struct lightningd *ld, json_add_primitive(response, name0, buf); return; } - - /* opt_show_charp surrounds with "", strip them */ - if (strstarts(buf, "\"")) { - char *end = strrchr(buf, '"'); - memmove(end, end + 1, strlen(end)); - answer = buf + 1; - } else - answer = buf; + answer = buf; } else if (opt->cb_arg == (void *)opt_set_talstr || opt->cb_arg == (void *)opt_set_charp || is_restricted_print_if_nonnull(opt->cb_arg)) {