apps/ciphers.c:251: error: INTEGER_OVERFLOW_L2
  ([0, +oo] - 1):unsigned64 by call to `SSL_free`.
Showing all 16 steps of the trace


apps/ciphers.c:193:11: Call
191.           }
192.       }
193.       ssl = SSL_new(ctx);
                 ^
194.       if (ssl == NULL)
195.           goto err;

ssl/ssl_lib.c:610:1: Parameter `ctx->sessions->num_items`
  608.   }
  609.   
  610. > SSL *SSL_new(SSL_CTX *ctx)
  611.   {
  612.       SSL *s;

apps/ciphers.c:251:5: Call
249.           sk_SSL_CIPHER_free(sk);
250.       SSL_CTX_free(ctx);
251.       SSL_free(ssl);
           ^
252.       return ret;
253.   }

ssl/ssl_lib.c:1070:1: Parameter `s->session_ctx->sessions->num_items`
  1068.   }
  1069.   
  1070. > void SSL_free(SSL *s)
  1071.   {
  1072.       int i;

ssl/ssl_lib.c:1101:9: Call
  1099.       /* Make the next call work :-) */
  1100.       if (s->session != NULL) {
  1101.           ssl_clear_bad_session(s);
                  ^
  1102.           SSL_SESSION_free(s->session);
  1103.       }

ssl/ssl_sess.c:1107:1: Parameter `s->session_ctx->sessions->num_items`
    1105.   }
    1106.   
    1107. > int ssl_clear_bad_session(SSL *s)
    1108.   {
    1109.       if ((s->session != NULL) &&

ssl/ssl_sess.c:1112:9: Call
    1110.           !(s->shutdown & SSL_SENT_SHUTDOWN) &&
    1111.           !(SSL_in_init(s) || SSL_in_before(s))) {
    1112.           SSL_CTX_remove_session(s->session_ctx, s->session);
                    ^
    1113.           return 1;
    1114.       } else

ssl/ssl_sess.c:724:1: Parameter `ctx->sessions->num_items`
      722.   }
      723.   
      724. > int SSL_CTX_remove_session(SSL_CTX *ctx, SSL_SESSION *c)
      725.   {
      726.       return remove_session_lock(ctx, c, 1);

ssl/ssl_sess.c:726:12: Call
      724.   int SSL_CTX_remove_session(SSL_CTX *ctx, SSL_SESSION *c)
      725.   {
      726.       return remove_session_lock(ctx, c, 1);
                        ^
      727.   }
      728.   

ssl/ssl_sess.c:729:1: Parameter `ctx->sessions->num_items`
        727.   }
        728.   
        729. > static int remove_session_lock(SSL_CTX *ctx, SSL_SESSION *c, int lck)
        730.   {
        731.       SSL_SESSION *r;

ssl/ssl_sess.c:739:17: Call
        737.           if ((r = lh_SSL_SESSION_retrieve(ctx->sessions, c)) == c) {
        738.               ret = 1;
        739.               r = lh_SSL_SESSION_delete(ctx->sessions, c);
                               ^
        740.               SSL_SESSION_list_remove(ctx, c);
        741.           }

ssl/ssl_locl.h:697:1: Parameter `lh->num_items`
          695.   } TLSEXT_INDEX;
          696.   
          697. > DEFINE_LHASH_OF(SSL_SESSION);
          698.   /* Needed in ssl_cert.c */
          699.   DEFINE_LHASH_OF(X509_NAME);

ssl/ssl_locl.h:697:1: Call
          695.   } TLSEXT_INDEX;
          696.   
          697. > DEFINE_LHASH_OF(SSL_SESSION);
          698.   /* Needed in ssl_cert.c */
          699.   DEFINE_LHASH_OF(X509_NAME);

