From 461930085da6d0f9e31ca854d6b7241085e333c9 Mon Sep 17 00:00:00 2001 From: German Service Network Date: Wed, 20 Aug 2025 12:59:14 +0200 Subject: [PATCH] Fix the missing new line character on JSON output for an invalid host warning --- ci/test-16-json-output.pl | 2 +- src/fping.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ci/test-16-json-output.pl b/ci/test-16-json-output.pl index bcf159d..d3b8d65 100644 --- a/ci/test-16-json-output.pl +++ b/ci/test-16-json-output.pl @@ -153,7 +153,7 @@ $cmd->stderr_is_eq(""); { my $cmd = Test::Command->new(cmd => "fping -J -c 1 -q host.invalid"); $cmd->exit_is_num(2); # Exit code 2 indicates name resolution error -$cmd->stdout_like(qr/^\{"warning":\s\{"host":\s"host\.invalid",\s"message":\s"(?:Name or service not known|Temporary failure in name resolution|nodename nor servname provided, or not known)"\}\}$/); +$cmd->stdout_like(qr/^\{"warning":\s\{"host":\s"host\.invalid",\s"message":\s"(?:Name or service not known|Temporary failure in name resolution|nodename nor servname provided, or not known)"\}\}\n$/); $cmd->stderr_is_eq(""); } diff --git a/src/fping.c b/src/fping.c index dcffd17..e359d56 100644 --- a/src/fping.c +++ b/src/fping.c @@ -3326,7 +3326,7 @@ void add_name(char *name) // Handle JSON output for invalid hosts if (json_flag) { - fprintf(stdout, "{\"warning\": {\"host\": \"%s\", \"message\": \"%s\"}}", name, gai_strerror(ret_ga)); + fprintf(stdout, "{\"warning\": {\"host\": \"%s\", \"message\": \"%s\"}}\n", name, gai_strerror(ret_ga)); return; } -- 2.43.0