ssl/ssl_lib.c:3207: error: INTEGER_OVERFLOW_L2
  ([0, max(0, `s->ctx->sessions->num_nodes`)] - 1):unsigned32 by call to `SSL_free`.
Showing all 17 steps of the trace


ssl/ssl_lib.c:3088:1: Parameter `s->ctx->sessions->num_nodes`
3086.   }
3087.   
3088. > SSL *SSL_dup(SSL *s)
3089.   {
3090.       STACK_OF(X509_NAME) *sk;

ssl/ssl_lib.c:3104:16: Call
3102.        * Otherwise, copy configuration state, and session if set.
3103.        */
3104.       if ((ret = SSL_new(SSL_get_SSL_CTX(s))) == NULL)
                       ^
3105.           return (NULL);
3106.   

ssl/ssl_lib.c:617:1: Parameter `ctx->sessions->num_nodes`
  615.   }
  616.   
  617. > SSL *SSL_new(SSL_CTX *ctx)
  618.   {
  619.       SSL *s;

ssl/ssl_lib.c:3207:5: Call
3205.   
3206.    err:
3207.       SSL_free(ret);
            ^
3208.       return NULL;
3209.   }

ssl/ssl_lib.c:1013:1: Parameter `s->initial_ctx->sessions->num_nodes`
  1011.   }
  1012.   
  1013. > void SSL_free(SSL *s)
  1014.   {
  1015.       int i;

ssl/ssl_lib.c:1060:5: Call
  1058.   
  1059.       OPENSSL_free(s->tlsext_hostname);
  1060.       SSL_CTX_free(s->initial_ctx);
              ^
  1061.   #ifndef OPENSSL_NO_EC
  1062.       OPENSSL_free(s->tlsext_ecpointformatlist);

ssl/ssl_lib.c:2493:1: Parameter `a->sessions->num_nodes`
    2491.   }
    2492.   
    2493. > void SSL_CTX_free(SSL_CTX *a)
    2494.   {
    2495.       int i;

ssl/ssl_lib.c:2519:9: Call
    2517.        */
    2518.       if (a->sessions != NULL)
    2519.           SSL_CTX_flush_sessions(a, 0);
                    ^
    2520.   
    2521.       CRYPTO_free_ex_data(CRYPTO_EX_INDEX_SSL_CTX, a, &a->ex_data);

ssl/ssl_sess.c:1074:1: Parameter `s->sessions->num_nodes`
      1072.   IMPLEMENT_LHASH_DOALL_ARG(SSL_SESSION, TIMEOUT_PARAM);
      1073.   
      1074. > void SSL_CTX_flush_sessions(SSL_CTX *s, long t)
      1075.   {
      1076.       unsigned long i;

ssl/ssl_sess.c:1087:5: Call
      1085.       i = CHECKED_LHASH_OF(SSL_SESSION, tp.cache)->down_load;
      1086.       CHECKED_LHASH_OF(SSL_SESSION, tp.cache)->down_load = 0;
      1087.       lh_SSL_SESSION_doall_TIMEOUT_PARAM(tp.cache, timeout_cb, &tp);
                  ^
      1088.       CHECKED_LHASH_OF(SSL_SESSION, tp.cache)->down_load = i;
      1089.       CRYPTO_THREAD_unlock(s->lock);

ssl/ssl_sess.c:1072:1: Parameter `lh->num_nodes`
        1070.   }
        1071.   
        1072. > IMPLEMENT_LHASH_DOALL_ARG(SSL_SESSION, TIMEOUT_PARAM);
        1073.   
        1074.   void SSL_CTX_flush_sessions(SSL_CTX *s, long t)

ssl/ssl_sess.c:1072:1: Call
        1070.   }
        1071.   
        1072. > IMPLEMENT_LHASH_DOALL_ARG(SSL_SESSION, TIMEOUT_PARAM);
        1073.   
        1074.   void SSL_CTX_flush_sessions(SSL_CTX *s, long t)

