From: Martin Kraemer Date: Sun, 6 Jul 2003 17:52:27 +0000 (+0000) Subject: Backport ab NULL-pointer issue fix from apache-2.1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d66f2a0e928b2e7ccfaa2cfffd796a0b2e341fb8;p=thirdparty%2Fapache%2Fhttpd.git Backport ab NULL-pointer issue fix from apache-2.1 git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/1.3.x@100465 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/CHANGES b/src/CHANGES index 8892e0c1557..63b9db884ff 100644 --- a/src/CHANGES +++ b/src/CHANGES @@ -1,5 +1,8 @@ Changes with Apache 1.3.28 + *) Fix NULL-pointer issue in ab when parsing an incomplete or non-HTTP + response. PR 21085. [Glenn Nielsen , André Malo] + *) Removed BIND_NOSTART from HP/UX shl_load() logic for loadable Apache modules, so that statics are initialized when the module is loaded (especially critical for c++ modules on HPUX.) diff --git a/src/support/ab.c b/src/support/ab.c index 1b318a7497d..3e2cbda4684 100644 --- a/src/support/ab.c +++ b/src/support/ab.c @@ -1098,8 +1098,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) @@ -1352,14 +1358,14 @@ static void test(void) static void copyright(void) { if (!use_html) { - printf("This is ApacheBench, Version %s\n", VERSION " <$Revision: 1.68 $> apache-1.3"); + printf("This is ApacheBench, Version %s\n", VERSION " <$Revision: 1.69 $> apache-1.3"); 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-1.3
\n", VERSION, "$Revision: 1.68 $"); + printf(" This is ApacheBench, Version %s <%s> apache-1.3
\n", VERSION, "$Revision: 1.69 $"); 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");