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


test/ssl_test.c:440:14: Call
438.           goto err;
439.   
440.       result = do_handshake(server_ctx, server2_ctx, client_ctx,
                    ^
441.                             resume_server_ctx, resume_client_ctx, test_ctx);
442.   

test/handshake_helper.c:1629:1: Parameter `resume_client_ctx->sessions->num_nodes`
  1627.   }
  1628.   
  1629. > HANDSHAKE_RESULT *do_handshake(SSL_CTX *server_ctx, SSL_CTX *server2_ctx,
  1630.                                  SSL_CTX *client_ctx, SSL_CTX *resume_server_ctx,
  1631.                                  SSL_CTX *resume_client_ctx,

test/ssl_test.c:448:5: Call
446.   err:
447.       CONF_modules_unload(0);
448.       SSL_CTX_free(server_ctx);
           ^
449.       SSL_CTX_free(server2_ctx);
450.       SSL_CTX_free(client_ctx);

ssl/ssl_lib.c:3017:1: Parameter `a->sessions->num_nodes`
  3015.   }
  3016.   
  3017. > void SSL_CTX_free(SSL_CTX *a)
  3018.   {
  3019.       int i;

ssl/ssl_lib.c:3043:9: Call
  3041.        */
  3042.       if (a->sessions != NULL)
  3043.           SSL_CTX_flush_sessions(a, 0);
                  ^
  3044.   
  3045.       CRYPTO_free_ex_data(CRYPTO_EX_INDEX_SSL_CTX, a, &a->ex_data);

ssl/ssl_sess.c:1102:1: Parameter `s->sessions->num_nodes`
    1100.   IMPLEMENT_LHASH_DOALL_ARG(SSL_SESSION, TIMEOUT_PARAM);
    1101.   
    1102. > void SSL_CTX_flush_sessions(SSL_CTX *s, long t)
    1103.   {
    1104.       unsigned long i;

ssl/ssl_sess.c:1115:5: Call
    1113.       i = lh_SSL_SESSION_get_down_load(s->sessions);
    1114.       lh_SSL_SESSION_set_down_load(s->sessions, 0);
    1115.       lh_SSL_SESSION_doall_TIMEOUT_PARAM(tp.cache, timeout_cb, &tp);
                ^
    1116.       lh_SSL_SESSION_set_down_load(s->sessions, i);
    1117.       CRYPTO_THREAD_unlock(s->lock);

ssl/ssl_sess.c:1100:1: Parameter `lh->num_nodes`
      1098.   }
      1099.   
      1100. > IMPLEMENT_LHASH_DOALL_ARG(SSL_SESSION, TIMEOUT_PARAM);
      1101.   
      1102.   void SSL_CTX_flush_sessions(SSL_CTX *s, long t)

ssl/ssl_sess.c:1100:1: Call
      1098.   }
      1099.   
      1100. > IMPLEMENT_LHASH_DOALL_ARG(SSL_SESSION, TIMEOUT_PARAM);
      1101.   
      1102.   void SSL_CTX_flush_sessions(SSL_CTX *s, long t)

crypto/lhash/lhash.c:198:1: Parameter `lh->num_nodes`
        196.   }
        197.   
        198. > void OPENSSL_LH_doall_arg(OPENSSL_LHASH *lh, OPENSSL_LH_DOALL_FUNCARG func, void *arg)
        199.   {
        200.       doall_util_fn(lh, 1, (OPENSSL_LH_DOALL_FUNC)0, func, arg);

crypto/lhash/lhash.c:200:5: Call
        198.   void OPENSSL_LH_doall_arg(OPENSSL_LHASH *lh, OPENSSL_LH_DOALL_FUNCARG func, void *arg)
        199.   {
        200.       doall_util_fn(lh, 1, (OPENSSL_LH_DOALL_FUNC)0, func, arg);
                   ^
        201.   }
        202.   

crypto/lhash/lhash.c:166:1: <LHS trace>
164.   }
165.   
166. > static void doall_util_fn(OPENSSL_LHASH *lh, int use_arg,
167.                             OPENSSL_LH_DOALL_FUNC func,
168.                             OPENSSL_LH_DOALL_FUNCARG func_arg, void *arg)

crypto/lhash/lhash.c:166:1: Parameter `lh->num_nodes`
          164.   }
          165.   
          166. > static void doall_util_fn(OPENSSL_LHASH *lh, int use_arg,
          167.                             OPENSSL_LH_DOALL_FUNC func,
          168.                             OPENSSL_LH_DOALL_FUNCARG func_arg, void *arg)

