ssl/d1_both.c:530: 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/d1_both.c:445:1: Parameter `s->ctx->sessions->num_items`
443.    * messages arrive in fragments.
444.    */
445. > long dtls1_get_message(SSL *s, int st1, int stn, int mt, long max, int *ok)
446.   {
447.       int i, al;

ssl/d1_both.c:530:5: Call
528.   
529.    f_err:
530.       ssl3_send_alert(s, SSL3_AL_FATAL, al);
           ^
531.       *ok = 0;
532.       return -1;

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: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->ctx->sessions->num_items)] - 1):unsigned64 by call to `ssl3_send_alert` 
        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);
}
['long dtls1_get_message(SSL *s, int st1, int stn, int mt, long max, int *ok)\n{\n    int i, al;\n    struct hm_header_st *msg_hdr;\n    unsigned char *p;\n    unsigned long msg_len;\n    if (s->s3->tmp.reuse_message) {\n        s->s3->tmp.reuse_message = 0;\n        if ((mt >= 0) && (s->s3->tmp.message_type != mt)) {\n            al = SSL_AD_UNEXPECTED_MESSAGE;\n            SSLerr(SSL_F_DTLS1_GET_MESSAGE, SSL_R_UNEXPECTED_MESSAGE);\n            goto f_err;\n        }\n        *ok = 1;\n        s->init_msg = s->init_buf->data + DTLS1_HM_HEADER_LENGTH;\n        s->init_num = (int)s->s3->tmp.message_size;\n        return s->init_num;\n    }\n    msg_hdr = &s->d1->r_msg_hdr;\n    memset(msg_hdr, 0, sizeof(*msg_hdr));\n again:\n    i = dtls1_get_message_fragment(s, st1, stn, mt, max, ok);\n    if (i == DTLS1_HM_BAD_FRAGMENT || i == DTLS1_HM_FRAGMENT_RETRY) {\n        goto again;\n    } else if (i <= 0 && !*ok) {\n        return i;\n    }\n    if (mt >= 0 && s->s3->tmp.message_type != mt) {\n        al = SSL_AD_UNEXPECTED_MESSAGE;\n        SSLerr(SSL_F_DTLS1_GET_MESSAGE, SSL_R_UNEXPECTED_MESSAGE);\n        goto f_err;\n    }\n    p = (unsigned char *)s->init_buf->data;\n    if (mt == SSL3_MT_CHANGE_CIPHER_SPEC) {\n        if (s->msg_callback) {\n            s->msg_callback(0, s->version, SSL3_RT_CHANGE_CIPHER_SPEC,\n                            p, 1, s, s->msg_callback_arg);\n        }\n        return i;\n    }\n    msg_len = msg_hdr->msg_len;\n    *(p++) = msg_hdr->type;\n    l2n3(msg_len, p);\n    s2n(msg_hdr->seq, p);\n    l2n3(0, p);\n    l2n3(msg_len, p);\n    if (s->version != DTLS1_BAD_VER) {\n        p -= DTLS1_HM_HEADER_LENGTH;\n        msg_len += DTLS1_HM_HEADER_LENGTH;\n    }\n    ssl3_finish_mac(s, p, msg_len);\n    if (s->msg_callback)\n        s->msg_callback(0, s->version, SSL3_RT_HANDSHAKE,\n                        p, msg_len, s, s->msg_callback_arg);\n    memset(msg_hdr, 0, sizeof(*msg_hdr));\n    if (!s->d1->listen)\n        s->d1->handshake_read_seq++;\n    s->init_msg = s->init_buf->data + DTLS1_HM_HEADER_LENGTH;\n    return s->init_num;\n f_err:\n    ssl3_send_alert(s, SSL3_AL_FATAL, al);\n    *ok = 0;\n    return -1;\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}']