Skip to content

Commit

Permalink
cli: accepts long paths as options
Browse files Browse the repository at this point in the history
This allows to accept safely long paths as options
and does not truncate them
as #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>
  • Loading branch information
vincenzopalazzo committed Feb 6, 2023
1 parent d06c187 commit ae138b2
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions lightningd/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -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, "...");
Expand All @@ -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)) {
Expand Down

0 comments on commit ae138b2

Please sign in to comment.