From: Willy Tarreau Date: Fri, 10 Jun 2022 13:12:21 +0000 (+0200) Subject: BUG/MINOR: cli/stats: add missing trailing LF after "show info json" X-Git-Tag: v2.7-dev1~70 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c6b7a97e5465e0d220ff5555cd88bab7bc5e4f5c;p=thirdparty%2Fhaproxy.git BUG/MINOR: cli/stats: add missing trailing LF after "show info json" This is the continuation of commit 5a0e7ca5d ("BUG/MINOR: cli/stats: add missing trailing LF after JSON outputs"). There's also a "show info json" command which was also missing the trailing LF. It's constructed exactly like the "show stat json", in that it dumps a series of fields without any LF. The difference however is that for the stats output, everything was enclosed in an array which required an LF *after* the closing bracket, while here there's no such array so we have to emit the LF after the loop. That makes the two functions a bit inconsistent, it's quite annoying, but making them better would require sending one LF per line in the stats output, which is not particularly interesting. Given that it took 5+ years to spot that this code wasn't working as expected it doesn't seem worth investing much time trying to refactor it to make it look cleaner at the risk of breaking other obscure parts. --- diff --git a/src/stats.c b/src/stats.c index f9a520a868..fdbca00655 100644 --- a/src/stats.c +++ b/src/stats.c @@ -691,13 +691,13 @@ static int stats_dump_json_info_fields(struct buffer *out, goto err; } - if (!chunk_strcat(out, "]")) + if (!chunk_strcat(out, "]\n")) goto err; return 1; err: chunk_reset(out); - chunk_appendf(out, "{\"errorStr\":\"output buffer too short\"}"); + chunk_appendf(out, "{\"errorStr\":\"output buffer too short\"}\n"); return 0; }