summaryrefslogtreecommitdiffstats
path: root/support
diff options
context:
space:
mode:
authorJoe Orton <jorton@apache.org>2005-04-15 12:51:44 +0200
committerJoe Orton <jorton@apache.org>2005-04-15 12:51:44 +0200
commit4800ec9ba7f3cbd02b9b99382c86724944bf5ccf (patch)
tree350b730837f5e2f0259da67d57bfb2f3534057d1 /support
parentIgnore generated config files. (diff)
downloadapache2-4800ec9ba7f3cbd02b9b99382c86724944bf5ccf.tar.xz
apache2-4800ec9ba7f3cbd02b9b99382c86724944bf5ccf.zip
Fix and prevent some segfaults in ab:
* support/ab.c (main): Fail if given concurrency level greater than number of requests, to prevent segfaults later. (ssl_print_cert_info): Use the correct buffer size. (ssl_start_connect): SSL_get_peer_cert_chain doesn't bump refcounts, so don't free the cert chain here. (test): Use both calloc parameters (unrelated cleanup). git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@161437 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'support')
-rw-r--r--support/ab.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/support/ab.c b/support/ab.c
index 03face7d24..a6c03de672 100644
--- a/support/ab.c
+++ b/support/ab.c
@@ -545,11 +545,11 @@ static int ssl_print_cert_info(BIO *bio, X509 *x509cert)
EVP_PKEY_bits(X509_get_pubkey(x509cert)));
dn=X509_get_issuer_name(x509cert);
- X509_NAME_oneline(dn, buf, BUFSIZ);
+ X509_NAME_oneline(dn, buf, sizeof buf);
BIO_printf(bio,"The issuer name is %s\n", buf);
dn=X509_get_subject_name(x509cert);
- X509_NAME_oneline(dn, buf, BUFSIZ);
+ X509_NAME_oneline(dn, buf, sizeof buf);
BIO_printf(bio,"The subject name is %s\n", buf);
/* dump the extension list too */
@@ -665,7 +665,6 @@ static void ssl_start_connect(struct connection * c)
x509cert = (X509 *)sk_X509_value(sk,i);
#endif
ssl_print_cert_info(bio_out,x509cert);
- X509_free(x509cert);
}
}
@@ -1562,9 +1561,9 @@ static void test(void)
now = apr_time_now();
- con = calloc(concurrency * sizeof(struct connection), 1);
+ con = calloc(concurrency, sizeof(struct connection));
- stats = calloc(requests * sizeof(struct data), 1);
+ stats = calloc(requests, sizeof(struct data));
if ((status = apr_pollset_create(&readbits, concurrency, cntxt, 0)) != APR_SUCCESS) {
apr_err("apr_pollset_create failed", status);
@@ -2174,6 +2173,12 @@ int main(int argc, const char * const argv[])
usage(argv[0]);
}
+ if (concurrency > requests) {
+ fprintf(stderr, "%s: Cannot use concurrency level greater than "
+ "total number of requests\n", argv[0]);
+ usage(argv[0]);
+ }
+
if ((heartbeatres) && (requests > 150)) {
heartbeatres = requests / 10; /* Print line every 10% of requests */
if (heartbeatres < 100)