ssl/ssl_lib.c:3172: error: INTEGER_OVERFLOW_L2
  ([0, max(0, `s->ctx->sessions->num_items`)] - 1):unsigned64 by call to `SSL_copy_session_id`.
Showing all 19 steps of the trace


ssl/ssl_lib.c:3148:1: Parameter `s->ctx->sessions->num_items`
3146.   }
3147.   
3148. > SSL *SSL_dup(SSL *s)
3149.   {
3150.       STACK_OF(X509_NAME) *sk;

ssl/ssl_lib.c:3164:16: Call
3162.        * Otherwise, copy configuration state, and session if set.
3163.        */
3164.       if ((ret = SSL_new(SSL_get_SSL_CTX(s))) == NULL)
                       ^
3165.           return (NULL);
3166.   

ssl/ssl_lib.c:521:1: Parameter `ctx->sessions->num_items`
  519.   }
  520.   
  521. > SSL *SSL_new(SSL_CTX *ctx)
  522.   {
  523.       SSL *s;

ssl/ssl_lib.c:3172:14: Call
3170.            * session-id, SSL_METHOD, sid_ctx, and 'cert'
3171.            */
3172.           if (!SSL_copy_session_id(ret, s))
                     ^
3173.               goto err;
3174.       } else {

ssl/ssl_lib.c:1365:1: Parameter `t->session_ctx->sessions->num_items`
  1363.    * modify.  We need to be able to read f without being hassled
  1364.    */
  1365. > int SSL_copy_session_id(SSL *t, const SSL *f)
  1366.   {
  1367.       int i;

ssl/ssl_lib.c:1369:10: Call
  1367.       int i;
  1368.       /* Do we need to to SSL locking? */
  1369.       if (!SSL_set_session(t, SSL_get_session(f))) {
                   ^
  1370.           return 0;
  1371.       }

ssl/ssl_sess.c:811:1: Parameter `s->session_ctx->sessions->num_items`
    809.   }
    810.   
    811. > int SSL_set_session(SSL *s, SSL_SESSION *session)
    812.   {
    813.       ssl_clear_bad_session(s);

ssl/ssl_sess.c:813:5: Call
    811.   int SSL_set_session(SSL *s, SSL_SESSION *session)
    812.   {
    813.       ssl_clear_bad_session(s);
               ^
    814.       if (s->ctx->method != s->method) {
    815.           if (!SSL_set_ssl_method(s, s->ctx->method))

ssl/ssl_sess.c:1031:1: Parameter `s->session_ctx->sessions->num_items`
      1029.   }
      1030.   
      1031. > int ssl_clear_bad_session(SSL *s)
      1032.   {
      1033.       if ((s->session != NULL) &&

ssl/ssl_sess.c:1036:9: Call
      1034.           !(s->shutdown & SSL_SENT_SHUTDOWN) &&
      1035.           !(SSL_in_init(s) || SSL_in_before(s))) {
      1036.           SSL_CTX_remove_session(s->session_ctx, s->session);
                      ^
      1037.           return (1);
      1038.       } else

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

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

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

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

ssl/ssl_locl.h:660:1: Parameter `lh->num_items`
            658.   } CLIENTHELLO_MSG;
            659.   
            660. > DEFINE_LHASH_OF(SSL_SESSION);
            661.   /* Needed in ssl_cert.c */
            662.   DEFINE_LHASH_OF(X509_NAME);

ssl/ssl_locl.h:660:1: Call
            658.   } CLIENTHELLO_MSG;
            659.   
            660. > DEFINE_LHASH_OF(SSL_SESSION);
            661.   /* Needed in ssl_cert.c */
            662.   DEFINE_LHASH_OF(X509_NAME);

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

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

crypto/lhash/lhash.c:123:5: Binary operation: ([0, max(0, s->ctx->sessions->num_items)] - 1):unsigned64 by call to `SSL_copy_session_id` 
              121.       }
              122.   
              123.       lh->num_items--;
                         ^
              124.       if ((lh->num_nodes > MIN_NODES) &&
              125.           (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);
}
['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_UP_REF(&s->references, &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,\n                                        (int)s->sid_ctx_length))\n            goto err;\n    }\n    if (!ssl_dane_dup(ret, s))\n        goto err;\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            BIO_up_ref(ret->rbio);\n            ret->wbio = ret->rbio;\n        }\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->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->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->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        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->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}', 'int SSL_copy_session_id(SSL *t, const SSL *f)\n{\n    int i;\n    if (!SSL_set_session(t, SSL_get_session(f))) {\n        return 0;\n    }\n    if (t->method != f->method) {\n        t->method->ssl_free(t);\n        t->method = f->method;\n        if (t->method->ssl_new(t) == 0)\n            return 0;\n    }\n    CRYPTO_UP_REF(&f->cert->references, &i, f->cert->lock);\n    ssl_cert_free(t->cert);\n    t->cert = f->cert;\n    if (!SSL_set_session_id_context(t, f->sid_ctx, (int)f->sid_ctx_length)) {\n        return 0;\n    }\n    return 1;\n}', 'int SSL_set_session(SSL *s, SSL_SESSION *session)\n{\n    ssl_clear_bad_session(s);\n    if (s->ctx->method != s->method) {\n        if (!SSL_set_ssl_method(s, s->ctx->method))\n            return 0;\n    }\n    if (session != NULL) {\n        SSL_SESSION_up_ref(session);\n        s->verify_result = session->verify_result;\n    }\n    SSL_SESSION_free(s->session);\n    s->session = session;\n    return 1;\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}']