From 5a0e7ca5d058f71b72ff296cd51f15eaddb3ad60 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Fri, 10 Jun 2022 09:21:22 +0200 Subject: [PATCH] BUG/MINOR: cli/stats: add missing trailing LF after JSON outputs Patrick Hemmer reported that we have a bug in the CLI commands "show stat json" and "show schema json" in that they forget the trailing LF that's required to mark the end of the response. This has been the case since the introduction of the feature in 1.8-dev1 by commit 6f6bb380e ("MEDIUM: stats: Add show json schema"), so this fix may be backported to all versions. --- src/stats.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/stats.c b/src/stats.c index dc9b040ffa..f9a520a868 100644 --- a/src/stats.c +++ b/src/stats.c @@ -3667,7 +3667,7 @@ static void stats_dump_json_header() */ static void stats_dump_json_end() { - chunk_strcat(&trash, "]"); + chunk_strcat(&trash, "]\n"); } /* Uses as a pointer to the current proxy and as @@ -4779,6 +4779,7 @@ static void stats_dump_json_schema(struct buffer *out) chunk_appendf(out, "{\"errorStr\":\"output buffer too short\"}"); } + chunk_appendf(out, "\n"); } /* This function dumps the schema onto the stream connector's read buffer. -- 2.39.5