test/sslapitest.c:2757: error: INTEGER_OVERFLOW_L2
  ([0, +oo] - 1):unsigned32 by call to `SSL_free`.
Showing all 16 steps of the trace


test/sslapitest.c:2743:10: Call
2741.       }
2742.   
2743.       if (!TEST_true(setupearly_data_test(&cctx, &sctx, &clientssl,
                 ^
2744.                                           &serverssl, &sess, idx)))
2745.           goto end;

test/sslapitest.c:2386:1: Parameter `(*serverssl)->session_ctx->sessions->num_nodes`
  2384.    * error.
  2385.    */
  2386. > static int setupearly_data_test(SSL_CTX **cctx, SSL_CTX **sctx, SSL **clientssl,
  2387.                                   SSL **serverssl, SSL_SESSION **sess, int idx)
  2388.   {

test/sslapitest.c:2757:5: Call
2755.       SSL_shutdown(clientssl);
2756.       SSL_shutdown(serverssl);
2757.       SSL_free(serverssl);
            ^
2758.       SSL_free(clientssl);
2759.       serverssl = clientssl = NULL;

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

ssl/ssl_lib.c:1213:5: Call
  1211.           s->method->ssl_free(s);
  1212.   
  1213.       SSL_CTX_free(s->ctx);
              ^
  1214.   
  1215.       ASYNC_WAIT_CTX_free(s->waitctx);

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_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;
        }
    }
}
['static int test_early_data_replay_int(int idx, int usecb, int confopt)\n{\n    SSL_CTX *cctx = NULL, *sctx = NULL;\n    SSL *clientssl = NULL, *serverssl = NULL;\n    int testresult = 0;\n    SSL_SESSION *sess = NULL;\n    size_t readbytes, written;\n    unsigned char buf[20];\n    allow_ed_cb_called = 0;\n    if (!TEST_true(create_ssl_ctx_pair(TLS_server_method(), TLS_client_method(),\n                                       TLS1_VERSION, 0, &sctx,\n                                       &cctx, cert, privkey)))\n        return 0;\n    if (usecb > 0) {\n        if (confopt == 0) {\n            SSL_CTX_set_options(sctx, SSL_OP_NO_ANTI_REPLAY);\n        } else {\n            SSL_CONF_CTX *confctx = SSL_CONF_CTX_new();\n            if (!TEST_ptr(confctx))\n                goto end;\n            SSL_CONF_CTX_set_flags(confctx, SSL_CONF_FLAG_FILE\n                                            | SSL_CONF_FLAG_SERVER);\n            SSL_CONF_CTX_set_ssl_ctx(confctx, sctx);\n            if (!TEST_int_eq(SSL_CONF_cmd(confctx, "Options", "-AntiReplay"),\n                             2)) {\n                SSL_CONF_CTX_free(confctx);\n                goto end;\n            }\n            SSL_CONF_CTX_free(confctx);\n        }\n        SSL_CTX_set_allow_early_data_cb(sctx, allow_early_data_cb, &usecb);\n    }\n    if (!TEST_true(setupearly_data_test(&cctx, &sctx, &clientssl,\n                                        &serverssl, &sess, idx)))\n        goto end;\n    if (!TEST_true(create_ssl_connection(serverssl, clientssl, SSL_ERROR_NONE))\n            || !TEST_true(SSL_session_reused(clientssl)))\n        goto end;\n    SSL_shutdown(clientssl);\n    SSL_shutdown(serverssl);\n    SSL_free(serverssl);\n    SSL_free(clientssl);\n    serverssl = clientssl = NULL;\n    if (!TEST_true(create_ssl_objects(sctx, cctx, &serverssl,\n                                      &clientssl, NULL, NULL))\n            || !TEST_true(SSL_set_session(clientssl, sess)))\n        goto end;\n    if (!TEST_true(SSL_write_early_data(clientssl, MSG1, strlen(MSG1),\n                                        &written))\n            || !TEST_size_t_eq(written, strlen(MSG1)))\n        goto end;\n    if (usecb <= 1) {\n        if (!TEST_int_eq(SSL_read_early_data(serverssl, buf, sizeof(buf),\n                                             &readbytes),\n                         SSL_READ_EARLY_DATA_FINISH)\n                || !TEST_int_eq(SSL_get_early_data_status(serverssl),\n                                SSL_EARLY_DATA_REJECTED))\n            goto end;\n    } else {\n        if (!TEST_int_eq(SSL_read_early_data(serverssl, buf, sizeof(buf),\n                                             &readbytes),\n                         SSL_READ_EARLY_DATA_SUCCESS)\n                || !TEST_mem_eq(MSG1, strlen(MSG1), buf, readbytes)\n                || !TEST_int_gt(SSL_connect(clientssl), 0)\n                || !TEST_int_eq(SSL_read_early_data(serverssl, buf, sizeof(buf),\n                                             &readbytes),\n                                SSL_READ_EARLY_DATA_FINISH)\n                || !TEST_int_eq(SSL_get_early_data_status(serverssl),\n                                SSL_EARLY_DATA_ACCEPTED))\n            goto end;\n    }\n    if (!TEST_true(create_ssl_connection(serverssl, clientssl, SSL_ERROR_NONE))\n            || !TEST_int_eq(SSL_session_reused(clientssl), (usecb > 0) ? 1 : 0)\n            || !TEST_int_eq(allow_ed_cb_called, usecb > 0 ? 1 : 0))\n        goto end;\n    testresult = 1;\n end:\n    SSL_SESSION_free(sess);\n    SSL_SESSION_free(clientpsk);\n    SSL_SESSION_free(serverpsk);\n    clientpsk = serverpsk = NULL;\n    SSL_free(serverssl);\n    SSL_free(clientssl);\n    SSL_CTX_free(sctx);\n    SSL_CTX_free(cctx);\n    return testresult;\n}', 'static int setupearly_data_test(SSL_CTX **cctx, SSL_CTX **sctx, SSL **clientssl,\n                                SSL **serverssl, SSL_SESSION **sess, int idx)\n{\n    if (*sctx == NULL\n            && !TEST_true(create_ssl_ctx_pair(TLS_server_method(),\n                                              TLS_client_method(),\n                                              TLS1_VERSION, 0,\n                                              sctx, cctx, cert, privkey)))\n        return 0;\n    if (!TEST_true(SSL_CTX_set_max_early_data(*sctx, SSL3_RT_MAX_PLAIN_LENGTH)))\n        return 0;\n    if (idx == 1) {\n        SSL_CTX_set_read_ahead(*cctx, 1);\n        SSL_CTX_set_read_ahead(*sctx, 1);\n    } else if (idx == 2) {\n        SSL_CTX_set_psk_use_session_callback(*cctx, use_session_cb);\n        SSL_CTX_set_psk_find_session_callback(*sctx, find_session_cb);\n        use_session_cb_cnt = 0;\n        find_session_cb_cnt = 0;\n        srvid = pskid;\n    }\n    if (!TEST_true(create_ssl_objects(*sctx, *cctx, serverssl, clientssl,\n                                      NULL, NULL)))\n        return 0;\n    if (idx == 1\n            && !TEST_true(SSL_set_tlsext_host_name(*clientssl, "localhost")))\n        return 0;\n    if (idx == 2) {\n        clientpsk = create_a_psk(*clientssl);\n        if (!TEST_ptr(clientpsk)\n                || !TEST_true(SSL_SESSION_set_max_early_data(clientpsk,\n                                                             0x100))\n                || !TEST_true(SSL_SESSION_up_ref(clientpsk))) {\n            SSL_SESSION_free(clientpsk);\n            clientpsk = NULL;\n            return 0;\n        }\n        serverpsk = clientpsk;\n        if (sess != NULL) {\n            if (!TEST_true(SSL_SESSION_up_ref(clientpsk))) {\n                SSL_SESSION_free(clientpsk);\n                SSL_SESSION_free(serverpsk);\n                clientpsk = serverpsk = NULL;\n                return 0;\n            }\n            *sess = clientpsk;\n        }\n        return 1;\n    }\n    if (sess == NULL)\n        return 1;\n    if (!TEST_true(create_ssl_connection(*serverssl, *clientssl,\n                                         SSL_ERROR_NONE)))\n        return 0;\n    *sess = SSL_get1_session(*clientssl);\n    SSL_shutdown(*clientssl);\n    SSL_shutdown(*serverssl);\n    SSL_free(*serverssl);\n    SSL_free(*clientssl);\n    *serverssl = *clientssl = NULL;\n    if (!TEST_true(create_ssl_objects(*sctx, *cctx, serverssl,\n                                      clientssl, NULL, NULL))\n            || !TEST_true(SSL_set_session(*clientssl, *sess)))\n        return 0;\n    return 1;\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}']