Hi all,

I get segmentation fault when HTTP server returns malformed status line
(without a status code). Use the following command to reproduce the issue:
`wget vminko.org:8081/test`
Wget crashes because the HTTP daemon returns just "HTTP/1.0\n\n" (see wget-test.pl).
The proposed fix is attached (wget-1.12-http-status-line.patch).

Best regards,
Vitaly
#!/usr/bin/perl

use HTTP::Daemon;
use HTTP::Status;

my $d = HTTP::Daemon->new(LocalAddr => 'vminko.org', LocalPort => 8081) || die;
while (my $c = $d->accept) {
        $r = $c->get_request;
        $c->print("HTTP/1.0\n\n") if ($r);
        $c->close;
        undef($c);
}

diff -ur wget-1.12/src/http.c wget-1.12.patched/src/http.c
--- wget-1.12/src/http.c        2009-09-22 07:02:18.000000000 +0400
+++ wget-1.12.patched/src/http.c        2011-04-09 18:05:53.853334621 +0400
@@ -1829,7 +1829,8 @@
   /* Check for status line.  */
   message = NULL;
   statcode = resp_status (resp, &message);
-  hs->message = xstrdup (message);
+  if (statcode != -1)
+    hs->message = xstrdup (message);
   if (!opt.server_response)
     logprintf (LOG_VERBOSE, "%2d %s\n", statcode,
                message ? quotearg_style (escape_quoting_style, message) : "");

Reply via email to