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 <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2023-01-04 14:12:47 +10:30 committed by Michael Schmoock
parent 87a0cb1603
commit a6db22ece2

View file

@ -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. */