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


ssl/record/ssl3_record.c:1382:1: Parameter `s->ctx->sessions->num_items`
1380.    */
1381.   /* used only by dtls1_read_bytes */
1382. > int dtls1_get_record(SSL *s)
1383.   {
1384.       int ssl_major, ssl_minor;

ssl/record/ssl3_record.c:1398:9: Call
1396.        * This is a non-blocking operation.
1397.        */
1398.       if (dtls1_process_buffered_records(s) < 0)
                ^
1399.           return -1;
1400.   

ssl/record/rec_layer_d1.c:353:1: Parameter `s->ctx->sessions->num_items`
  351.   
  352.   
  353. > int dtls1_process_buffered_records(SSL *s)
  354.   {
  355.       pitem *item;

ssl/record/ssl3_record.c:1548:10: Call
1546.       }
1547.   
1548.       if (!dtls1_process_record(s)) {
                 ^
1549.           rr->length = 0;
1550.           RECORD_LAYER_reset_packet_length(&s->rlayer);   /* dump this record */

ssl/record/ssl3_record.c:1199:1: Parameter `s->ctx->sessions->num_items`
  1197.   }
  1198.   
  1199. > int dtls1_process_record(SSL *s)
  1200.   {
  1201.       int i, al;

ssl/record/ssl3_record.c:1358:5: Call
  1356.   
  1357.    f_err:
  1358.       ssl3_send_alert(s, SSL3_AL_FATAL, al);
              ^
  1359.    err:
  1360.       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:675:1: Parameter `ctx->sessions->num_items`
      673.   }
      674.   
      675. > int SSL_CTX_remove_session(SSL_CTX *ctx, SSL_SESSION *c)
      676.   {
      677.       return remove_session_lock(ctx, c, 1);

ssl/ssl_sess.c:677:12: Call
      675.   int SSL_CTX_remove_session(SSL_CTX *ctx, SSL_SESSION *c)
      676.   {
      677.       return remove_session_lock(ctx, c, 1);
                        ^
      678.   }
      679.   

ssl/ssl_sess.c:680:1: Parameter `ctx->sessions->num_items`
        678.   }
        679.   
        680. > static int remove_session_lock(SSL_CTX *ctx, SSL_SESSION *c, int lck)
        681.   {
        682.       SSL_SESSION *r;

ssl/ssl_sess.c:690:17: Call
        688.           if ((r = lh_SSL_SESSION_retrieve(ctx->sessions, c)) == c) {
        689.               ret = 1;
        690.               r = lh_SSL_SESSION_delete(ctx->sessions, c);
                               ^
        691.               SSL_SESSION_list_remove(ctx, c);
        692.           }

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

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

crypto/lhash/lhash.c:231:5: Binary operation: ([0, max(0, s->ctx->sessions->num_items)] - 1):unsigned64 by call to `dtls1_process_record` 
          229.       }
          230.   
          231.       lh->num_items--;
                     ^
          232.       if ((lh->num_nodes > MIN_NODES) &&
          233.           (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 dtls1_get_record(SSL *s)\n{\n    int ssl_major, ssl_minor;\n    int i, n;\n    SSL3_RECORD *rr;\n    unsigned char *p = NULL;\n    unsigned short version;\n    DTLS1_BITMAP *bitmap;\n    unsigned int is_next_epoch;\n    rr = RECORD_LAYER_get_rrec(&s->rlayer);\n    if (dtls1_process_buffered_records(s) < 0)\n        return -1;\n    if (dtls1_get_processed_record(s))\n        return 1;\n again:\n    if ((RECORD_LAYER_get_rstate(&s->rlayer) != SSL_ST_READ_BODY) ||\n        (RECORD_LAYER_get_packet_length(&s->rlayer) < DTLS1_RT_HEADER_LENGTH)) {\n        n = ssl3_read_n(s, DTLS1_RT_HEADER_LENGTH,\n            SSL3_BUFFER_get_len(&s->rlayer.rbuf), 0);\n        if (n <= 0)\n            return (n);\n        if (RECORD_LAYER_get_packet_length(&s->rlayer) != DTLS1_RT_HEADER_LENGTH) {\n            RECORD_LAYER_reset_packet_length(&s->rlayer);\n            goto again;\n        }\n        RECORD_LAYER_set_rstate(&s->rlayer, SSL_ST_READ_BODY);\n        p = RECORD_LAYER_get_packet(&s->rlayer);\n        if (s->msg_callback)\n            s->msg_callback(0, 0, SSL3_RT_HEADER, p, DTLS1_RT_HEADER_LENGTH,\n                            s, s->msg_callback_arg);\n        rr->type = *(p++);\n        ssl_major = *(p++);\n        ssl_minor = *(p++);\n        version = (ssl_major << 8) | ssl_minor;\n        n2s(p, rr->epoch);\n        memcpy(&(RECORD_LAYER_get_read_sequence(&s->rlayer)[2]), p, 6);\n        p += 6;\n        n2s(p, rr->length);\n        if (!s->first_packet) {\n            if (version != s->version) {\n                rr->length = 0;\n                RECORD_LAYER_reset_packet_length(&s->rlayer);\n                goto again;\n            }\n        }\n        if ((version & 0xff00) != (s->version & 0xff00)) {\n            rr->length = 0;\n            RECORD_LAYER_reset_packet_length(&s->rlayer);\n            goto again;\n        }\n        if (rr->length > SSL3_RT_MAX_ENCRYPTED_LENGTH) {\n            rr->length = 0;\n            RECORD_LAYER_reset_packet_length(&s->rlayer);\n            goto again;\n        }\n    }\n    if (rr->length >\n        RECORD_LAYER_get_packet_length(&s->rlayer) - DTLS1_RT_HEADER_LENGTH) {\n        i = rr->length;\n        n = ssl3_read_n(s, i, i, 1);\n        if (n != i) {\n            rr->length = 0;\n            RECORD_LAYER_reset_packet_length(&s->rlayer);\n            goto again;\n        }\n    }\n    RECORD_LAYER_set_rstate(&s->rlayer, SSL_ST_READ_HEADER);\n    bitmap = dtls1_get_bitmap(s, rr, &is_next_epoch);\n    if (bitmap == NULL) {\n        rr->length = 0;\n        RECORD_LAYER_reset_packet_length(&s->rlayer);\n        goto again;\n    }\n#ifndef OPENSSL_NO_SCTP\n    if (!BIO_dgram_is_sctp(SSL_get_rbio(s))) {\n#endif\n        if (!(s->d1->listen && rr->type == SSL3_RT_HANDSHAKE &&\n              RECORD_LAYER_get_packet_length(&s->rlayer)\n                  > DTLS1_RT_HEADER_LENGTH &&\n              RECORD_LAYER_get_packet(&s->rlayer)[DTLS1_RT_HEADER_LENGTH]\n                  == SSL3_MT_CLIENT_HELLO) &&\n            !dtls1_record_replay_check(s, bitmap)) {\n            rr->length = 0;\n            RECORD_LAYER_reset_packet_length(&s->rlayer);\n            goto again;\n        }\n#ifndef OPENSSL_NO_SCTP\n    }\n#endif\n    if (rr->length == 0)\n        goto again;\n    if (is_next_epoch) {\n        if ((SSL_in_init(s) || s->in_handshake) && !s->d1->listen) {\n            if (dtls1_buffer_record\n                (s, &(DTLS_RECORD_LAYER_get_unprocessed_rcds(&s->rlayer)),\n                rr->seq_num) < 0)\n                return -1;\n            dtls1_record_bitmap_update(s, bitmap);\n        }\n        rr->length = 0;\n        RECORD_LAYER_reset_packet_length(&s->rlayer);\n        goto again;\n    }\n    if (!dtls1_process_record(s)) {\n        rr->length = 0;\n        RECORD_LAYER_reset_packet_length(&s->rlayer);\n        goto again;\n    }\n    dtls1_record_bitmap_update(s, bitmap);\n    return (1);\n}', 'int dtls1_process_buffered_records(SSL *s)\n{\n    pitem *item;\n    item = pqueue_peek(s->rlayer.d->unprocessed_rcds.q);\n    if (item) {\n        if (s->rlayer.d->unprocessed_rcds.epoch != s->rlayer.d->r_epoch)\n            return (1);\n        while (pqueue_peek(s->rlayer.d->unprocessed_rcds.q)) {\n            dtls1_get_unprocessed_record(s);\n            if (!dtls1_process_record(s))\n                return (0);\n            if (dtls1_buffer_record(s, &(s->rlayer.d->processed_rcds),\n                SSL3_RECORD_get_seq_num(&s->rlayer.rrec)) < 0)\n                return -1;\n        }\n    }\n    s->rlayer.d->processed_rcds.epoch = s->rlayer.d->r_epoch;\n    s->rlayer.d->unprocessed_rcds.epoch = s->rlayer.d->r_epoch + 1;\n    return (1);\n}', 'int dtls1_process_record(SSL *s)\n{\n    int i, al;\n    int enc_err;\n    SSL_SESSION *sess;\n    SSL3_RECORD *rr;\n    unsigned int mac_size;\n    unsigned char md[EVP_MAX_MD_SIZE];\n    rr = RECORD_LAYER_get_rrec(&s->rlayer);\n    sess = s->session;\n    rr->input = &(RECORD_LAYER_get_packet(&s->rlayer)[DTLS1_RT_HEADER_LENGTH]);\n    if (rr->length > SSL3_RT_MAX_ENCRYPTED_LENGTH) {\n        al = SSL_AD_RECORD_OVERFLOW;\n        SSLerr(SSL_F_DTLS1_PROCESS_RECORD, SSL_R_ENCRYPTED_LENGTH_TOO_LONG);\n        goto f_err;\n    }\n    rr->data = rr->input;\n    rr->orig_len = rr->length;\n    enc_err = s->method->ssl3_enc->enc(s, 0);\n    if (enc_err == 0) {\n        rr->length = 0;\n        RECORD_LAYER_reset_packet_length(&s->rlayer);\n        goto err;\n    }\n#ifdef TLS_DEBUG\n    printf("dec %d\\n", rr->length);\n    {\n        unsigned int z;\n        for (z = 0; z < rr->length; z++)\n            printf("%02X%c", rr->data[z], ((z + 1) % 16) ? \' \' : \'\\n\');\n    }\n    printf("\\n");\n#endif\n    if ((sess != NULL) &&\n        (s->enc_read_ctx != NULL) && (EVP_MD_CTX_md(s->read_hash) != NULL)) {\n        unsigned char *mac = NULL;\n        unsigned char mac_tmp[EVP_MAX_MD_SIZE];\n        mac_size = EVP_MD_CTX_size(s->read_hash);\n        OPENSSL_assert(mac_size <= EVP_MAX_MD_SIZE);\n        if (rr->orig_len < mac_size ||\n            (EVP_CIPHER_CTX_mode(s->enc_read_ctx) == EVP_CIPH_CBC_MODE &&\n             rr->orig_len < mac_size + 1)) {\n            al = SSL_AD_DECODE_ERROR;\n            SSLerr(SSL_F_DTLS1_PROCESS_RECORD, SSL_R_LENGTH_TOO_SHORT);\n            goto f_err;\n        }\n        if (EVP_CIPHER_CTX_mode(s->enc_read_ctx) == EVP_CIPH_CBC_MODE) {\n            mac = mac_tmp;\n            ssl3_cbc_copy_mac(mac_tmp, rr, mac_size);\n            rr->length -= mac_size;\n        } else {\n            rr->length -= mac_size;\n            mac = &rr->data[rr->length];\n        }\n        i = s->method->ssl3_enc->mac(s, md, 0   );\n        if (i < 0 || mac == NULL\n            || CRYPTO_memcmp(md, mac, (size_t)mac_size) != 0)\n            enc_err = -1;\n        if (rr->length > SSL3_RT_MAX_COMPRESSED_LENGTH + mac_size)\n            enc_err = -1;\n    }\n    if (enc_err < 0) {\n        rr->length = 0;\n        RECORD_LAYER_reset_packet_length(&s->rlayer);\n        goto err;\n    }\n    if (s->expand != NULL) {\n        if (rr->length > SSL3_RT_MAX_COMPRESSED_LENGTH) {\n            al = SSL_AD_RECORD_OVERFLOW;\n            SSLerr(SSL_F_DTLS1_PROCESS_RECORD,\n                   SSL_R_COMPRESSED_LENGTH_TOO_LONG);\n            goto f_err;\n        }\n        if (!ssl3_do_uncompress(s)) {\n            al = SSL_AD_DECOMPRESSION_FAILURE;\n            SSLerr(SSL_F_DTLS1_PROCESS_RECORD, SSL_R_BAD_DECOMPRESSION);\n            goto f_err;\n        }\n    }\n    if (rr->length > SSL3_RT_MAX_PLAIN_LENGTH) {\n        al = SSL_AD_RECORD_OVERFLOW;\n        SSLerr(SSL_F_DTLS1_PROCESS_RECORD, SSL_R_DATA_LENGTH_TOO_LONG);\n        goto f_err;\n    }\n    rr->off = 0;\n    RECORD_LAYER_reset_packet_length(&s->rlayer);\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}', '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}']