]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: cli/stats: add missing trailing LF after JSON outputs
authorWilly Tarreau <w@1wt.eu>
Fri, 10 Jun 2022 07:21:22 +0000 (09:21 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 10 Jun 2022 07:23:44 +0000 (09:23 +0200)
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

index dc9b040ffa39da9050ada58bdfa93c0d47c9499a..f9a520a8683e59794929f2e8fa0b9bb2c9f3546d 100644 (file)
@@ -3667,7 +3667,7 @@ static void stats_dump_json_header()
  */
 static void stats_dump_json_end()
 {
-       chunk_strcat(&trash, "]");
+       chunk_strcat(&trash, "]\n");
 }
 
 /* Uses <appctx.ctx.stats.obj1> as a pointer to the current proxy and <obj2> 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.