apps/s_time.c:347: error: INTEGER_OVERFLOW_L2
  ([0, +oo] - 1):unsigned32 by call to `SSL_CTX_free`.
Showing all 14 steps of the trace


apps/s_time.c:346:5: Call
344.   
345.    end:
346.       SSL_free(scon);
           ^
347.       SSL_CTX_free(ctx);
348.       return ret;

ssl/ssl_lib.c:1138:1: Parameter `s->session_ctx->sessions->num_nodes`
  1136.   }
  1137.   
  1138. > void SSL_free(SSL *s)
  1139.   {
  1140.       int i;

apps/s_time.c:347:5: Call
345.    end:
346.       SSL_free(scon);
347.       SSL_CTX_free(ctx);
           ^
348.       return ret;
349.   }

ssl/ssl_lib.c:3163:1: Parameter `a->sessions->num_nodes`
  3161.   }
  3162.   
  3163. > void SSL_CTX_free(SSL_CTX *a)
  3164.   {
  3165.       int i;

ssl/ssl_lib.c:3189:9: Call
  3187.        */
  3188.       if (a->sessions != NULL)
  3189.           SSL_CTX_flush_sessions(a, 0);
                  ^
  3190.   
  3191.       CRYPTO_free_ex_data(CRYPTO_EX_INDEX_SSL_CTX, a, &a->ex_data);

ssl/ssl_sess.c:1106:1: Parameter `s->sessions->num_nodes`
    1104.   IMPLEMENT_LHASH_DOALL_ARG(SSL_SESSION, TIMEOUT_PARAM);
    1105.   
    1106. > void SSL_CTX_flush_sessions(SSL_CTX *s, long t)
    1107.   {
    1108.       unsigned long i;

ssl/ssl_sess.c:1119:5: Call
    1117.       i = lh_SSL_SESSION_get_down_load(s->sessions);
    1118.       lh_SSL_SESSION_set_down_load(s->sessions, 0);
    1119.       lh_SSL_SESSION_doall_TIMEOUT_PARAM(tp.cache, timeout_cb, &tp);
                ^
    1120.       lh_SSL_SESSION_set_down_load(s->sessions, i);
    1121.       CRYPTO_THREAD_unlock(s->lock);

ssl/ssl_sess.c:1104:1: Parameter `lh->num_nodes`
      1102.   }
      1103.   
      1104. > IMPLEMENT_LHASH_DOALL_ARG(SSL_SESSION, TIMEOUT_PARAM);
      1105.   
      1106.   void SSL_CTX_flush_sessions(SSL_CTX *s, long t)

ssl/ssl_sess.c:1104:1: Call
      1102.   }
      1103.   
      1104. > IMPLEMENT_LHASH_DOALL_ARG(SSL_SESSION, TIMEOUT_PARAM);
      1105.   
      1106.   void SSL_CTX_flush_sessions(SSL_CTX *s, long t)

crypto/lhash/lhash.c:218:1: Parameter `lh->num_nodes`
        216.   }
        217.   
        218. > void OPENSSL_LH_doall_arg(OPENSSL_LHASH *lh, OPENSSL_LH_DOALL_FUNCARG func, void *arg)
        219.   {
        220.       doall_util_fn(lh, 1, (OPENSSL_LH_DOALL_FUNC)0, func, arg);

crypto/lhash/lhash.c:220:5: Call
        218.   void OPENSSL_LH_doall_arg(OPENSSL_LHASH *lh, OPENSSL_LH_DOALL_FUNCARG func, void *arg)
        219.   {
        220.       doall_util_fn(lh, 1, (OPENSSL_LH_DOALL_FUNC)0, func, arg);
                   ^
        221.   }
        222.   

crypto/lhash/lhash.c:186:1: <LHS trace>
184.   }
185.   
186. > static void doall_util_fn(OPENSSL_LHASH *lh, int use_arg,
187.                             OPENSSL_LH_DOALL_FUNC func,
188.                             OPENSSL_LH_DOALL_FUNCARG func_arg, void *arg)

crypto/lhash/lhash.c:186:1: Parameter `lh->num_nodes`
          184.   }
          185.   
          186. > static void doall_util_fn(OPENSSL_LHASH *lh, int use_arg,
          187.                             OPENSSL_LH_DOALL_FUNC func,
          188.                             OPENSSL_LH_DOALL_FUNCARG func_arg, void *arg)

