mirror of
https://github.com/apache/httpd.git
synced 2025-08-15 23:27:39 +00:00
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
This commit is contained in:
15
support/ab.c
15
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)
|
||||
|
Reference in New Issue
Block a user