crypto/lhash/lhash.c:102:1: <LHS trace>
100.   }
101.   
102. > void *OPENSSL_LH_delete(OPENSSL_LHASH *lh, const void *data)
103.   {
104.       unsigned long hash;

crypto/lhash/lhash.c:102:1: Parameter `lh->num_items`
            100.   }
            101.   
            102. > void *OPENSSL_LH_delete(OPENSSL_LHASH *lh, const void *data)
            103.   {
            104.       unsigned long hash;

crypto/lhash/lhash.c:122:5: Binary operation: ([0, +oo] - 1):unsigned64 by call to `SSL_free` 
            120.       }
            121.   
            122.       lh->num_items--;
                       ^
            123.       if ((lh->num_nodes > MIN_NODES) &&
            124.           (lh->down_load >= (lh->num_items * LH_LOAD_MULT / lh->num_nodes)))

void *OPENSSL_LH_delete(OPENSSL_LHASH *lh, const void *data)
{
    unsigned long hash;
    OPENSSL_LH_NODE *nn, **rn;
    void *ret;
    lh->error = 0;
    rn = getrn(lh, data, &hash);
    if (*rn == NULL) {
        lh->num_no_delete++;
        return NULL;
    } else {
        nn = *rn;
        *rn = nn->next;
        ret = nn->data;
        OPENSSL_free(nn);
        lh->num_delete++;
    }
    lh->num_items--;
    if ((lh->num_nodes > MIN_NODES) &&
        (lh->down_load >= (lh->num_items * LH_LOAD_MULT / lh->num_nodes)))
        contract(lh);
    return ret;
}
['int ciphers_main(int argc, char **argv)\n{\n    SSL_CTX *ctx = NULL;\n    SSL *ssl = NULL;\n    STACK_OF(SSL_CIPHER) *sk = NULL;\n    const SSL_METHOD *meth = TLS_server_method();\n    int ret = 1, i, verbose = 0, Verbose = 0, use_supported = 0;\n    int stdname = 0;\n#ifndef OPENSSL_NO_PSK\n    int psk = 0;\n#endif\n#ifndef OPENSSL_NO_SRP\n    int srp = 0;\n#endif\n    const char *p;\n    char *ciphers = NULL, *prog, *convert = NULL;\n    char buf[512];\n    OPTION_CHOICE o;\n    int min_version = 0, max_version = 0;\n    prog = opt_init(argc, argv, ciphers_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(ciphers_options);\n            ret = 0;\n            goto end;\n        case OPT_V:\n            verbose = 1;\n            break;\n        case OPT_UPPER_V:\n            verbose = Verbose = 1;\n            break;\n        case OPT_S:\n            use_supported = 1;\n            break;\n        case OPT_STDNAME:\n            stdname = verbose = 1;\n            break;\n        case OPT_CONVERT:\n            convert = opt_arg();\n            break;\n        case OPT_SSL3:\n            min_version = SSL3_VERSION;\n            max_version = SSL3_VERSION;\n            break;\n        case OPT_TLS1:\n            min_version = TLS1_VERSION;\n            max_version = TLS1_VERSION;\n            break;\n        case OPT_TLS1_1:\n            min_version = TLS1_1_VERSION;\n            max_version = TLS1_1_VERSION;\n            break;\n        case OPT_TLS1_2:\n            min_version = TLS1_2_VERSION;\n            max_version = TLS1_2_VERSION;\n            break;\n        case OPT_TLS1_3:\n            min_version = TLS1_3_VERSION;\n            max_version = TLS1_3_VERSION;\n            break;\n        case OPT_PSK:\n#ifndef OPENSSL_NO_PSK\n            psk = 1;\n#endif\n            break;\n        case OPT_SRP:\n#ifndef OPENSSL_NO_SRP\n            srp = 1;\n#endif\n            break;\n        }\n    }\n    argv = opt_rest();\n    argc = opt_num_rest();\n    if (argc == 1)\n        ciphers = *argv;\n    else if (argc != 0)\n        goto opthelp;\n    if (convert != NULL) {\n        BIO_printf(bio_out, "OpenSSL cipher name: %s\\n",\n                   OPENSSL_cipher_name(convert));\n        goto end;\n    }\n    ctx = SSL_CTX_new(meth);\n    if (ctx == NULL)\n        goto err;\n    if (SSL_CTX_set_min_proto_version(ctx, min_version) == 0)\n        goto err;\n    if (SSL_CTX_set_max_proto_version(ctx, max_version) == 0)\n        goto err;\n#ifndef OPENSSL_NO_PSK\n    if (psk)\n        SSL_CTX_set_psk_client_callback(ctx, dummy_psk);\n#endif\n#ifndef OPENSSL_NO_SRP\n    if (srp)\n        SSL_CTX_set_srp_client_pwd_callback(ctx, dummy_srp);\n#endif\n    if (ciphers != NULL) {\n        if (!SSL_CTX_set_cipher_list(ctx, ciphers)) {\n            BIO_printf(bio_err, "Error in cipher list\\n");\n            goto err;\n        }\n    }\n    ssl = SSL_new(ctx);\n    if (ssl == NULL)\n        goto err;\n    if (use_supported)\n        sk = SSL_get1_supported_ciphers(ssl);\n    else\n        sk = SSL_get_ciphers(ssl);\n    if (!verbose) {\n        for (i = 0; i < sk_SSL_CIPHER_num(sk); i++) {\n            const SSL_CIPHER *c = sk_SSL_CIPHER_value(sk, i);\n            p = SSL_CIPHER_get_name(c);\n            if (p == NULL)\n                break;\n            if (i != 0)\n                BIO_printf(bio_out, ":");\n            BIO_printf(bio_out, "%s", p);\n        }\n        BIO_printf(bio_out, "\\n");\n    } else {\n        for (i = 0; i < sk_SSL_CIPHER_num(sk); i++) {\n            const SSL_CIPHER *c;\n            c = sk_SSL_CIPHER_value(sk, i);\n            if (Verbose) {\n                unsigned long id = SSL_CIPHER_get_id(c);\n                int id0 = (int)(id >> 24);\n                int id1 = (int)((id >> 16) & 0xffL);\n                int id2 = (int)((id >> 8) & 0xffL);\n                int id3 = (int)(id & 0xffL);\n                if ((id & 0xff000000L) == 0x03000000L)\n                    BIO_printf(bio_out, "          0x%02X,0x%02X - ", id2, id3);\n                else\n                    BIO_printf(bio_out, "0x%02X,0x%02X,0x%02X,0x%02X - ", id0, id1, id2, id3);\n            }\n            if (stdname) {\n                const char *nm = SSL_CIPHER_standard_name(c);\n                if (nm == NULL)\n                    nm = "UNKNOWN";\n                BIO_printf(bio_out, "%s - ", nm);\n            }\n            BIO_puts(bio_out, SSL_CIPHER_description(c, buf, sizeof buf));\n        }\n    }\n    ret = 0;\n    goto end;\n err:\n    ERR_print_errors(bio_err);\n end:\n    if (use_supported)\n        sk_SSL_CIPHER_free(sk);\n    SSL_CTX_free(ctx);\n    SSL_free(ssl);\n    return ret;\n}', 'SSL *SSL_new(SSL_CTX *ctx)\n{\n    SSL *s;\n    if (ctx == NULL) {\n        SSLerr(SSL_F_SSL_NEW, SSL_R_NULL_SSL_CTX);\n        return (NULL);\n    }\n    if (ctx->method == NULL) {\n        SSLerr(SSL_F_SSL_NEW, SSL_R_SSL_CTX_HAS_NO_DEFAULT_SSL_VERSION);\n        return (NULL);\n    }\n    s = OPENSSL_zalloc(sizeof(*s));\n    if (s == NULL)\n        goto err;\n    s->lock = CRYPTO_THREAD_lock_new();\n    if (s->lock == NULL)\n        goto err;\n    if (RAND_get_rand_method() == RAND_OpenSSL()) {\n        s->drbg = RAND_DRBG_new(NID_aes_128_ctr, RAND_DRBG_FLAG_CTR_USE_DF,\n                                RAND_DRBG_get0_global());\n        if (s->drbg == NULL\n            || RAND_DRBG_instantiate(s->drbg, NULL, 0) == 0) {\n            CRYPTO_THREAD_lock_free(s->lock);\n            goto err;\n        }\n    }\n    RECORD_LAYER_init(&s->rlayer, s);\n    s->options = ctx->options;\n    s->dane.flags = ctx->dane.flags;\n    s->min_proto_version = ctx->min_proto_version;\n    s->max_proto_version = ctx->max_proto_version;\n    s->mode = ctx->mode;\n    s->max_cert_list = ctx->max_cert_list;\n    s->references = 1;\n    s->max_early_data = ctx->max_early_data;\n    s->cert = ssl_cert_dup(ctx->cert);\n    if (s->cert == NULL)\n        goto err;\n    RECORD_LAYER_set_read_ahead(&s->rlayer, ctx->read_ahead);\n    s->msg_callback = ctx->msg_callback;\n    s->msg_callback_arg = ctx->msg_callback_arg;\n    s->verify_mode = ctx->verify_mode;\n    s->not_resumable_session_cb = ctx->not_resumable_session_cb;\n    s->record_padding_cb = ctx->record_padding_cb;\n    s->record_padding_arg = ctx->record_padding_arg;\n    s->block_padding = ctx->block_padding;\n    s->sid_ctx_length = ctx->sid_ctx_length;\n    if (!ossl_assert(s->sid_ctx_length <= sizeof s->sid_ctx))\n        goto err;\n    memcpy(&s->sid_ctx, &ctx->sid_ctx, sizeof(s->sid_ctx));\n    s->verify_callback = ctx->default_verify_callback;\n    s->generate_session_id = ctx->generate_session_id;\n    s->param = X509_VERIFY_PARAM_new();\n    if (s->param == NULL)\n        goto err;\n    X509_VERIFY_PARAM_inherit(s->param, ctx->param);\n    s->quiet_shutdown = ctx->quiet_shutdown;\n    s->max_send_fragment = ctx->max_send_fragment;\n    s->split_send_fragment = ctx->split_send_fragment;\n    s->max_pipelines = ctx->max_pipelines;\n    if (s->max_pipelines > 1)\n        RECORD_LAYER_set_read_ahead(&s->rlayer, 1);\n    if (ctx->default_read_buf_len > 0)\n        SSL_set_default_read_buffer_len(s, ctx->default_read_buf_len);\n    SSL_CTX_up_ref(ctx);\n    s->ctx = ctx;\n    s->ext.debug_cb = 0;\n    s->ext.debug_arg = NULL;\n    s->ext.ticket_expected = 0;\n    s->ext.status_type = ctx->ext.status_type;\n    s->ext.status_expected = 0;\n    s->ext.ocsp.ids = NULL;\n    s->ext.ocsp.exts = NULL;\n    s->ext.ocsp.resp = NULL;\n    s->ext.ocsp.resp_len = 0;\n    SSL_CTX_up_ref(ctx);\n    s->session_ctx = ctx;\n#ifndef OPENSSL_NO_EC\n    if (ctx->ext.ecpointformats) {\n        s->ext.ecpointformats =\n            OPENSSL_memdup(ctx->ext.ecpointformats,\n                           ctx->ext.ecpointformats_len);\n        if (!s->ext.ecpointformats)\n            goto err;\n        s->ext.ecpointformats_len =\n            ctx->ext.ecpointformats_len;\n    }\n    if (ctx->ext.supportedgroups) {\n        s->ext.supportedgroups =\n            OPENSSL_memdup(ctx->ext.supportedgroups,\n                           ctx->ext.supportedgroups_len\n                                * sizeof(*ctx->ext.supportedgroups));\n        if (!s->ext.supportedgroups)\n            goto err;\n        s->ext.supportedgroups_len = ctx->ext.supportedgroups_len;\n    }\n#endif\n#ifndef OPENSSL_NO_NEXTPROTONEG\n    s->ext.npn = NULL;\n#endif\n    if (s->ctx->ext.alpn) {\n        s->ext.alpn = OPENSSL_malloc(s->ctx->ext.alpn_len);\n        if (s->ext.alpn == NULL)\n            goto err;\n        memcpy(s->ext.alpn, s->ctx->ext.alpn, s->ctx->ext.alpn_len);\n        s->ext.alpn_len = s->ctx->ext.alpn_len;\n    }\n    s->verified_chain = NULL;\n    s->verify_result = X509_V_OK;\n    s->default_passwd_callback = ctx->default_passwd_callback;\n    s->default_passwd_callback_userdata = ctx->default_passwd_callback_userdata;\n    s->method = ctx->method;\n    s->key_update = SSL_KEY_UPDATE_NONE;\n    if (!s->method->ssl_new(s))\n        goto err;\n    s->server = (ctx->method->ssl_accept == ssl_undefined_function) ? 0 : 1;\n    if (!SSL_clear(s))\n        goto err;\n    if (!CRYPTO_new_ex_data(CRYPTO_EX_INDEX_SSL, s, &s->ex_data))\n        goto err;\n#ifndef OPENSSL_NO_PSK\n    s->psk_client_callback = ctx->psk_client_callback;\n    s->psk_server_callback = ctx->psk_server_callback;\n#endif\n    s->psk_find_session_cb = ctx->psk_find_session_cb;\n    s->psk_use_session_cb = ctx->psk_use_session_cb;\n    s->job = NULL;\n#ifndef OPENSSL_NO_CT\n    if (!SSL_set_ct_validation_callback(s, ctx->ct_validation_callback,\n                                        ctx->ct_validation_callback_arg))\n        goto err;\n#endif\n    return s;\n err:\n    SSL_free(s);\n    SSLerr(SSL_F_SSL_NEW, ERR_R_MALLOC_FAILURE);\n    return NULL;\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    ssl_free_wbio_buffer(s);\n    BIO_free_all(s->wbio);\n    BIO_free_all(s->rbio);\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    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    sk_X509_NAME_pop_free(s->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    RECORD_LAYER_release(&s->rlayer);\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    RAND_DRBG_free(s->drbg);\n    CRYPTO_THREAD_lock_free(s->lock);\n    OPENSSL_free(s);\n}', 'int ssl_clear_bad_session(SSL *s)\n{\n    if ((s->session != NULL) &&\n        !(s->shutdown & SSL_SENT_SHUTDOWN) &&\n        !(SSL_in_init(s) || SSL_in_before(s))) {\n        SSL_CTX_remove_session(s->session_ctx, s->session);\n        return 1;\n    } else\n        return (0);\n}', 'int SSL_CTX_remove_session(SSL_CTX *ctx, SSL_SESSION *c)\n{\n    return remove_session_lock(ctx, c, 1);\n}', 'static int remove_session_lock(SSL_CTX *ctx, SSL_SESSION *c, int lck)\n{\n    SSL_SESSION *r;\n    int ret = 0;\n    if ((c != NULL) && (c->session_id_length != 0)) {\n        if (lck)\n            CRYPTO_THREAD_write_lock(ctx->lock);\n        if ((r = lh_SSL_SESSION_retrieve(ctx->sessions, c)) == c) {\n            ret = 1;\n            r = lh_SSL_SESSION_delete(ctx->sessions, c);\n            SSL_SESSION_list_remove(ctx, c);\n        }\n        c->not_resumable = 1;\n        if (lck)\n            CRYPTO_THREAD_unlock(ctx->lock);\n        if (ret)\n            SSL_SESSION_free(r);\n        if (ctx->remove_session_cb != NULL)\n            ctx->remove_session_cb(ctx, c);\n    } else\n        ret = 0;\n    return (ret);\n}', 'DEFINE_LHASH_OF(SSL_SESSION)', 'void *OPENSSL_LH_delete(OPENSSL_LHASH *lh, const void *data)\n{\n    unsigned long hash;\n    OPENSSL_LH_NODE *nn, **rn;\n    void *ret;\n    lh->error = 0;\n    rn = getrn(lh, data, &hash);\n    if (*rn == NULL) {\n        lh->num_no_delete++;\n        return NULL;\n    } else {\n        nn = *rn;\n        *rn = nn->next;\n        ret = nn->data;\n        OPENSSL_free(nn);\n        lh->num_delete++;\n    }\n    lh->num_items--;\n    if ((lh->num_nodes > MIN_NODES) &&\n        (lh->down_load >= (lh->num_items * LH_LOAD_MULT / lh->num_nodes)))\n        contract(lh);\n    return ret;\n}']