From 47a7b4a55b347bc55eeabd14995573d0e00510cb Mon Sep 17 00:00:00 2001 From: pn Date: Mon, 2 May 2022 17:02:03 +0200 Subject: [PATCH] log: Add termination to prefix log --- lightningd/log.c | 3 ++- lightningd/options.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lightningd/log.c b/lightningd/log.c index 3b4df6a1c..e6e968275 100644 --- a/lightningd/log.c +++ b/lightningd/log.c @@ -614,7 +614,8 @@ static char *arg_log_prefix(const char *arg, struct log *log) static void show_log_prefix(char buf[OPT_SHOW_LEN], const struct log *log) { - strncpy(buf, log->prefix->prefix, OPT_SHOW_LEN); + strncpy(buf, log->prefix->prefix, OPT_SHOW_LEN - 1); + buf[OPT_SHOW_LEN - 1] = '\0'; } static int signalfds[2]; diff --git a/lightningd/options.c b/lightningd/options.c index 34e6f6db4..6c22c4c5f 100644 --- a/lightningd/options.c +++ b/lightningd/options.c @@ -1537,8 +1537,8 @@ static void add_config(struct lightningd *ld, if (opt->desc == opt_hidden) { /* Ignore hidden options (deprecated) */ } else if (opt->show) { - strcpy(buf + OPT_SHOW_LEN, "..."); opt->show(buf, opt->u.carg); + strcpy(buf + OPT_SHOW_LEN - 1, "..."); if (streq(buf, "true") || streq(buf, "false") || strspn(buf, "0123456789.") == strlen(buf)) {