From adbac91be721055b506a60a69a8b74d7673e0549 Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Fri, 17 May 2024 21:27:59 -0400 Subject: [PATCH] header_ok: Only keep first line of argument This allows callers to pass the entire response without generating overly long error messages. --- ddclient.in | 1 + t/header_ok.pl | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/ddclient.in b/ddclient.in index 9af3867..a5b2800 100755 --- a/ddclient.in +++ b/ddclient.in @@ -3774,6 +3774,7 @@ sub nic_updateable { ###################################################################### sub header_ok { my ($host, $line) = @_; + $line =~ s/\r?\n.*//s; my $ok = 0; if ($line =~ m%^s*HTTP/.*\s+(\d+)%i) { diff --git a/t/header_ok.pl b/t/header_ok.pl index e835757..5797341 100644 --- a/t/header_ok.pl +++ b/t/header_ok.pl @@ -51,6 +51,12 @@ my @test_cases = ( input => 'HTTP/1.1 456 bad', want => 0, }, + { + desc => 'only first line is logged on error', + input => "HTTP/1.1 404 not found\n\nbody", + want => 0, + wantmsg => qr/(?!body)/, + }, ); for my $tc (@test_cases) {