From: André Malo Date: Sun, 29 Jun 2003 17:41:56 +0000 (+0000) Subject: Fix NULL-pointer issue in ab when parsing an incomplete or non-HTTP X-Git-Tag: pre_ajp_proxy~1497 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=dbdd2df050df37133888cb61eebc416e76a4d88f;p=apache Fix NULL-pointer issue in ab when parsing an incomplete or non-HTTP response. PR: 21085 Submitted by: Glenn Nielsen git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@100399 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/CHANGES b/CHANGES index 08df847a11..8eeaf1b0d1 100644 --- a/CHANGES +++ b/CHANGES @@ -2,6 +2,9 @@ Changes with Apache 2.1.0-dev [Remove entries to the current 2.0 section below, when backported] + *) Fix NULL-pointer issue in ab when parsing an incomplete or non-HTTP + response. PR 21085. [Glenn Nielsen , André Malo] + *) Added FreeBSD directory layout. PR 21100. [Sander Holthaus , André Malo] diff --git a/support/ab.c b/support/ab.c index 670ca7ad4a..2af5d16f34 100644 --- a/support/ab.c +++ b/support/ab.c @@ -1484,8 +1484,14 @@ static void read_connection(struct connection * c) /* check response code */ part = strstr(c->cbuff, "HTTP"); /* really HTTP/1.x_ */ - strncpy(respcode, (part + strlen("HTTP/1.x_")), 3); - respcode[3] = '\0'; + if (part && strlen(part) > strlen("HTTP/1.x_")) { + strncpy(respcode, (part + strlen("HTTP/1.x_")), 3); + respcode[3] = '\0'; + } + else { + strcpy(respcode, "500"); + } + if (respcode[0] != '2') { err_response++; if (verbosity >= 2) @@ -1780,14 +1786,14 @@ static void test(void) static void copyright(void) { if (!use_html) { - printf("This is ApacheBench, Version %s\n", AP_AB_BASEREVISION " <$Revision: 1.123 $> apache-2.0"); + printf("This is ApacheBench, Version %s\n", AP_AB_BASEREVISION " <$Revision: 1.124 $> apache-2.0"); printf("Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/\n"); printf("Copyright (c) 1998-2002 The Apache Software Foundation, http://www.apache.org/\n"); printf("\n"); } else { printf("

\n"); - printf(" This is ApacheBench, Version %s <%s> apache-2.0
\n", AP_AB_BASEREVISION, "$Revision: 1.123 $"); + printf(" This is ApacheBench, Version %s <%s> apache-2.0
\n", AP_AB_BASEREVISION, "$Revision: 1.124 $"); printf(" Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
\n"); printf(" Copyright (c) 1998-2002 The Apache Software Foundation, http://www.apache.org/
\n"); printf("

\n

\n");