From 5a06f972b1fd64f3da46187edf4998af0266a53b Mon Sep 17 00:00:00 2001 From: Jamie Cameron Date: Tue, 5 Sep 2017 10:35:44 -0700 Subject: [PATCH] Escape potentially malicious HTTP headers CVE: CVE-2017-15644 CVE-2017-15645 CVE-2017-15646 Upstream-Status: Backport [https://github.com/webmin/webmin/commit/0c58892732ee7610a7abba5507614366d382c9c9] Signed-off-by: Gyorgy Sarvari --- web-lib-funcs.pl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/web-lib-funcs.pl b/web-lib-funcs.pl index 1fcd96ab..df673bb7 100755 --- a/web-lib-funcs.pl +++ b/web-lib-funcs.pl @@ -2308,7 +2308,7 @@ alarm(0); $h = $main::download_timed_out if ($main::download_timed_out); if (!ref($h)) { if ($error) { $$error = $h; return; } - else { &error($h); } + else { &error(&html_escape($h)); } } &complete_http_download($h, $dest, $error, $cbfunc, $osdn, $host, $port, $headers, $ssl, $nocache); @@ -2336,7 +2336,7 @@ if ($line !~ /^HTTP\/1\..\s+(200|30[0-9]|400)(\s+|$)/) { alarm(0); &close_http_connection($_[0]); if ($_[2]) { ${$_[2]} = $line; return; } - else { &error("Download failed : $line"); } + else { &error("Download failed : ".&html_escape($line)); } } my $rcode = $1; &$cbfunc(1, $rcode >= 300 && $rcode < 400 ? 1 : 0) @@ -2382,7 +2382,7 @@ if ($rcode >= 300 && $rcode < 400) { # Assume relative to same dir .. not handled &close_http_connection($_[0]); if ($_[2]) { ${$_[2]} = "Invalid Location header $header{'location'}"; return; } - else { &error("Invalid Location header $header{'location'}"); } + else { &error("Invalid Location header ".&html_escape($header{'location'})); } } else { &close_http_connection($_[0]); @@ -2411,7 +2411,7 @@ else { if (!&open_tempfile(PFILE, ">$_[1]", 1)) { &close_http_connection($_[0]); if ($_[2]) { ${$_[2]} = "Failed to write to $_[1] : $!"; return; } - else { &error("Failed to write to $_[1] : $!"); } + else { &error("Failed to write to ".&html_escape($_[1])." : ".&html_escape("$!")); } } binmode(PFILE); # For windows while(defined($buf = &read_http_connection($_[0], 1024))) {