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


ssl/statem/statem.c:519:1: Parameter `s->ctx->sessions->num_items`
517.    * will resume in the same state where we left off.
518.    */
519. > static SUB_STATE_RETURN read_state_machine(SSL *s) {
520.       OSSL_STATEM *st = &s->statem;
521.       int ret, mt;

ssl/statem/statem.c:560:23: Call
558.                   ret = dtls_get_message(s, &mt, &len);
559.               } else {
560.                   ret = tls_get_message_header(s, &mt);
                             ^
561.               }
562.   

ssl/statem/statem_lib.c:440:1: Parameter `s->ctx->sessions->num_items`
  438.   }
  439.   
  440. > int tls_get_message_header(SSL *s, int *mt)
  441.   {
  442.       /* s->init_num < SSL3_HM_HEADER_LENGTH */

ssl/statem/statem_lib.c:534:5: Call
  532.       return 1;
  533.    f_err:
  534.       ssl3_send_alert(s, SSL3_AL_FATAL, al);
             ^
  535.    err:
  536.       return 0;

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:785:1: Parameter `ctx->sessions->num_items`
      783.   }
      784.   
      785. > int SSL_CTX_remove_session(SSL_CTX *ctx, SSL_SESSION *c)
      786.   {
      787.       return remove_session_lock(ctx, c, 1);

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

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

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

ssl/ssl_locl.h:697:1: Parameter `lh->num_items`
          695.   
          696.   DEFINE_STACK_OF(SSL_COMP)
          697. > DEFINE_LHASH_OF(SSL_SESSION);
          698.   
          699.   

ssl/ssl_locl.h:697:1: Call
          695.   
          696.   DEFINE_STACK_OF(SSL_COMP)
          697. > DEFINE_LHASH_OF(SSL_SESSION);
          698.   
          699.   

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 `tls_get_message_header` 
            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);
}
['static SUB_STATE_RETURN read_state_machine(SSL *s) {\n    OSSL_STATEM *st = &s->statem;\n    int ret, mt;\n    unsigned long 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    unsigned long (*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            s->init_num = 0;\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                ssl3_send_alert(s, SSL3_AL_FATAL, SSL3_AD_UNEXPECTED_MESSAGE);\n                SSLerr(SSL_F_READ_STATE_MACHINE, SSL_R_UNEXPECTED_MESSAGE);\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            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            if (ret == MSG_PROCESS_ERROR) {\n                return SUB_STATE_ERROR;\n            }\n            if (ret == MSG_PROCESS_FINISHED_READING) {\n                if (SSL_IS_DTLS(s)) {\n                    dtls1_stop_timer(s);\n                }\n                return SUB_STATE_FINISHED;\n            }\n            if (ret == MSG_PROCESS_CONTINUE_PROCESSING) {\n                st->read_state = READ_STATE_POST_PROCESS;\n                st->read_state_work = WORK_MORE_A;\n            } else {\n                st->read_state = READ_STATE_HEADER;\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            default:\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 tls_get_message_header(SSL *s, int *mt)\n{\n    int skip_message, i, recvd_type, al;\n    unsigned char *p;\n    unsigned long l;\n    p = (unsigned char *)s->init_buf->data;\n    do {\n        while (s->init_num < SSL3_HM_HEADER_LENGTH) {\n            i = s->method->ssl_read_bytes(s, SSL3_RT_HANDSHAKE, &recvd_type,\n                &p[s->init_num], SSL3_HM_HEADER_LENGTH - s->init_num, 0);\n            if (i <= 0) {\n                s->rwstate = SSL_READING;\n                return 0;\n            }\n            if (recvd_type == SSL3_RT_CHANGE_CIPHER_SPEC) {\n                s->s3->tmp.message_type = *mt = SSL3_MT_CHANGE_CIPHER_SPEC;\n                s->init_num = i - 1;\n                s->s3->tmp.message_size = i;\n                return 1;\n            } else if (recvd_type != SSL3_RT_HANDSHAKE) {\n                al = SSL_AD_UNEXPECTED_MESSAGE;\n                SSLerr(SSL_F_TLS_GET_MESSAGE_HEADER, SSL_R_CCS_RECEIVED_EARLY);\n                goto f_err;\n            }\n            s->init_num += i;\n        }\n        skip_message = 0;\n        if (!s->server)\n            if (p[0] == SSL3_MT_HELLO_REQUEST)\n                if (p[1] == 0 && p[2] == 0 && p[3] == 0) {\n                    s->init_num = 0;\n                    skip_message = 1;\n                    if (s->msg_callback)\n                        s->msg_callback(0, s->version, SSL3_RT_HANDSHAKE,\n                                        p, SSL3_HM_HEADER_LENGTH, s,\n                                        s->msg_callback_arg);\n                }\n    } while (skip_message);\n    *mt = *p;\n    s->s3->tmp.message_type = *(p++);\n    if(RECORD_LAYER_is_sslv2_record(&s->rlayer)) {\n        l = RECORD_LAYER_get_rrec_length(&s->rlayer)\n            + SSL3_HM_HEADER_LENGTH;\n        if (l && !BUF_MEM_grow_clean(s->init_buf, (int)l)) {\n            SSLerr(SSL_F_TLS_GET_MESSAGE_HEADER, ERR_R_BUF_LIB);\n            goto err;\n        }\n        s->s3->tmp.message_size = l;\n        s->init_msg = s->init_buf->data;\n        s->init_num = SSL3_HM_HEADER_LENGTH;\n    } else {\n        n2l3(p, l);\n        if (l > (INT_MAX - SSL3_HM_HEADER_LENGTH)) {\n            al = SSL_AD_ILLEGAL_PARAMETER;\n            SSLerr(SSL_F_TLS_GET_MESSAGE_HEADER, SSL_R_EXCESSIVE_MESSAGE_SIZE);\n            goto f_err;\n        }\n        if (l && !BUF_MEM_grow_clean(s->init_buf,\n                                    (int)l + SSL3_HM_HEADER_LENGTH)) {\n            SSLerr(SSL_F_TLS_GET_MESSAGE_HEADER, ERR_R_BUF_LIB);\n            goto err;\n        }\n        s->s3->tmp.message_size = l;\n        s->init_msg = s->init_buf->data + SSL3_HM_HEADER_LENGTH;\n        s->init_num = 0;\n    }\n    return 1;\n f_err:\n    ssl3_send_alert(s, SSL3_AL_FATAL, al);\n err:\n    return 0;\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}', 'DEFINE_LHASH_OF(SSL_SESSION)', '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}']