ssl/s3_clnt.c:534: error: INTEGER_OVERFLOW_L2
  ([0, max(0, `s->initial_ctx->sessions->num_items`)] - 1):unsigned64 by call to `ssl3_get_new_session_ticket`.
Showing all 11 steps of the trace


ssl/s3_clnt.c:175:1: Parameter `s->initial_ctx->sessions->num_items`
173.   
174.   
175. > int ssl3_connect(SSL *s)
176.   {
177.       BUF_MEM *buf = NULL;

ssl/s3_clnt.c:534:19: Call
532.           case SSL3_ST_CR_SESSION_TICKET_A:
533.           case SSL3_ST_CR_SESSION_TICKET_B:
534.               ret = ssl3_get_new_session_ticket(s);
                         ^
535.               if (ret <= 0)
536.                   goto end;

ssl/s3_clnt.c:2177:1: Parameter `s->initial_ctx->sessions->num_items`
  2175.   }
  2176.   
  2177. > int ssl3_get_new_session_ticket(SSL *s)
  2178.   {
  2179.       int ok, al, ret = 0;

ssl/s3_clnt.c:2215:17: Call
  2213.               } else {
  2214.                   /* We carry on if this fails */
  2215.                   SSL_CTX_remove_session(s->session_ctx, s->session);
                          ^
  2216.               }
  2217.           }

ssl/ssl_sess.c:787:1: Parameter `ctx->sessions->num_items`
    785.   }
    786.   
    787. > int SSL_CTX_remove_session(SSL_CTX *ctx, SSL_SESSION *c)
    788.   {
    789.       return remove_session_lock(ctx, c, 1);

ssl/ssl_sess.c:789:12: Call
    787.   int SSL_CTX_remove_session(SSL_CTX *ctx, SSL_SESSION *c)
    788.   {
    789.       return remove_session_lock(ctx, c, 1);
                      ^
    790.   }
    791.   

ssl/ssl_sess.c:792:1: Parameter `ctx->sessions->num_items`
      790.   }
      791.   
      792. > static int remove_session_lock(SSL_CTX *ctx, SSL_SESSION *c, int lck)
      793.   {
      794.       SSL_SESSION *r;

ssl/ssl_sess.c:802:17: Call
      800.           if ((r = lh_SSL_SESSION_retrieve(ctx->sessions, c)) == c) {
      801.               ret = 1;
      802.               r = lh_SSL_SESSION_delete(ctx->sessions, c);
                             ^
      803.               SSL_SESSION_list_remove(ctx, c);
      804.           }

crypto/lhash/lhash.c:209:1: <LHS trace>
207.   }
208.   
209. > void *lh_delete(_LHASH *lh, const void *data)
210.   {
211.       unsigned long hash;

crypto/lhash/lhash.c:209:1: Parameter `lh->num_items`
        207.   }
        208.   
        209. > void *lh_delete(_LHASH *lh, const void *data)
        210.   {
        211.       unsigned long hash;

crypto/lhash/lhash.c:229:5: Binary operation: ([0, max(0, s->initial_ctx->sessions->num_items)] - 1):unsigned64 by call to `ssl3_get_new_session_ticket` 
        227.       }
        228.   
        229.       lh->num_items--;
                   ^
        230.       if ((lh->num_nodes > MIN_NODES) &&
        231.           (lh->down_load >= (lh->num_items * LH_LOAD_MULT / lh->num_nodes)))

