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


ssl/statem.c:167:1: Parameter `s->ctx->sessions->num_items`
165.    * <=0: NBIO or error
166.    */
167. > int state_machine(SSL *s, int server) {
168.       BUF_MEM *buf = NULL;
169.       unsigned long Time = (unsigned long)time(NULL);

ssl/statem.c:306:17: Call
304.                   SSLerr(SSL_F_STATE_MACHINE,
305.                          SSL_R_UNSAFE_LEGACY_RENEGOTIATION_DISABLED);
306.                   ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_HANDSHAKE_FAILURE);
                       ^
307.                   statem_set_error(s);
308.                   goto end;

ssl/s3_msg.c:166:1: Parameter `s->ctx->sessions->num_items`
  164.   }
  165.   
  166. > int ssl3_send_alert(SSL *s, int level, int desc)
  167.   {
  168.       /* Map tls/ssl alert value to correct one */

ssl/s3_msg.c:177:9: Call
  175.       /* If a fatal one, remove from cache */
  176.       if ((level == SSL3_AL_FATAL) && (s->session != NULL))
  177.           SSL_CTX_remove_session(s->ctx, s->session);
                 ^
  178.   
  179.       s->s3->alert_dispatch = 1;

ssl/ssl_sess.c:776:1: Parameter `ctx->sessions->num_items`
    774.   }
    775.   
    776. > int SSL_CTX_remove_session(SSL_CTX *ctx, SSL_SESSION *c)
    777.   {
    778.       return remove_session_lock(ctx, c, 1);

ssl/ssl_sess.c:778:12: Call
    776.   int SSL_CTX_remove_session(SSL_CTX *ctx, SSL_SESSION *c)
    777.   {
    778.       return remove_session_lock(ctx, c, 1);
                      ^
    779.   }
    780.   

ssl/ssl_sess.c:781:1: Parameter `ctx->sessions->num_items`
      779.   }
      780.   
      781. > static int remove_session_lock(SSL_CTX *ctx, SSL_SESSION *c, int lck)
      782.   {
      783.       SSL_SESSION *r;

ssl/ssl_sess.c:791:17: Call
      789.           if ((r = lh_SSL_SESSION_retrieve(ctx->sessions, c)) == c) {
      790.               ret = 1;
      791.               r = lh_SSL_SESSION_delete(ctx->sessions, c);
                             ^
      792.               SSL_SESSION_list_remove(ctx, c);
      793.           }

crypto/lhash/lhash.c:189:1: <LHS trace>
187.   }
188.   
189. > void *lh_delete(_LHASH *lh, const void *data)
190.   {
191.       unsigned long hash;

crypto/lhash/lhash.c:189:1: Parameter `lh->num_items`
        187.   }
        188.   
        189. > void *lh_delete(_LHASH *lh, const void *data)
        190.   {
        191.       unsigned long hash;

crypto/lhash/lhash.c:209:5: Binary operation: ([0, max(0, s->ctx->sessions->num_items)] - 1):unsigned64 by call to `ssl3_send_alert` 
        207.       }
        208.   
        209.       lh->num_items--;
                   ^
        210.       if ((lh->num_nodes > MIN_NODES) &&
        211.           (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 state_machine(SSL *s, int server) {\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    STATEM *st = &s->statem;\n    int ret = -1;\n    int ssret;\n    if (st->state == MSG_FLOW_ERROR) {\n        return -1;\n    }\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        if (SSL_IS_DTLS(s))\n            dtls1_stop_timer(s);\n        s->tlsext_hb_pending = 0;\n        s->tlsext_hb_seq++;\n    }\n#endif\n    if (st->state == MSG_FLOW_RENEGOTIATE) {\n        s->renegotiate = 1;\n        if (!server)\n            s->ctx->stats.sess_connect_renegotiate++;\n    }\n    if (st->state == MSG_FLOW_UNINITED || st->state == MSG_FLOW_RENEGOTIATE) {\n        if (server)\n            s->state = SSL_ST_ACCEPT;\n        else\n            s->state = SSL_ST_CONNECT;\n        if (st->state == MSG_FLOW_UNINITED) {\n            st->hand_state = TLS_ST_BEFORE;\n        }\n        s->server = server;\n        if (cb != NULL)\n            cb(s, SSL_CB_HANDSHAKE_START, 1);\n        if (SSL_IS_DTLS(s)) {\n            if ((s->version & 0xff00) != (DTLS1_VERSION & 0xff00) &&\n                    (server\n                    || (s->version & 0xff00) != (DTLS1_BAD_VER & 0xff00))) {\n                SSLerr(SSL_F_STATE_MACHINE, ERR_R_INTERNAL_ERROR);\n                goto end;\n            }\n        } else {\n            if ((s->version >> 8) != SSL3_VERSION_MAJOR\n                    && s->version != TLS_ANY_VERSION) {\n                SSLerr(SSL_F_STATE_MACHINE, ERR_R_INTERNAL_ERROR);\n                goto end;\n            }\n        }\n        if (s->version != TLS_ANY_VERSION &&\n                !ssl_security(s, SSL_SECOP_VERSION, 0, s->version, NULL)) {\n            SSLerr(SSL_F_STATE_MACHINE, SSL_R_VERSION_TOO_LOW);\n            goto end;\n        }\n        if (server)\n            s->type = SSL_ST_ACCEPT;\n        else\n            s->type = SSL_ST_CONNECT;\n        if (s->init_buf == NULL) {\n            if ((buf = BUF_MEM_new()) == NULL) {\n                goto end;\n            }\n            if (!BUF_MEM_grow(buf, SSL3_RT_MAX_PLAIN_LENGTH)) {\n                goto end;\n            }\n            s->init_buf = buf;\n            buf = NULL;\n        }\n        if (!ssl3_setup_buffers(s)) {\n            goto end;\n        }\n        s->init_num = 0;\n        s->s3->change_cipher_spec = 0;\n        if (!server || st->state != MSG_FLOW_RENEGOTIATE) {\n#ifndef OPENSSL_NO_SCTP\n                if (!SSL_IS_DTLS(s) || !BIO_dgram_is_sctp(SSL_get_wbio(s)))\n#endif\n                    if (!ssl_init_wbio_buffer(s, server ? 1 : 0)) {\n                        goto end;\n                    }\n            ssl3_init_finished_mac(s);\n        }\n        if (server) {\n            if (st->state != MSG_FLOW_RENEGOTIATE) {\n                s->ctx->stats.sess_accept++;\n            } else if (!s->s3->send_connection_binding &&\n                       !(s->options &\n                         SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION)) {\n                SSLerr(SSL_F_STATE_MACHINE,\n                       SSL_R_UNSAFE_LEGACY_RENEGOTIATION_DISABLED);\n                ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_HANDSHAKE_FAILURE);\n                statem_set_error(s);\n                goto end;\n            } else {\n                s->ctx->stats.sess_accept_renegotiate++;\n            }\n        } else {\n            s->ctx->stats.sess_connect++;\n            memset(s->s3->client_random, 0, sizeof(s->s3->client_random));\n            s->hit = 0;\n            s->s3->tmp.cert_request = 0;\n            if (SSL_IS_DTLS(s)) {\n                st->use_timer = 1;\n            }\n        }\n        st->state = MSG_FLOW_WRITING;\n        init_write_state_machine(s);\n        st->read_state_first_init = 1;\n    }\n    while(st->state != MSG_FLOW_FINISHED) {\n        if(st->state == MSG_FLOW_READING) {\n            ssret = read_state_machine(s);\n            if (ssret == SUB_STATE_FINISHED) {\n                st->state = MSG_FLOW_WRITING;\n                init_write_state_machine(s);\n            } else {\n                goto end;\n            }\n        } else if (st->state == MSG_FLOW_WRITING) {\n            ssret = write_state_machine(s);\n            if (ssret == SUB_STATE_FINISHED) {\n                st->state = MSG_FLOW_READING;\n                init_read_state_machine(s);\n            } else if (ssret == SUB_STATE_END_HANDSHAKE) {\n                st->state = MSG_FLOW_FINISHED;\n            } else {\n                goto end;\n            }\n        } else {\n            statem_set_error(s);\n            goto end;\n        }\n    }\n    st->state = MSG_FLOW_UNINITED;\n    ret = 1;\n end:\n    s->in_handshake--;\n    BUF_MEM_free(buf);\n    if (cb != NULL) {\n        if (server)\n            cb(s, SSL_CB_ACCEPT_EXIT, ret);\n        else\n            cb(s, SSL_CB_CONNECT_EXIT, ret);\n    }\n    return ret;\n}', 'int ssl3_send_alert(SSL *s, int level, int desc)\n{\n    desc = s->method->ssl3_enc->alert_value(desc);\n    if (s->version == SSL3_VERSION && desc == SSL_AD_PROTOCOL_VERSION)\n        desc = SSL_AD_HANDSHAKE_FAILURE;\n    if (desc < 0)\n        return -1;\n    if ((level == SSL3_AL_FATAL) && (s->session != NULL))\n        SSL_CTX_remove_session(s->ctx, s->session);\n    s->s3->alert_dispatch = 1;\n    s->s3->send_alert[0] = level;\n    s->s3->send_alert[1] = desc;\n    if (!RECORD_LAYER_write_pending(&s->rlayer)) {\n        return s->method->ssl_dispatch_alert(s);\n    }\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}']