]> granicus.if.org Git - apache/commitdiff
Limit the concurrency to MAX_CONCURRENCY.
authorMadhusudan Mathihalli <madhum@apache.org>
Wed, 17 Mar 2004 18:22:35 +0000 (18:22 +0000)
committerMadhusudan Mathihalli <madhum@apache.org>
Wed, 17 Mar 2004 18:22:35 +0000 (18:22 +0000)
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

support/ab.c

index d30e1aca74b1dbd1faf4cb7c222ba592bb776fdf..296ac6eced0f1732a065cb4084ad933f06c1054b 100644 (file)
@@ -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("<p>\n");
-       printf(" This is ApacheBench, Version %s <i>&lt;%s&gt;</i> apache-2.0<br>\n", AP_AB_BASEREVISION, "$Revision: 1.139 $");
+       printf(" This is ApacheBench, Version %s <i>&lt;%s&gt;</i> apache-2.0<br>\n", AP_AB_BASEREVISION, "$Revision: 1.140 $");
        printf(" Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/<br>\n");
        printf(" Copyright (c) 1998-2002 The Apache Software Foundation, http://www.apache.org/<br>\n");
        printf("</p>\n<p>\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 */