From a6db22ece213038ff7d7bc5177ff773f458c8ec5 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Wed, 4 Jan 2023 14:12:47 +1030 Subject: [PATCH] cli: fix buffer overflow in (currently unused!) code for progress bars. It's only used in the test framework. Reported-by: @cdecker Signed-off-by: Rusty Russell --- cli/lightning-cli.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/lightning-cli.c b/cli/lightning-cli.c index a213665ea..517283584 100644 --- a/cli/lightning-cli.c +++ b/cli/lightning-cli.c @@ -544,7 +544,7 @@ static bool handle_notify(const char *buf, jsmntok_t *toks, snprintf(totstr, sizeof(totstr), "%u", tot); printf("%*u/%s ", (int)strlen(totstr), n+1, totstr); memset(bar, ' ', sizeof(bar)-1); - memset(bar, '=', (double)strlen(bar) / (tot-1) * n); + memset(bar, '=', (double)(sizeof(bar)-1) / (tot-1) * n); bar[sizeof(bar)-1] = '\0'; printf("|%s|", bar); /* Leave bar there if it's finished. */