Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cli: accept long path #5883

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
cli: accepts long paths as options
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
commit ae138b2faf74023004658b4628a66b9c5e6b3f20
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