crypto/lhash/lhash.c:200:10: Binary operation: ([0, +oo] - 1):unsigned32 by call to `SSL_CTX_free` 
          198.        * memory leaks otherwise
          199.        */
          200.       for (i = lh->num_nodes - 1; i >= 0; i--) {
                          ^
          201.           a = lh->b[i];
          202.           while (a != NULL) {

static void doall_util_fn(OPENSSL_LHASH *lh, int use_arg,
                          OPENSSL_LH_DOALL_FUNC func,
                          OPENSSL_LH_DOALL_FUNCARG func_arg, void *arg)
{
    int i;
    OPENSSL_LH_NODE *a, *n;
    if (lh == NULL)
        return;
    for (i = lh->num_nodes - 1; i >= 0; i--) {
        a = lh->b[i];
        while (a != NULL) {
            n = a->next;
            if (use_arg)
                func_arg(a->data, arg);
            else
                func(a->data);
            a = n;
        }
    }
}
['int s_time_main(int argc, char **argv)\n{\n    char buf[1024 * 8];\n    SSL *scon = NULL;\n    SSL_CTX *ctx = NULL;\n    const SSL_METHOD *meth = NULL;\n    char *CApath = NULL, *CAfile = NULL, *cipher = NULL, *ciphersuites = NULL;\n    char *www_path = NULL;\n    char *host = SSL_CONNECT_NAME, *certfile = NULL, *keyfile = NULL, *prog;\n    double totalTime = 0.0;\n    int noCApath = 0, noCAfile = 0;\n    int maxtime = SECONDS, nConn = 0, perform = 3, ret = 1, i, st_bugs = 0;\n    long bytes_read = 0, finishtime = 0;\n    OPTION_CHOICE o;\n    int max_version = 0, ver, buf_len;\n    size_t buf_size;\n    meth = TLS_client_method();\n    prog = opt_init(argc, argv, s_time_options);\n    while ((o = opt_next()) != OPT_EOF) {\n        switch (o) {\n        case OPT_EOF:\n        case OPT_ERR:\n opthelp:\n            BIO_printf(bio_err, "%s: Use -help for summary.\\n", prog);\n            goto end;\n        case OPT_HELP:\n            opt_help(s_time_options);\n            ret = 0;\n            goto end;\n        case OPT_CONNECT:\n            host = opt_arg();\n            break;\n        case OPT_REUSE:\n            perform = 2;\n            break;\n        case OPT_NEW:\n            perform = 1;\n            break;\n        case OPT_VERIFY:\n            if (!opt_int(opt_arg(), &verify_args.depth))\n                goto opthelp;\n            BIO_printf(bio_err, "%s: verify depth is %d\\n",\n                       prog, verify_args.depth);\n            break;\n        case OPT_CERT:\n            certfile = opt_arg();\n            break;\n        case OPT_NAMEOPT:\n            if (!set_nameopt(opt_arg()))\n                goto end;\n            break;\n        case OPT_KEY:\n            keyfile = opt_arg();\n            break;\n        case OPT_CAPATH:\n            CApath = opt_arg();\n            break;\n        case OPT_CAFILE:\n            CAfile = opt_arg();\n            break;\n        case OPT_NOCAPATH:\n            noCApath = 1;\n            break;\n        case OPT_NOCAFILE:\n            noCAfile = 1;\n            break;\n        case OPT_CIPHER:\n            cipher = opt_arg();\n            break;\n        case OPT_CIPHERSUITES:\n            ciphersuites = opt_arg();\n            break;\n        case OPT_BUGS:\n            st_bugs = 1;\n            break;\n        case OPT_TIME:\n            if (!opt_int(opt_arg(), &maxtime))\n                goto opthelp;\n            break;\n        case OPT_WWW:\n            www_path = opt_arg();\n            buf_size = strlen(www_path) + fmt_http_get_cmd_size;\n            if (buf_size > sizeof(buf)) {\n                BIO_printf(bio_err, "%s: -www option is too long\\n", prog);\n                goto end;\n            }\n            break;\n        case OPT_SSL3:\n            max_version = SSL3_VERSION;\n            break;\n        }\n    }\n    argc = opt_num_rest();\n    if (argc != 0)\n        goto opthelp;\n    if (cipher == NULL)\n        cipher = getenv("SSL_CIPHER");\n    if ((ctx = SSL_CTX_new(meth)) == NULL)\n        goto end;\n    SSL_CTX_set_mode(ctx, SSL_MODE_AUTO_RETRY);\n    SSL_CTX_set_quiet_shutdown(ctx, 1);\n    if (SSL_CTX_set_max_proto_version(ctx, max_version) == 0)\n        goto end;\n    if (st_bugs)\n        SSL_CTX_set_options(ctx, SSL_OP_ALL);\n    if (cipher != NULL && !SSL_CTX_set_cipher_list(ctx, cipher))\n        goto end;\n    if (ciphersuites != NULL && !SSL_CTX_set_ciphersuites(ctx, ciphersuites))\n        goto end;\n    if (!set_cert_stuff(ctx, certfile, keyfile))\n        goto end;\n    if (!ctx_set_verify_locations(ctx, CAfile, CApath, noCAfile, noCApath)) {\n        ERR_print_errors(bio_err);\n        goto end;\n    }\n    if (!(perform & 1))\n        goto next;\n    printf("Collecting connection statistics for %d seconds\\n", maxtime);\n    bytes_read = 0;\n    finishtime = (long)time(NULL) + maxtime;\n    tm_Time_F(START);\n    for (;;) {\n        if (finishtime < (long)time(NULL))\n            break;\n        if ((scon = doConnection(NULL, host, ctx)) == NULL)\n            goto end;\n        if (www_path != NULL) {\n            buf_len = BIO_snprintf(buf, sizeof(buf), fmt_http_get_cmd,\n                                   www_path);\n            if (buf_len <= 0 || SSL_write(scon, buf, buf_len) <= 0)\n                goto end;\n            while ((i = SSL_read(scon, buf, sizeof(buf))) > 0)\n                bytes_read += i;\n        }\n        SSL_set_shutdown(scon, SSL_SENT_SHUTDOWN | SSL_RECEIVED_SHUTDOWN);\n        BIO_closesocket(SSL_get_fd(scon));\n        nConn += 1;\n        if (SSL_session_reused(scon)) {\n            ver = \'r\';\n        } else {\n            ver = SSL_version(scon);\n            if (ver == TLS1_VERSION)\n                ver = \'t\';\n            else if (ver == SSL3_VERSION)\n                ver = \'3\';\n            else\n                ver = \'*\';\n        }\n        fputc(ver, stdout);\n        fflush(stdout);\n        SSL_free(scon);\n        scon = NULL;\n    }\n    totalTime += tm_Time_F(STOP);\n    i = (int)((long)time(NULL) - finishtime + maxtime);\n    printf\n        ("\\n\\n%d connections in %.2fs; %.2f connections/user sec, bytes read %ld\\n",\n         nConn, totalTime, ((double)nConn / totalTime), bytes_read);\n    printf\n        ("%d connections in %ld real seconds, %ld bytes read per connection\\n",\n         nConn, (long)time(NULL) - finishtime + maxtime, bytes_read / nConn);\n next:\n    if (!(perform & 2))\n        goto end;\n    printf("\\n\\nNow timing with session id reuse.\\n");\n    if ((scon = doConnection(NULL, host, ctx)) == NULL) {\n        BIO_printf(bio_err, "Unable to get connection\\n");\n        goto end;\n    }\n    if (www_path != NULL) {\n        buf_len = BIO_snprintf(buf, sizeof(buf), fmt_http_get_cmd, www_path);\n        if (buf_len <= 0 || SSL_write(scon, buf, buf_len) <= 0)\n            goto end;\n        while ((i = SSL_read(scon, buf, sizeof(buf))) > 0)\n            continue;\n    }\n    SSL_set_shutdown(scon, SSL_SENT_SHUTDOWN | SSL_RECEIVED_SHUTDOWN);\n    BIO_closesocket(SSL_get_fd(scon));\n    nConn = 0;\n    totalTime = 0.0;\n    finishtime = (long)time(NULL) + maxtime;\n    printf("starting\\n");\n    bytes_read = 0;\n    tm_Time_F(START);\n    for (;;) {\n        if (finishtime < (long)time(NULL))\n            break;\n        if ((doConnection(scon, host, ctx)) == NULL)\n            goto end;\n        if (www_path != NULL) {\n            buf_len = BIO_snprintf(buf, sizeof(buf), fmt_http_get_cmd,\n                                   www_path);\n            if (buf_len <= 0 || SSL_write(scon, buf, buf_len) <= 0)\n                goto end;\n            while ((i = SSL_read(scon, buf, sizeof(buf))) > 0)\n                bytes_read += i;\n        }\n        SSL_set_shutdown(scon, SSL_SENT_SHUTDOWN | SSL_RECEIVED_SHUTDOWN);\n        BIO_closesocket(SSL_get_fd(scon));\n        nConn += 1;\n        if (SSL_session_reused(scon)) {\n            ver = \'r\';\n        } else {\n            ver = SSL_version(scon);\n            if (ver == TLS1_VERSION)\n                ver = \'t\';\n            else if (ver == SSL3_VERSION)\n                ver = \'3\';\n            else\n                ver = \'*\';\n        }\n        fputc(ver, stdout);\n        fflush(stdout);\n    }\n    totalTime += tm_Time_F(STOP);\n    printf\n        ("\\n\\n%d connections in %.2fs; %.2f connections/user sec, bytes read %ld\\n",\n         nConn, totalTime, ((double)nConn / totalTime), bytes_read);\n    printf\n        ("%d connections in %ld real seconds, %ld bytes read per connection\\n",\n         nConn, (long)time(NULL) - finishtime + maxtime, bytes_read / nConn);\n    ret = 0;\n end:\n    SSL_free(scon);\n    SSL_CTX_free(ctx);\n    return ret;\n}', 'void SSL_free(SSL *s)\n{\n    int i;\n    if (s == NULL)\n        return;\n    CRYPTO_DOWN_REF(&s->references, &i, s->lock);\n    REF_PRINT_COUNT("SSL", s);\n    if (i > 0)\n        return;\n    REF_ASSERT_ISNT(i < 0);\n    X509_VERIFY_PARAM_free(s->param);\n    dane_final(&s->dane);\n    CRYPTO_free_ex_data(CRYPTO_EX_INDEX_SSL, s, &s->ex_data);\n    RECORD_LAYER_release(&s->rlayer);\n    ssl_free_wbio_buffer(s);\n    BIO_free_all(s->wbio);\n    s->wbio = NULL;\n    BIO_free_all(s->rbio);\n    s->rbio = NULL;\n    BUF_MEM_free(s->init_buf);\n    sk_SSL_CIPHER_free(s->cipher_list);\n    sk_SSL_CIPHER_free(s->cipher_list_by_id);\n    sk_SSL_CIPHER_free(s->tls13_ciphersuites);\n    if (s->session != NULL) {\n        ssl_clear_bad_session(s);\n        SSL_SESSION_free(s->session);\n    }\n    SSL_SESSION_free(s->psksession);\n    OPENSSL_free(s->psksession_id);\n    clear_ciphers(s);\n    ssl_cert_free(s->cert);\n    OPENSSL_free(s->ext.hostname);\n    SSL_CTX_free(s->session_ctx);\n#ifndef OPENSSL_NO_EC\n    OPENSSL_free(s->ext.ecpointformats);\n    OPENSSL_free(s->ext.supportedgroups);\n#endif\n    sk_X509_EXTENSION_pop_free(s->ext.ocsp.exts, X509_EXTENSION_free);\n#ifndef OPENSSL_NO_OCSP\n    sk_OCSP_RESPID_pop_free(s->ext.ocsp.ids, OCSP_RESPID_free);\n#endif\n#ifndef OPENSSL_NO_CT\n    SCT_LIST_free(s->scts);\n    OPENSSL_free(s->ext.scts);\n#endif\n    OPENSSL_free(s->ext.ocsp.resp);\n    OPENSSL_free(s->ext.alpn);\n    OPENSSL_free(s->ext.tls13_cookie);\n    OPENSSL_free(s->clienthello);\n    OPENSSL_free(s->pha_context);\n    EVP_MD_CTX_free(s->pha_dgst);\n    sk_X509_NAME_pop_free(s->ca_names, X509_NAME_free);\n    sk_X509_NAME_pop_free(s->client_ca_names, X509_NAME_free);\n    sk_X509_pop_free(s->verified_chain, X509_free);\n    if (s->method != NULL)\n        s->method->ssl_free(s);\n    SSL_CTX_free(s->ctx);\n    ASYNC_WAIT_CTX_free(s->waitctx);\n#if !defined(OPENSSL_NO_NEXTPROTONEG)\n    OPENSSL_free(s->ext.npn);\n#endif\n#ifndef OPENSSL_NO_SRTP\n    sk_SRTP_PROTECTION_PROFILE_free(s->srtp_profiles);\n#endif\n    CRYPTO_THREAD_lock_free(s->lock);\n    OPENSSL_free(s);\n}', 'void SSL_CTX_free(SSL_CTX *a)\n{\n    int i;\n    if (a == NULL)\n        return;\n    CRYPTO_DOWN_REF(&a->references, &i, a->lock);\n    REF_PRINT_COUNT("SSL_CTX", a);\n    if (i > 0)\n        return;\n    REF_ASSERT_ISNT(i < 0);\n    X509_VERIFY_PARAM_free(a->param);\n    dane_ctx_final(&a->dane);\n    if (a->sessions != NULL)\n        SSL_CTX_flush_sessions(a, 0);\n    CRYPTO_free_ex_data(CRYPTO_EX_INDEX_SSL_CTX, a, &a->ex_data);\n    lh_SSL_SESSION_free(a->sessions);\n    X509_STORE_free(a->cert_store);\n#ifndef OPENSSL_NO_CT\n    CTLOG_STORE_free(a->ctlog_store);\n#endif\n    sk_SSL_CIPHER_free(a->cipher_list);\n    sk_SSL_CIPHER_free(a->cipher_list_by_id);\n    sk_SSL_CIPHER_free(a->tls13_ciphersuites);\n    ssl_cert_free(a->cert);\n    sk_X509_NAME_pop_free(a->ca_names, X509_NAME_free);\n    sk_X509_NAME_pop_free(a->client_ca_names, X509_NAME_free);\n    sk_X509_pop_free(a->extra_certs, X509_free);\n    a->comp_methods = NULL;\n#ifndef OPENSSL_NO_SRTP\n    sk_SRTP_PROTECTION_PROFILE_free(a->srtp_profiles);\n#endif\n#ifndef OPENSSL_NO_SRP\n    SSL_CTX_SRP_CTX_free(a);\n#endif\n#ifndef OPENSSL_NO_ENGINE\n    ENGINE_finish(a->client_cert_engine);\n#endif\n#ifndef OPENSSL_NO_EC\n    OPENSSL_free(a->ext.ecpointformats);\n    OPENSSL_free(a->ext.supportedgroups);\n#endif\n    OPENSSL_free(a->ext.alpn);\n    OPENSSL_secure_free(a->ext.secure);\n    CRYPTO_THREAD_lock_free(a->lock);\n    OPENSSL_free(a);\n}', 'void SSL_CTX_flush_sessions(SSL_CTX *s, long t)\n{\n    unsigned long i;\n    TIMEOUT_PARAM tp;\n    tp.ctx = s;\n    tp.cache = s->sessions;\n    if (tp.cache == NULL)\n        return;\n    tp.time = t;\n    CRYPTO_THREAD_write_lock(s->lock);\n    i = lh_SSL_SESSION_get_down_load(s->sessions);\n    lh_SSL_SESSION_set_down_load(s->sessions, 0);\n    lh_SSL_SESSION_doall_TIMEOUT_PARAM(tp.cache, timeout_cb, &tp);\n    lh_SSL_SESSION_set_down_load(s->sessions, i);\n    CRYPTO_THREAD_unlock(s->lock);\n}', 'IMPLEMENT_LHASH_DOALL_ARG(SSL_SESSION, TIMEOUT_PARAM)', 'void OPENSSL_LH_doall_arg(OPENSSL_LHASH *lh, OPENSSL_LH_DOALL_FUNCARG func, void *arg)\n{\n    doall_util_fn(lh, 1, (OPENSSL_LH_DOALL_FUNC)0, func, arg);\n}', 'static void doall_util_fn(OPENSSL_LHASH *lh, int use_arg,\n                          OPENSSL_LH_DOALL_FUNC func,\n                          OPENSSL_LH_DOALL_FUNCARG func_arg, void *arg)\n{\n    int i;\n    OPENSSL_LH_NODE *a, *n;\n    if (lh == NULL)\n        return;\n    for (i = lh->num_nodes - 1; i >= 0; i--) {\n        a = lh->b[i];\n        while (a != NULL) {\n            n = a->next;\n            if (use_arg)\n                func_arg(a->data, arg);\n            else\n                func(a->data);\n            a = n;\n        }\n    }\n}']