Commit 82cc70b0 authored by Joe Orton's avatar Joe Orton
Browse files

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
parent 51ed65e6
Loading
Loading
Loading
Loading
+10 −5
Original line number Diff line number Diff line
@@ -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)