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


ssl/statem/statem.c:495:1: Parameter `s->session_ctx->sessions->num_items`
493.    * will resume in the same state where we left off.
494.    */
495. > static SUB_STATE_RETURN read_state_machine(SSL *s)
496.   {
497.       OSSL_STATEM *st = &s->statem;

ssl/statem/statem.c:644:13: Call
642.           default:
643.               /* Shouldn't happen */
644.               ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_INTERNAL_ERROR);
                   ^
645.               SSLerr(SSL_F_READ_STATE_MACHINE, ERR_R_INTERNAL_ERROR);
646.               ossl_statem_set_error(s);

ssl/s3_msg.c:63:1: Parameter `s->session_ctx->sessions->num_items`
  61.   }
  62.   
  63. > int ssl3_send_alert(SSL *s, int level, int desc)
  64.   {
  65.       /* Map tls/ssl alert value to correct one */

ssl/s3_msg.c:77:9: Call
  75.       /* If a fatal one, remove from cache */
  76.       if ((level == SSL3_AL_FATAL) && (s->session != NULL))
  77.           SSL_CTX_remove_session(s->session_ctx, s->session);
                ^
  78.   
  79.       s->s3->alert_dispatch = 1;

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:721:1: Parameter `lh->num_items`
        719.   } TLSEXT_INDEX;
        720.   
        721. > DEFINE_LHASH_OF(SSL_SESSION);
        722.   /* Needed in ssl_cert.c */
        723.   DEFINE_LHASH_OF(X509_NAME);

ssl/ssl_locl.h:721:1: Call
        719.   } TLSEXT_INDEX;
        720.   
        721. > DEFINE_LHASH_OF(SSL_SESSION);
        722.   /* Needed in ssl_cert.c */
        723.   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->session_ctx->sessions->num_items)] - 1):unsigned64 by call to `ssl3_send_alert` 
          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);
}
['static SUB_STATE_RETURN read_state_machine(SSL *s)\n{\n    OSSL_STATEM *st = &s->statem;\n    int ret, mt;\n    size_t len = 0;\n    int (*transition) (SSL *s, int mt);\n    PACKET pkt;\n    MSG_PROCESS_RETURN(*process_message) (SSL *s, PACKET *pkt);\n    WORK_STATE(*post_process_message) (SSL *s, WORK_STATE wst);\n    size_t (*max_message_size) (SSL *s);\n    void (*cb) (const SSL *ssl, int type, int val) = NULL;\n    cb = get_callback(s);\n    if (s->server) {\n        transition = ossl_statem_server_read_transition;\n        process_message = ossl_statem_server_process_message;\n        max_message_size = ossl_statem_server_max_message_size;\n        post_process_message = ossl_statem_server_post_process_message;\n    } else {\n        transition = ossl_statem_client_read_transition;\n        process_message = ossl_statem_client_process_message;\n        max_message_size = ossl_statem_client_max_message_size;\n        post_process_message = ossl_statem_client_post_process_message;\n    }\n    if (st->read_state_first_init) {\n        s->first_packet = 1;\n        st->read_state_first_init = 0;\n    }\n    while (1) {\n        switch (st->read_state) {\n        case READ_STATE_HEADER:\n            if (SSL_IS_DTLS(s)) {\n                ret = dtls_get_message(s, &mt, &len);\n            } else {\n                ret = tls_get_message_header(s, &mt);\n            }\n            if (ret == 0) {\n                return SUB_STATE_ERROR;\n            }\n            if (cb != NULL) {\n                if (s->server)\n                    cb(s, SSL_CB_ACCEPT_LOOP, 1);\n                else\n                    cb(s, SSL_CB_CONNECT_LOOP, 1);\n            }\n            if (!transition(s, mt)) {\n                ossl_statem_set_error(s);\n                return SUB_STATE_ERROR;\n            }\n            if (s->s3->tmp.message_size > max_message_size(s)) {\n                ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_ILLEGAL_PARAMETER);\n                SSLerr(SSL_F_READ_STATE_MACHINE, SSL_R_EXCESSIVE_MESSAGE_SIZE);\n                return SUB_STATE_ERROR;\n            }\n            if (!SSL_IS_DTLS(s)\n                    && s->s3->tmp.message_size > 0\n                    && !grow_init_buf(s, s->s3->tmp.message_size\n                                         + SSL3_HM_HEADER_LENGTH)) {\n                ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_INTERNAL_ERROR);\n                SSLerr(SSL_F_READ_STATE_MACHINE, ERR_R_BUF_LIB);\n                return SUB_STATE_ERROR;\n            }\n            st->read_state = READ_STATE_BODY;\n        case READ_STATE_BODY:\n            if (!SSL_IS_DTLS(s)) {\n                ret = tls_get_message_body(s, &len);\n                if (ret == 0) {\n                    return SUB_STATE_ERROR;\n                }\n            }\n            s->first_packet = 0;\n            if (!PACKET_buf_init(&pkt, s->init_msg, len)) {\n                ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_INTERNAL_ERROR);\n                SSLerr(SSL_F_READ_STATE_MACHINE, ERR_R_INTERNAL_ERROR);\n                return SUB_STATE_ERROR;\n            }\n            ret = process_message(s, &pkt);\n            s->init_num = 0;\n            switch (ret) {\n            case MSG_PROCESS_ERROR:\n                return SUB_STATE_ERROR;\n            case MSG_PROCESS_FINISHED_READING:\n                if (SSL_IS_DTLS(s)) {\n                    dtls1_stop_timer(s);\n                }\n                return SUB_STATE_FINISHED;\n            case MSG_PROCESS_CONTINUE_PROCESSING:\n                st->read_state = READ_STATE_POST_PROCESS;\n                st->read_state_work = WORK_MORE_A;\n                break;\n            default:\n                st->read_state = READ_STATE_HEADER;\n                break;\n            }\n            break;\n        case READ_STATE_POST_PROCESS:\n            st->read_state_work = post_process_message(s, st->read_state_work);\n            switch (st->read_state_work) {\n            case WORK_ERROR:\n            case WORK_MORE_A:\n            case WORK_MORE_B:\n            case WORK_MORE_C:\n                return SUB_STATE_ERROR;\n            case WORK_FINISHED_CONTINUE:\n                st->read_state = READ_STATE_HEADER;\n                break;\n            case WORK_FINISHED_STOP:\n                if (SSL_IS_DTLS(s)) {\n                    dtls1_stop_timer(s);\n                }\n                return SUB_STATE_FINISHED;\n            }\n            break;\n        default:\n            ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_INTERNAL_ERROR);\n            SSLerr(SSL_F_READ_STATE_MACHINE, ERR_R_INTERNAL_ERROR);\n            ossl_statem_set_error(s);\n            return SUB_STATE_ERROR;\n        }\n    }\n}', 'int ssl3_send_alert(SSL *s, int level, int desc)\n{\n    if (SSL_TREAT_AS_TLS13(s))\n        desc = tls13_alert_code(desc);\n    else\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->session_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_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}']