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 <rusty@rustcorp.com.au>
Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
This commit is contained in:
Vincenzo Palazzo 2023-02-06 09:35:36 +01:00 committed by Rusty Russell
parent 59ed23e6cf
commit 8369ca71b1

View file

@ -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)) {