From: Madhusudan Mathihalli Date: Wed, 17 Mar 2004 18:22:35 +0000 (+0000) Subject: Limit the concurrency to MAX_CONCURRENCY. X-Git-Tag: pre_ajp_proxy~503 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=87d5e2ed2b1d9d86366f0ff655fe215331200708;p=apache Limit the concurrency to MAX_CONCURRENCY. Otherwise, ab may dump core (calloc fails) when a arbitrarily huge value is used. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@103011 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/support/ab.c b/support/ab.c index d30e1aca74..296ac6eced 100644 --- a/support/ab.c +++ b/support/ab.c @@ -245,6 +245,7 @@ struct data { #define ap_min(a,b) ((a)<(b))?(a):(b) #define ap_max(a,b) ((a)>(b))?(a):(b) +#define MAX_CONCURRENCY 20000 /* --------------------- GLOBALS ---------------------------- */ @@ -1785,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.139 $> apache-2.0"); + printf("This is ApacheBench, Version %s\n", AP_AB_BASEREVISION " <$Revision: 1.140 $> 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.139 $"); + printf(" This is ApacheBench, Version %s <%s> apache-2.0
\n", AP_AB_BASEREVISION, "$Revision: 1.140 $"); 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"); @@ -2158,6 +2159,11 @@ int main(int argc, const char * const argv[]) usage(argv[0]); } + if ((concurrency < 0) || (concurrency > MAX_CONCURRENCY)) { + fprintf(stderr, "%s: Invalid Concurrency [Range 0..%d]\n", + argv[0], MAX_CONCURRENCY); + usage(argv[0]; + } if ((heartbeatres) && (requests > 150)) { heartbeatres = requests / 10; /* Print line every 10% of requests */