ssl/d1_pkt.c:679: error: INTEGER_OVERFLOW_L2
  ([0, 17727] - [0, 17728]):unsigned32 by call to `dtls1_process_record`.
Showing all 15 steps of the trace


ssl/d1_pkt.c:554:13: Assignment
552.           /* this packet contained a partial record, dump it */
553.           if (s->packet_length != DTLS1_RT_HEADER_LENGTH) {
554.               s->packet_length = 0;
                   ^
555.               goto again;
556.           }

ssl/d1_pkt.c:679:10: Call
677.       }
678.   
679.       if (!dtls1_process_record(s)) {
                ^
680.           rr->length = 0;
681.           s->packet_length = 0;   /* dump this record */

ssl/d1_pkt.c:345:1: Parameter `s->s3->rrec.length`
  343.   }
  344.   
  345. > static int dtls1_process_record(SSL *s)
  346.   {
  347.       int i, al;

ssl/d1_pkt.c:441:13: Call
  439.                */
  440.               mac = mac_tmp;
  441.               ssl3_cbc_copy_mac(mac_tmp, rr, mac_size);
                     ^
  442.               rr->length -= mac_size;
  443.           } else {

ssl/s3_cbc.c:220:1: Parameter `md_size`
    218.   #define CBC_MAC_ROTATE_IN_PLACE
    219.   
    220. > void ssl3_cbc_copy_mac(unsigned char *out,
    221.                          const SSL3_RECORD *rec, unsigned md_size)
    222.   {

ssl/s3_cbc.c:269:35: Call
    267.       for (i = scan_start, j = 0; i < rec->orig_len; i++) {
    268.           unsigned char mac_started = constant_time_ge_8(i, mac_start);
    269.           unsigned char mac_ended = constant_time_ge_8(i, mac_end);
                                             ^
    270.           unsigned char b = rec->data[i];
    271.           rotated_mac[j++] |= b & mac_started & ~mac_ended;

crypto/constant_time_locl.h:153:1: Parameter `a`
      151.   }
      152.   
      153. > static inline unsigned char constant_time_ge_8(unsigned int a, unsigned int b)
      154.   {
      155.       return (unsigned char)(constant_time_ge(a, b));

crypto/constant_time_locl.h:155:28: Call
      153.   static inline unsigned char constant_time_ge_8(unsigned int a, unsigned int b)
      154.   {
      155.       return (unsigned char)(constant_time_ge(a, b));
                                        ^
      156.   }
      157.   

crypto/constant_time_locl.h:148:1: Parameter `a`
        146.   }
        147.   
        148. > static inline unsigned int constant_time_ge(unsigned int a, unsigned int b)
        149.   {
        150.       return ~constant_time_lt(a, b);

crypto/constant_time_locl.h:150:13: Call
        148.   static inline unsigned int constant_time_ge(unsigned int a, unsigned int b)
        149.   {
        150.       return ~constant_time_lt(a, b);
                           ^
        151.   }
        152.   

crypto/constant_time_locl.h:138:1: <LHS trace>
136.   }
137.   
138. > static inline unsigned int constant_time_lt(unsigned int a, unsigned int b)
139.   {
140.       return constant_time_msb(a ^ ((a ^ b) | ((a - b) ^ b)));

crypto/constant_time_locl.h:138:1: Parameter `a`
          136.   }
          137.   
          138. > static inline unsigned int constant_time_lt(unsigned int a, unsigned int b)
          139.   {
          140.       return constant_time_msb(a ^ ((a ^ b) | ((a - b) ^ b)));

crypto/constant_time_locl.h:138:1: <RHS trace>
136.   }
137.   
138. > static inline unsigned int constant_time_lt(unsigned int a, unsigned int b)
139.   {
140.       return constant_time_msb(a ^ ((a ^ b) | ((a - b) ^ b)));

crypto/constant_time_locl.h:138:1: Parameter `b`
          136.   }
          137.   
          138. > static inline unsigned int constant_time_lt(unsigned int a, unsigned int b)
          139.   {
          140.       return constant_time_msb(a ^ ((a ^ b) | ((a - b) ^ b)));

crypto/constant_time_locl.h:140:12: Binary operation: ([0, 17727] - [0, 17728]):unsigned32 by call to `dtls1_process_record` 
          138.   static inline unsigned int constant_time_lt(unsigned int a, unsigned int b)
          139.   {
          140.       return constant_time_msb(a ^ ((a ^ b) | ((a - b) ^ b)));
                            ^
          141.   }
          142.   

static inline unsigned int constant_time_lt(unsigned int a, unsigned int b)
{
    return constant_time_msb(a ^ ((a ^ b) | ((a - b) ^ b)));
}
['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 = &(s->s3->rrec);\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 ((s->rstate != SSL_ST_READ_BODY) ||\n        (s->packet_length < DTLS1_RT_HEADER_LENGTH)) {\n        n = ssl3_read_n(s, DTLS1_RT_HEADER_LENGTH, s->s3->rbuf.len, 0);\n        if (n <= 0)\n            return (n);\n        if (s->packet_length != DTLS1_RT_HEADER_LENGTH) {\n            s->packet_length = 0;\n            goto again;\n        }\n        s->rstate = SSL_ST_READ_BODY;\n        p = s->packet;\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(&(s->s3->read_sequence[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                s->packet_length = 0;\n                goto again;\n            }\n        }\n        if ((version & 0xff00) != (s->version & 0xff00)) {\n            rr->length = 0;\n            s->packet_length = 0;\n            goto again;\n        }\n        if (rr->length > SSL3_RT_MAX_ENCRYPTED_LENGTH) {\n            rr->length = 0;\n            s->packet_length = 0;\n            goto again;\n        }\n    }\n    if (rr->length > s->packet_length - 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            s->packet_length = 0;\n            goto again;\n        }\n    }\n    s->rstate = SSL_ST_READ_HEADER;\n    bitmap = dtls1_get_bitmap(s, rr, &is_next_epoch);\n    if (bitmap == NULL) {\n        rr->length = 0;\n        s->packet_length = 0;\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              s->packet_length > DTLS1_RT_HEADER_LENGTH &&\n              s->packet[DTLS1_RT_HEADER_LENGTH] == SSL3_MT_CLIENT_HELLO) &&\n            !dtls1_record_replay_check(s, bitmap)) {\n            rr->length = 0;\n            s->packet_length = 0;\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, &(s->d1->unprocessed_rcds), rr->seq_num) < 0)\n                return -1;\n            dtls1_record_bitmap_update(s, bitmap);\n        }\n        rr->length = 0;\n        s->packet_length = 0;\n        goto again;\n    }\n    if (!dtls1_process_record(s)) {\n        rr->length = 0;\n        s->packet_length = 0;\n        goto again;\n    }\n    dtls1_record_bitmap_update(s, bitmap);\n    return (1);\n}', 'static 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 = &(s->s3->rrec);\n    sess = s->session;\n    rr->input = &(s->packet[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        s->packet_length = 0;\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        s->packet_length = 0;\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    s->packet_length = 0;\n    return (1);\n f_err:\n    ssl3_send_alert(s, SSL3_AL_FATAL, al);\n err:\n    return (0);\n}', 'void ssl3_cbc_copy_mac(unsigned char *out,\n                       const SSL3_RECORD *rec, unsigned md_size)\n{\n#if defined(CBC_MAC_ROTATE_IN_PLACE)\n    unsigned char rotated_mac_buf[64 + EVP_MAX_MD_SIZE];\n    unsigned char *rotated_mac;\n#else\n    unsigned char rotated_mac[EVP_MAX_MD_SIZE];\n#endif\n    unsigned mac_end = rec->length;\n    unsigned mac_start = mac_end - md_size;\n    unsigned scan_start = 0;\n    unsigned i, j;\n    unsigned div_spoiler;\n    unsigned rotate_offset;\n    OPENSSL_assert(rec->orig_len >= md_size);\n    OPENSSL_assert(md_size <= EVP_MAX_MD_SIZE);\n#if defined(CBC_MAC_ROTATE_IN_PLACE)\n    rotated_mac = rotated_mac_buf + ((0 - (size_t)rotated_mac_buf) & 63);\n#endif\n    if (rec->orig_len > md_size + 255 + 1)\n        scan_start = rec->orig_len - (md_size + 255 + 1);\n    div_spoiler = md_size >> 1;\n    div_spoiler <<= (sizeof(div_spoiler) - 1) * 8;\n    rotate_offset = (div_spoiler + mac_start - scan_start) % md_size;\n    memset(rotated_mac, 0, md_size);\n    for (i = scan_start, j = 0; i < rec->orig_len; i++) {\n        unsigned char mac_started = constant_time_ge_8(i, mac_start);\n        unsigned char mac_ended = constant_time_ge_8(i, mac_end);\n        unsigned char b = rec->data[i];\n        rotated_mac[j++] |= b & mac_started & ~mac_ended;\n        j &= constant_time_lt(j, md_size);\n    }\n#if defined(CBC_MAC_ROTATE_IN_PLACE)\n    j = 0;\n    for (i = 0; i < md_size; i++) {\n        ((volatile unsigned char *)rotated_mac)[rotate_offset ^ 32];\n        out[j++] = rotated_mac[rotate_offset++];\n        rotate_offset &= constant_time_lt(rotate_offset, md_size);\n    }\n#else\n    memset(out, 0, md_size);\n    rotate_offset = md_size - rotate_offset;\n    rotate_offset &= constant_time_lt(rotate_offset, md_size);\n    for (i = 0; i < md_size; i++) {\n        for (j = 0; j < md_size; j++)\n            out[j] |= rotated_mac[i] & constant_time_eq_8(j, rotate_offset);\n        rotate_offset++;\n        rotate_offset &= constant_time_lt(rotate_offset, md_size);\n    }\n#endif\n}', 'static inline unsigned char constant_time_ge_8(unsigned int a, unsigned int b)\n{\n    return (unsigned char)(constant_time_ge(a, b));\n}', 'static inline unsigned int constant_time_ge(unsigned int a, unsigned int b)\n{\n    return ~constant_time_lt(a, b);\n}', 'static inline unsigned int constant_time_lt(unsigned int a, unsigned int b)\n{\n    return constant_time_msb(a ^ ((a ^ b) | ((a - b) ^ b)));\n}']