void *lh_delete(_LHASH *lh, const void *data)
{
    unsigned long hash;
    LHASH_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 ssl3_connect(SSL *s)\n{\n    BUF_MEM *buf = NULL;\n    unsigned long Time = (unsigned long)time(NULL);\n    void (*cb) (const SSL *ssl, int type, int val) = NULL;\n    int ret = -1;\n    int new_state, state, skip = 0;\n    RAND_add(&Time, sizeof(Time), 0);\n    ERR_clear_error();\n    clear_sys_error();\n    if (s->info_callback != NULL)\n        cb = s->info_callback;\n    else if (s->ctx->info_callback != NULL)\n        cb = s->ctx->info_callback;\n    s->in_handshake++;\n    if (!SSL_in_init(s) || SSL_in_before(s)) {\n        if (!SSL_clear(s))\n            return -1;\n    }\n#ifndef OPENSSL_NO_HEARTBEATS\n    if (s->tlsext_hb_pending) {\n        s->tlsext_hb_pending = 0;\n        s->tlsext_hb_seq++;\n    }\n#endif\n    for (;;) {\n        state = s->state;\n        switch (s->state) {\n        case SSL_ST_RENEGOTIATE:\n            s->renegotiate = 1;\n            s->state = SSL_ST_CONNECT;\n            s->ctx->stats.sess_connect_renegotiate++;\n        case SSL_ST_BEFORE:\n        case SSL_ST_CONNECT:\n        case SSL_ST_BEFORE | SSL_ST_CONNECT:\n        case SSL_ST_OK | SSL_ST_CONNECT:\n            s->server = 0;\n            if (cb != NULL)\n                cb(s, SSL_CB_HANDSHAKE_START, 1);\n            if ((s->version >> 8) != SSL3_VERSION_MAJOR\n                    && s->version != TLS_ANY_VERSION) {\n                SSLerr(SSL_F_SSL3_CONNECT, ERR_R_INTERNAL_ERROR);\n                s->state = SSL_ST_ERR;\n                ret = -1;\n                goto end;\n            }\n            if (s->version != TLS_ANY_VERSION &&\n                    !ssl_security(s, SSL_SECOP_VERSION, 0, s->version, NULL)) {\n                SSLerr(SSL_F_SSL3_CONNECT, SSL_R_VERSION_TOO_LOW);\n                return -1;\n            }\n            s->type = SSL_ST_CONNECT;\n            if (s->init_buf == NULL) {\n                if ((buf = BUF_MEM_new()) == NULL) {\n                    ret = -1;\n                    s->state = SSL_ST_ERR;\n                    goto end;\n                }\n                if (!BUF_MEM_grow(buf, SSL3_RT_MAX_PLAIN_LENGTH)) {\n                    ret = -1;\n                    s->state = SSL_ST_ERR;\n                    goto end;\n                }\n                s->init_buf = buf;\n                buf = NULL;\n            }\n            if (!ssl3_setup_buffers(s)) {\n                ret = -1;\n                goto end;\n            }\n            if (!ssl_init_wbio_buffer(s, 0)) {\n                ret = -1;\n                s->state = SSL_ST_ERR;\n                goto end;\n            }\n            ssl3_init_finished_mac(s);\n            s->state = SSL3_ST_CW_CLNT_HELLO_A;\n            s->ctx->stats.sess_connect++;\n            s->init_num = 0;\n            s->s3->change_cipher_spec = 0;\n            break;\n        case SSL3_ST_CW_CLNT_HELLO_A:\n        case SSL3_ST_CW_CLNT_HELLO_B:\n            s->shutdown = 0;\n            ret = ssl3_client_hello(s);\n            if (ret <= 0)\n                goto end;\n            s->state = SSL3_ST_CR_SRVR_HELLO_A;\n            s->init_num = 0;\n            if (s->bbio != s->wbio)\n                s->wbio = BIO_push(s->bbio, s->wbio);\n            break;\n        case SSL3_ST_CR_SRVR_HELLO_A:\n        case SSL3_ST_CR_SRVR_HELLO_B:\n            ret = ssl3_get_server_hello(s);\n            if (ret <= 0)\n                goto end;\n            if (s->hit) {\n                s->state = SSL3_ST_CR_CHANGE_A;\n                if (s->tlsext_ticket_expected) {\n                    s->state = SSL3_ST_CR_SESSION_TICKET_A;\n                }\n            } else {\n                s->state = SSL3_ST_CR_CERT_A;\n            }\n            s->init_num = 0;\n            break;\n        case SSL3_ST_CR_CERT_A:\n        case SSL3_ST_CR_CERT_B:\n            ret = ssl3_check_change(s);\n            if (ret < 0)\n                goto end;\n            if (ret == 1) {\n                s->hit = 1;\n                s->state = SSL3_ST_CR_CHANGE_A;\n                s->init_num = 0;\n                break;\n            }\n            if (!(s->s3->tmp.new_cipher->algorithm_auth &\n                    (SSL_aNULL | SSL_aSRP | SSL_aPSK))) {\n                ret = ssl3_get_server_certificate(s);\n                if (ret <= 0)\n                    goto end;\n                if (s->tlsext_status_expected)\n                    s->state = SSL3_ST_CR_CERT_STATUS_A;\n                else\n                    s->state = SSL3_ST_CR_KEY_EXCH_A;\n            } else {\n                skip = 1;\n                s->state = SSL3_ST_CR_KEY_EXCH_A;\n            }\n            s->init_num = 0;\n            break;\n        case SSL3_ST_CR_KEY_EXCH_A:\n        case SSL3_ST_CR_KEY_EXCH_B:\n            ret = ssl3_get_key_exchange(s);\n            if (ret <= 0)\n                goto end;\n            s->state = SSL3_ST_CR_CERT_REQ_A;\n            s->init_num = 0;\n            if (!ssl3_check_cert_and_algorithm(s)) {\n                ret = -1;\n                s->state = SSL_ST_ERR;\n                goto end;\n            }\n            break;\n        case SSL3_ST_CR_CERT_REQ_A:\n        case SSL3_ST_CR_CERT_REQ_B:\n            ret = ssl3_get_certificate_request(s);\n            if (ret <= 0)\n                goto end;\n            s->state = SSL3_ST_CR_SRVR_DONE_A;\n            s->init_num = 0;\n            break;\n        case SSL3_ST_CR_SRVR_DONE_A:\n        case SSL3_ST_CR_SRVR_DONE_B:\n            ret = ssl3_get_server_done(s);\n            if (ret <= 0)\n                goto end;\n#ifndef OPENSSL_NO_SRP\n            if (s->s3->tmp.new_cipher->algorithm_mkey & SSL_kSRP) {\n                if ((ret = SRP_Calc_A_param(s)) <= 0) {\n                    SSLerr(SSL_F_SSL3_CONNECT, SSL_R_SRP_A_CALC);\n                    ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_INTERNAL_ERROR);\n                    s->state = SSL_ST_ERR;\n                    goto end;\n                }\n            }\n#endif\n            if (s->s3->tmp.cert_req)\n                s->state = SSL3_ST_CW_CERT_A;\n            else\n                s->state = SSL3_ST_CW_KEY_EXCH_A;\n            s->init_num = 0;\n            break;\n        case SSL3_ST_CW_CERT_A:\n        case SSL3_ST_CW_CERT_B:\n        case SSL3_ST_CW_CERT_C:\n        case SSL3_ST_CW_CERT_D:\n            ret = ssl3_send_client_certificate(s);\n            if (ret <= 0)\n                goto end;\n            s->state = SSL3_ST_CW_KEY_EXCH_A;\n            s->init_num = 0;\n            break;\n        case SSL3_ST_CW_KEY_EXCH_A:\n        case SSL3_ST_CW_KEY_EXCH_B:\n            ret = ssl3_send_client_key_exchange(s);\n            if (ret <= 0)\n                goto end;\n            if (s->s3->tmp.cert_req == 1) {\n                s->state = SSL3_ST_CW_CERT_VRFY_A;\n            } else {\n                s->state = SSL3_ST_CW_CHANGE_A;\n            }\n            if (s->s3->flags & TLS1_FLAGS_SKIP_CERT_VERIFY) {\n                s->state = SSL3_ST_CW_CHANGE_A;\n            }\n            s->init_num = 0;\n            break;\n        case SSL3_ST_CW_CERT_VRFY_A:\n        case SSL3_ST_CW_CERT_VRFY_B:\n            ret = ssl3_send_client_verify(s);\n            if (ret <= 0)\n                goto end;\n            s->state = SSL3_ST_CW_CHANGE_A;\n            s->init_num = 0;\n            break;\n        case SSL3_ST_CW_CHANGE_A:\n        case SSL3_ST_CW_CHANGE_B:\n            ret = ssl3_send_change_cipher_spec(s,\n                                               SSL3_ST_CW_CHANGE_A,\n                                               SSL3_ST_CW_CHANGE_B);\n            if (ret <= 0)\n                goto end;\n#if defined(OPENSSL_NO_NEXTPROTONEG)\n            s->state = SSL3_ST_CW_FINISHED_A;\n#else\n            if (s->s3->next_proto_neg_seen)\n                s->state = SSL3_ST_CW_NEXT_PROTO_A;\n            else\n                s->state = SSL3_ST_CW_FINISHED_A;\n#endif\n            s->init_num = 0;\n            s->session->cipher = s->s3->tmp.new_cipher;\n#ifdef OPENSSL_NO_COMP\n            s->session->compress_meth = 0;\n#else\n            if (s->s3->tmp.new_compression == NULL)\n                s->session->compress_meth = 0;\n            else\n                s->session->compress_meth = s->s3->tmp.new_compression->id;\n#endif\n            if (!s->method->ssl3_enc->setup_key_block(s)) {\n                ret = -1;\n                s->state = SSL_ST_ERR;\n                goto end;\n            }\n            if (!s->method->ssl3_enc->change_cipher_state(s,\n                                                          SSL3_CHANGE_CIPHER_CLIENT_WRITE))\n            {\n                ret = -1;\n                s->state = SSL_ST_ERR;\n                goto end;\n            }\n            break;\n#if !defined(OPENSSL_NO_NEXTPROTONEG)\n        case SSL3_ST_CW_NEXT_PROTO_A:\n        case SSL3_ST_CW_NEXT_PROTO_B:\n            ret = ssl3_send_next_proto(s);\n            if (ret <= 0)\n                goto end;\n            s->state = SSL3_ST_CW_FINISHED_A;\n            break;\n#endif\n        case SSL3_ST_CW_FINISHED_A:\n        case SSL3_ST_CW_FINISHED_B:\n            ret = ssl3_send_finished(s,\n                                     SSL3_ST_CW_FINISHED_A,\n                                     SSL3_ST_CW_FINISHED_B,\n                                     s->method->\n                                     ssl3_enc->client_finished_label,\n                                     s->method->\n                                     ssl3_enc->client_finished_label_len);\n            if (ret <= 0)\n                goto end;\n            s->state = SSL3_ST_CW_FLUSH;\n            if (s->hit) {\n                s->s3->tmp.next_state = SSL_ST_OK;\n            } else {\n                if (s->tlsext_ticket_expected)\n                    s->s3->tmp.next_state = SSL3_ST_CR_SESSION_TICKET_A;\n                else\n                    s->s3->tmp.next_state = SSL3_ST_CR_CHANGE_A;\n            }\n            s->init_num = 0;\n            break;\n        case SSL3_ST_CR_SESSION_TICKET_A:\n        case SSL3_ST_CR_SESSION_TICKET_B:\n            ret = ssl3_get_new_session_ticket(s);\n            if (ret <= 0)\n                goto end;\n            s->state = SSL3_ST_CR_CHANGE_A;\n            s->init_num = 0;\n            break;\n        case SSL3_ST_CR_CERT_STATUS_A:\n        case SSL3_ST_CR_CERT_STATUS_B:\n            ret = ssl3_get_cert_status(s);\n            if (ret <= 0)\n                goto end;\n            s->state = SSL3_ST_CR_KEY_EXCH_A;\n            s->init_num = 0;\n            break;\n        case SSL3_ST_CR_CHANGE_A:\n        case SSL3_ST_CR_CHANGE_B:\n            ret = ssl3_get_change_cipher_spec(s, SSL3_ST_CR_CHANGE_A,\n                                              SSL3_ST_CR_CHANGE_B);\n            if (ret <= 0)\n                goto end;\n            s->state = SSL3_ST_CR_FINISHED_A;\n            s->init_num = 0;\n            break;\n        case SSL3_ST_CR_FINISHED_A:\n        case SSL3_ST_CR_FINISHED_B:\n            ret = ssl3_get_finished(s, SSL3_ST_CR_FINISHED_A,\n                                    SSL3_ST_CR_FINISHED_B);\n            if (ret <= 0)\n                goto end;\n            if (s->hit)\n                s->state = SSL3_ST_CW_CHANGE_A;\n            else\n                s->state = SSL_ST_OK;\n            s->init_num = 0;\n            break;\n        case SSL3_ST_CW_FLUSH:\n            s->rwstate = SSL_WRITING;\n            if (BIO_flush(s->wbio) <= 0) {\n                ret = -1;\n                goto end;\n            }\n            s->rwstate = SSL_NOTHING;\n            s->state = s->s3->tmp.next_state;\n            break;\n        case SSL_ST_OK:\n            ssl3_cleanup_key_block(s);\n            BUF_MEM_free(s->init_buf);\n            s->init_buf = NULL;\n            ssl_free_wbio_buffer(s);\n            s->init_num = 0;\n            s->renegotiate = 0;\n            s->new_session = 0;\n            ssl_update_cache(s, SSL_SESS_CACHE_CLIENT);\n            if (s->hit)\n                s->ctx->stats.sess_hit++;\n            ret = 1;\n            s->handshake_func = ssl3_connect;\n            s->ctx->stats.sess_connect_good++;\n            if (cb != NULL)\n                cb(s, SSL_CB_HANDSHAKE_DONE, 1);\n            goto end;\n        case SSL_ST_ERR:\n        default:\n            SSLerr(SSL_F_SSL3_CONNECT, SSL_R_UNKNOWN_STATE);\n            ret = -1;\n            goto end;\n        }\n        if (!s->s3->tmp.reuse_message && !skip) {\n            if (s->debug) {\n                if ((ret = BIO_flush(s->wbio)) <= 0)\n                    goto end;\n            }\n            if ((cb != NULL) && (s->state != state)) {\n                new_state = s->state;\n                s->state = state;\n                cb(s, SSL_CB_CONNECT_LOOP, 1);\n                s->state = new_state;\n            }\n        }\n        skip = 0;\n    }\n end:\n    s->in_handshake--;\n    BUF_MEM_free(buf);\n    if (cb != NULL)\n        cb(s, SSL_CB_CONNECT_EXIT, ret);\n    return (ret);\n}', 'int ssl3_get_new_session_ticket(SSL *s)\n{\n    int ok, al, ret = 0;\n    unsigned int ticklen;\n    long n;\n    PACKET pkt;\n    n = s->method->ssl_get_message(s,\n                                   SSL3_ST_CR_SESSION_TICKET_A,\n                                   SSL3_ST_CR_SESSION_TICKET_B,\n                                   SSL3_MT_NEWSESSION_TICKET, 16384, &ok);\n    if (!ok)\n        return ((int)n);\n    if (!PACKET_buf_init(&pkt, s->init_msg, n)) {\n        al = SSL_AD_INTERNAL_ERROR;\n        SSLerr(SSL_F_SSL3_GET_NEW_SESSION_TICKET, ERR_R_INTERNAL_ERROR);\n        goto f_err;\n    }\n    if (s->session->session_id_length > 0) {\n        int i = s->session_ctx->session_cache_mode;\n        SSL_SESSION *new_sess;\n        if (i & SSL_SESS_CACHE_CLIENT) {\n            if (i & SSL_SESS_CACHE_NO_INTERNAL_STORE) {\n                if (s->session_ctx->remove_session_cb != NULL)\n                    s->session_ctx->remove_session_cb(s->session_ctx,\n                                                      s->session);\n            } else {\n                SSL_CTX_remove_session(s->session_ctx, s->session);\n            }\n        }\n        if ((new_sess = ssl_session_dup(s->session, 0)) == 0) {\n            al = SSL_AD_INTERNAL_ERROR;\n            SSLerr(SSL_F_SSL3_GET_NEW_SESSION_TICKET, ERR_R_MALLOC_FAILURE);\n            goto f_err;\n        }\n        SSL_SESSION_free(s->session);\n        s->session = new_sess;\n    }\n    if (!PACKET_get_net_4(&pkt, &s->session->tlsext_tick_lifetime_hint)\n            || !PACKET_get_net_2(&pkt, &ticklen)\n            || PACKET_remaining(&pkt) != ticklen) {\n        al = SSL_AD_DECODE_ERROR;\n        SSLerr(SSL_F_SSL3_GET_NEW_SESSION_TICKET, SSL_R_LENGTH_MISMATCH);\n        goto f_err;\n    }\n    OPENSSL_free(s->session->tlsext_tick);\n    s->session->tlsext_ticklen = 0;\n    s->session->tlsext_tick = OPENSSL_malloc(ticklen);\n    if (!s->session->tlsext_tick) {\n        SSLerr(SSL_F_SSL3_GET_NEW_SESSION_TICKET, ERR_R_MALLOC_FAILURE);\n        goto err;\n    }\n    if (!PACKET_copy_bytes(&pkt, s->session->tlsext_tick, ticklen)) {\n        al = SSL_AD_DECODE_ERROR;\n        SSLerr(SSL_F_SSL3_GET_NEW_SESSION_TICKET, SSL_R_LENGTH_MISMATCH);\n        goto f_err;\n    }\n    s->session->tlsext_ticklen = ticklen;\n    EVP_Digest(s->session->tlsext_tick, ticklen,\n               s->session->session_id, &s->session->session_id_length,\n               EVP_sha256(), NULL);\n    ret = 1;\n    return (ret);\n f_err:\n    ssl3_send_alert(s, SSL3_AL_FATAL, al);\n err:\n    s->state = SSL_ST_ERR;\n    return (-1);\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_w_lock(CRYPTO_LOCK_SSL_CTX);\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        if (lck)\n            CRYPTO_w_unlock(CRYPTO_LOCK_SSL_CTX);\n        if (ret) {\n            r->not_resumable = 1;\n            if (ctx->remove_session_cb != NULL)\n                ctx->remove_session_cb(ctx, r);\n            SSL_SESSION_free(r);\n        }\n    } else\n        ret = 0;\n    return (ret);\n}', 'void *lh_delete(_LHASH *lh, const void *data)\n{\n    unsigned long hash;\n    LHASH_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}']