crypto/lhash/lhash.c:273:1: Parameter `lh->num_nodes`
          271.   }
          272.   
          273. > void lh_doall_arg(_LHASH *lh, LHASH_DOALL_ARG_FN_TYPE func, void *arg)
          274.   {
          275.       doall_util_fn(lh, 1, (LHASH_DOALL_FN_TYPE)0, func, arg);

crypto/lhash/lhash.c:275:5: Call
          273.   void lh_doall_arg(_LHASH *lh, LHASH_DOALL_ARG_FN_TYPE func, void *arg)
          274.   {
          275.       doall_util_fn(lh, 1, (LHASH_DOALL_FN_TYPE)0, func, arg);
                     ^
          276.   }
          277.   

crypto/lhash/lhash.c:235:1: <LHS trace>
233.   }
234.   
235. > static void doall_util_fn(_LHASH *lh, int use_arg, LHASH_DOALL_FN_TYPE func,
236.                             LHASH_DOALL_ARG_FN_TYPE func_arg, void *arg)
237.   {

crypto/lhash/lhash.c:235:1: Parameter `lh->num_nodes`
            233.   }
            234.   
            235. > static void doall_util_fn(_LHASH *lh, int use_arg, LHASH_DOALL_FN_TYPE func,
            236.                             LHASH_DOALL_ARG_FN_TYPE func_arg, void *arg)
            237.   {

crypto/lhash/lhash.c:248:10: Binary operation: ([0, max(0, s->ctx->sessions->num_nodes)] - 1):unsigned32 by call to `SSL_free` 
            246.        * memory leaks otherwise
            247.        */
            248.       for (i = lh->num_nodes - 1; i >= 0; i--) {
                            ^
            249.           a = lh->b[i];
            250.           while (a != NULL) {

static void doall_util_fn(_LHASH *lh, int use_arg, LHASH_DOALL_FN_TYPE func,
                          LHASH_DOALL_ARG_FN_TYPE func_arg, void *arg)
{
    int i;
    LHASH_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;
        }
    }
}
['SSL *SSL_dup(SSL *s)\n{\n    STACK_OF(X509_NAME) *sk;\n    X509_NAME *xn;\n    SSL *ret;\n    int i;\n    if (!SSL_in_init(s) || !SSL_in_before(s)) {\n        CRYPTO_atomic_add(&s->references, 1, &i, s->lock);\n        return s;\n    }\n    if ((ret = SSL_new(SSL_get_SSL_CTX(s))) == NULL)\n        return (NULL);\n    if (s->session != NULL) {\n        if (!SSL_copy_session_id(ret, s))\n            goto err;\n    } else {\n        if (!SSL_set_ssl_method(ret, s->method))\n            goto err;\n        if (s->cert != NULL) {\n            ssl_cert_free(ret->cert);\n            ret->cert = ssl_cert_dup(s->cert);\n            if (ret->cert == NULL)\n                goto err;\n        }\n        if (!SSL_set_session_id_context(ret, s->sid_ctx, s->sid_ctx_length))\n            goto err;\n    }\n    ssl_dane_dup(ret, s);\n    ret->version = s->version;\n    ret->options = s->options;\n    ret->mode = s->mode;\n    SSL_set_max_cert_list(ret, SSL_get_max_cert_list(s));\n    SSL_set_read_ahead(ret, SSL_get_read_ahead(s));\n    ret->msg_callback = s->msg_callback;\n    ret->msg_callback_arg = s->msg_callback_arg;\n    SSL_set_verify(ret, SSL_get_verify_mode(s), SSL_get_verify_callback(s));\n    SSL_set_verify_depth(ret, SSL_get_verify_depth(s));\n    ret->generate_session_id = s->generate_session_id;\n    SSL_set_info_callback(ret, SSL_get_info_callback(s));\n    if (!CRYPTO_dup_ex_data(CRYPTO_EX_INDEX_SSL, &ret->ex_data, &s->ex_data))\n        goto err;\n    if (s->rbio != NULL) {\n        if (!BIO_dup_state(s->rbio, (char *)&ret->rbio))\n            goto err;\n    }\n    if (s->wbio != NULL) {\n        if (s->wbio != s->rbio) {\n            if (!BIO_dup_state(s->wbio, (char *)&ret->wbio))\n                goto err;\n        } else\n            ret->wbio = ret->rbio;\n    }\n    ret->server = s->server;\n    if (s->handshake_func) {\n        if (s->server)\n            SSL_set_accept_state(ret);\n        else\n            SSL_set_connect_state(ret);\n    }\n    ret->shutdown = s->shutdown;\n    ret->hit = s->hit;\n    ret->default_passwd_callback = s->default_passwd_callback;\n    ret->default_passwd_callback_userdata = s->default_passwd_callback_userdata;\n    X509_VERIFY_PARAM_inherit(ret->param, s->param);\n    if (s->cipher_list != NULL) {\n        if ((ret->cipher_list = sk_SSL_CIPHER_dup(s->cipher_list)) == NULL)\n            goto err;\n    }\n    if (s->cipher_list_by_id != NULL)\n        if ((ret->cipher_list_by_id = sk_SSL_CIPHER_dup(s->cipher_list_by_id))\n            == NULL)\n            goto err;\n    if (s->client_CA != NULL) {\n        if ((sk = sk_X509_NAME_dup(s->client_CA)) == NULL)\n            goto err;\n        ret->client_CA = sk;\n        for (i = 0; i < sk_X509_NAME_num(sk); i++) {\n            xn = sk_X509_NAME_value(sk, i);\n            if (sk_X509_NAME_set(sk, i, X509_NAME_dup(xn)) == NULL) {\n                X509_NAME_free(xn);\n                goto err;\n            }\n        }\n    }\n    return ret;\n err:\n    SSL_free(ret);\n    return NULL;\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        SSLerr(SSL_F_SSL_NEW, ERR_R_MALLOC_FAILURE);\n        OPENSSL_free(s);\n        return NULL;\n    }\n    RECORD_LAYER_init(&s->rlayer, s);\n    s->options = ctx->options;\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->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->sid_ctx_length = ctx->sid_ctx_length;\n    OPENSSL_assert(s->sid_ctx_length <= sizeof s->sid_ctx);\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->tlsext_debug_cb = 0;\n    s->tlsext_debug_arg = NULL;\n    s->tlsext_ticket_expected = 0;\n    s->tlsext_status_type = -1;\n    s->tlsext_status_expected = 0;\n    s->tlsext_ocsp_ids = NULL;\n    s->tlsext_ocsp_exts = NULL;\n    s->tlsext_ocsp_resp = NULL;\n    s->tlsext_ocsp_resplen = -1;\n    SSL_CTX_up_ref(ctx);\n    s->initial_ctx = ctx;\n# ifndef OPENSSL_NO_EC\n    if (ctx->tlsext_ecpointformatlist) {\n        s->tlsext_ecpointformatlist =\n            OPENSSL_memdup(ctx->tlsext_ecpointformatlist,\n                           ctx->tlsext_ecpointformatlist_length);\n        if (!s->tlsext_ecpointformatlist)\n            goto err;\n        s->tlsext_ecpointformatlist_length =\n            ctx->tlsext_ecpointformatlist_length;\n    }\n    if (ctx->tlsext_ellipticcurvelist) {\n        s->tlsext_ellipticcurvelist =\n            OPENSSL_memdup(ctx->tlsext_ellipticcurvelist,\n                           ctx->tlsext_ellipticcurvelist_length);\n        if (!s->tlsext_ellipticcurvelist)\n            goto err;\n        s->tlsext_ellipticcurvelist_length =\n            ctx->tlsext_ellipticcurvelist_length;\n    }\n# endif\n# ifndef OPENSSL_NO_NEXTPROTONEG\n    s->next_proto_negotiated = NULL;\n# endif\n    if (s->ctx->alpn_client_proto_list) {\n        s->alpn_client_proto_list =\n            OPENSSL_malloc(s->ctx->alpn_client_proto_list_len);\n        if (s->alpn_client_proto_list == NULL)\n            goto err;\n        memcpy(s->alpn_client_proto_list, s->ctx->alpn_client_proto_list,\n               s->ctx->alpn_client_proto_list_len);\n        s->alpn_client_proto_list_len = s->ctx->alpn_client_proto_list_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    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    CRYPTO_new_ex_data(CRYPTO_EX_INDEX_SSL, s, &s->ex_data);\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->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_atomic_add(&s->references, -1, &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    if (s->bbio != NULL) {\n        if (s->bbio == s->wbio) {\n            s->wbio = BIO_pop(s->wbio);\n        }\n        BIO_free(s->bbio);\n        s->bbio = NULL;\n    }\n    BIO_free_all(s->rbio);\n    if (s->wbio != s->rbio)\n        BIO_free_all(s->wbio);\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    clear_ciphers(s);\n    ssl_cert_free(s->cert);\n    OPENSSL_free(s->tlsext_hostname);\n    SSL_CTX_free(s->initial_ctx);\n#ifndef OPENSSL_NO_EC\n    OPENSSL_free(s->tlsext_ecpointformatlist);\n    OPENSSL_free(s->tlsext_ellipticcurvelist);\n#endif\n    sk_X509_EXTENSION_pop_free(s->tlsext_ocsp_exts, X509_EXTENSION_free);\n    sk_OCSP_RESPID_pop_free(s->tlsext_ocsp_ids, OCSP_RESPID_free);\n#ifndef OPENSSL_NO_CT\n    SCT_LIST_free(s->scts);\n    OPENSSL_free(s->tlsext_scts);\n#endif\n    OPENSSL_free(s->tlsext_ocsp_resp);\n    OPENSSL_free(s->alpn_client_proto_list);\n    sk_X509_NAME_pop_free(s->client_CA, 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->next_proto_negotiated);\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_atomic_add(&a->references, -1, &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->client_CA, 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->tlsext_ecpointformatlist);\n    OPENSSL_free(a->tlsext_ellipticcurvelist);\n#endif\n    OPENSSL_free(a->alpn_client_proto_list);\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 = CHECKED_LHASH_OF(SSL_SESSION, tp.cache)->down_load;\n    CHECKED_LHASH_OF(SSL_SESSION, tp.cache)->down_load = 0;\n    lh_SSL_SESSION_doall_TIMEOUT_PARAM(tp.cache, timeout_cb, &tp);\n    CHECKED_LHASH_OF(SSL_SESSION, tp.cache)->down_load = i;\n    CRYPTO_THREAD_unlock(s->lock);\n}', 'IMPLEMENT_LHASH_DOALL_ARG(SSL_SESSION, TIMEOUT_PARAM)', 'void lh_doall_arg(_LHASH *lh, LHASH_DOALL_ARG_FN_TYPE func, void *arg)\n{\n    doall_util_fn(lh, 1, (LHASH_DOALL_FN_TYPE)0, func, arg);\n}', 'static void doall_util_fn(_LHASH *lh, int use_arg, LHASH_DOALL_FN_TYPE func,\n                          LHASH_DOALL_ARG_FN_TYPE func_arg, void *arg)\n{\n    int i;\n    LHASH_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}']