crypto/lhash/lhash.c:180:10: Binary operation: ([0, +oo] - 1):unsigned32 by call to `SSL_CTX_free` 
          178.        * memory leaks otherwise
          179.        */
          180.       for (i = lh->num_nodes - 1; i >= 0; i--) {
                          ^
          181.           a = lh->b[i];
          182.           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;
        }
    }
}
['static int test_handshake(int idx)\n{\n    int ret = 0;\n    SSL_CTX *server_ctx = NULL, *server2_ctx = NULL, *client_ctx = NULL,\n        *resume_server_ctx = NULL, *resume_client_ctx = NULL;\n    SSL_TEST_CTX *test_ctx = NULL;\n    HANDSHAKE_RESULT *result = NULL;\n    char test_app[MAX_TESTCASE_NAME_LENGTH];\n    BIO_snprintf(test_app, sizeof(test_app), "test-%d", idx);\n    test_ctx = SSL_TEST_CTX_create(conf, test_app);\n    if (!TEST_ptr(test_ctx))\n        goto err;\n#ifndef OPENSSL_NO_DTLS\n    if (test_ctx->method == SSL_TEST_METHOD_DTLS) {\n        server_ctx = SSL_CTX_new(DTLS_server_method());\n        if (test_ctx->extra.server.servername_callback !=\n            SSL_TEST_SERVERNAME_CB_NONE) {\n            if (!TEST_ptr(server2_ctx = SSL_CTX_new(DTLS_server_method())))\n                goto err;\n        }\n        client_ctx = SSL_CTX_new(DTLS_client_method());\n        if (test_ctx->handshake_mode == SSL_TEST_HANDSHAKE_RESUME) {\n            resume_server_ctx = SSL_CTX_new(DTLS_server_method());\n            resume_client_ctx = SSL_CTX_new(DTLS_client_method());\n            if (!TEST_ptr(resume_server_ctx)\n                    || !TEST_ptr(resume_client_ctx))\n                goto err;\n        }\n    }\n#endif\n    if (test_ctx->method == SSL_TEST_METHOD_TLS) {\n        server_ctx = SSL_CTX_new(TLS_server_method());\n        if (test_ctx->extra.server.servername_callback !=\n            SSL_TEST_SERVERNAME_CB_NONE) {\n            if (!TEST_ptr(server2_ctx = SSL_CTX_new(TLS_server_method())))\n                goto err;\n        }\n        client_ctx = SSL_CTX_new(TLS_client_method());\n        if (test_ctx->handshake_mode == SSL_TEST_HANDSHAKE_RESUME) {\n            resume_server_ctx = SSL_CTX_new(TLS_server_method());\n            resume_client_ctx = SSL_CTX_new(TLS_client_method());\n            if (!TEST_ptr(resume_server_ctx)\n                    || !TEST_ptr(resume_client_ctx))\n                goto err;\n        }\n    }\n    if (!TEST_ptr(server_ctx)\n            || !TEST_ptr(client_ctx)\n            || !TEST_int_gt(CONF_modules_load(conf, test_app, 0),  0))\n        goto err;\n    if (!SSL_CTX_config(server_ctx, "server")\n        || !SSL_CTX_config(client_ctx, "client")) {\n        goto err;\n    }\n    if (server2_ctx != NULL && !SSL_CTX_config(server2_ctx, "server2"))\n        goto err;\n    if (resume_server_ctx != NULL\n        && !SSL_CTX_config(resume_server_ctx, "resume-server"))\n        goto err;\n    if (resume_client_ctx != NULL\n        && !SSL_CTX_config(resume_client_ctx, "resume-client"))\n        goto err;\n    result = do_handshake(server_ctx, server2_ctx, client_ctx,\n                          resume_server_ctx, resume_client_ctx, test_ctx);\n    if (result != NULL)\n        ret = check_test(result, test_ctx);\nerr:\n    CONF_modules_unload(0);\n    SSL_CTX_free(server_ctx);\n    SSL_CTX_free(server2_ctx);\n    SSL_CTX_free(client_ctx);\n    SSL_CTX_free(resume_server_ctx);\n    SSL_CTX_free(resume_client_ctx);\n    SSL_TEST_CTX_free(test_ctx);\n    HANDSHAKE_RESULT_free(result);\n    return ret;\n}', 'HANDSHAKE_RESULT *do_handshake(SSL_CTX *server_ctx, SSL_CTX *server2_ctx,\n                               SSL_CTX *client_ctx, SSL_CTX *resume_server_ctx,\n                               SSL_CTX *resume_client_ctx,\n                               const SSL_TEST_CTX *test_ctx)\n{\n    HANDSHAKE_RESULT *result;\n    SSL_SESSION *session = NULL;\n    result = do_handshake_internal(server_ctx, server2_ctx, client_ctx,\n                                   test_ctx, &test_ctx->extra,\n                                   NULL, &session);\n    if (result == NULL\n            || test_ctx->handshake_mode != SSL_TEST_HANDSHAKE_RESUME\n            || result->result == SSL_TEST_INTERNAL_ERROR)\n        goto end;\n    if (result->result != SSL_TEST_SUCCESS) {\n        result->result = SSL_TEST_FIRST_HANDSHAKE_FAILED;\n        goto end;\n    }\n    HANDSHAKE_RESULT_free(result);\n    result = do_handshake_internal(resume_server_ctx, NULL, resume_client_ctx,\n                                   test_ctx, &test_ctx->resume_extra,\n                                   session, NULL);\n end:\n    SSL_SESSION_free(session);\n    return result;\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    ssl_cert_free(a->cert);\n    sk_X509_NAME_pop_free(a->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    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}']