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


ssl/d1_pkt.c:582:4: Assignment
580.   		if (s->packet_length != DTLS1_RT_HEADER_LENGTH)
581.   			{
582.   			s->packet_length = 0;
          ^
583.   			goto again;
584.   			}

ssl/d1_pkt.c:708:7: Call
706.   		}
707.   
708.   	if (!dtls1_process_record(s))
             ^
709.   		{
710.   		rr->length = 0;

ssl/d1_pkt.c:375:1: Parameter `s->s3->rrec.length`
  373.   #endif
  374.   
  375. > static int
  376.   dtls1_process_record(SSL *s)
  377.   {

ssl/d1_pkt.c:468:4: Call
  466.   			 * */
  467.   			mac = mac_tmp;
  468.   			ssl3_cbc_copy_mac(mac_tmp, rr, mac_size);
            ^
  469.   			rr->length -= mac_size;
  470.   			}

ssl/s3_cbc.c:249:1: Parameter `md_size`
    247.    * the timing. This has been tested to be true on Intel amd64 chips.
    248.    */
    249. > void ssl3_cbc_copy_mac(unsigned char* out,
    250.   		       const SSL3_RECORD *rec,
    251.   		       unsigned md_size)

ssl/s3_cbc.c:297:30: Call
    295.   			{
    296.   			unsigned char mac_started = constant_time_ge(i, mac_start);
    297.   			unsigned char mac_ended = constant_time_ge(i, mac_end);
                                        ^
    298.   			unsigned char b = 0;
    299.   			b = rec->data[i];

ssl/s3_cbc.c:82:1: <LHS trace>
80.   
81.   /* constant_time_ge returns 0xff if a>=b and 0x00 otherwise. */
82. > static unsigned constant_time_ge(unsigned a, unsigned b)
83.   	{
84.   	a -= b;

ssl/s3_cbc.c:82:1: Parameter `a`
      80.   
      81.   /* constant_time_ge returns 0xff if a>=b and 0x00 otherwise. */
      82. > static unsigned constant_time_ge(unsigned a, unsigned b)
      83.   	{
      84.   	a -= b;

ssl/s3_cbc.c:82:1: <RHS trace>
80.   
81.   /* constant_time_ge returns 0xff if a>=b and 0x00 otherwise. */
82. > static unsigned constant_time_ge(unsigned a, unsigned b)
83.   	{
84.   	a -= b;

ssl/s3_cbc.c:82:1: Parameter `b`
      80.   
      81.   /* constant_time_ge returns 0xff if a>=b and 0x00 otherwise. */
      82. > static unsigned constant_time_ge(unsigned a, unsigned b)
      83.   	{
      84.   	a -= b;

ssl/s3_cbc.c:84:2: Binary operation: ([0, 17727] - [0, 17728]):unsigned32 by call to `dtls1_process_record` 
      82.   static unsigned constant_time_ge(unsigned a, unsigned b)
      83.   	{
      84.   	a -= b;
             ^
      85.   	return DUPLICATE_MSB_TO_ALL(~a);
      86.   	}

static unsigned constant_time_ge(unsigned a, unsigned b)
	{
	a -= b;
	return DUPLICATE_MSB_TO_ALL(~a);
	}
['int dtls1_get_record(SSL *s)\n\t{\n\tint ssl_major,ssl_minor;\n\tint i,n;\n\tSSL3_RECORD *rr;\n\tunsigned char *p = NULL;\n\tunsigned short version;\n\tDTLS1_BITMAP *bitmap;\n\tunsigned int is_next_epoch;\n\trr= &(s->s3->rrec);\n\tdtls1_process_buffered_records(s);\n\tif (dtls1_get_processed_record(s))\n\t\treturn 1;\nagain:\n\tif (\t(s->rstate != SSL_ST_READ_BODY) ||\n\t\t(s->packet_length < DTLS1_RT_HEADER_LENGTH))\n\t\t{\n\t\tn=ssl3_read_n(s, DTLS1_RT_HEADER_LENGTH, s->s3->rbuf.len, 0);\n\t\tif (n <= 0) return(n);\n\t\tif (s->packet_length != DTLS1_RT_HEADER_LENGTH)\n\t\t\t{\n\t\t\ts->packet_length = 0;\n\t\t\tgoto again;\n\t\t\t}\n\t\ts->rstate=SSL_ST_READ_BODY;\n\t\tp=s->packet;\n\t\trr->type= *(p++);\n\t\tssl_major= *(p++);\n\t\tssl_minor= *(p++);\n\t\tversion=(ssl_major<<8)|ssl_minor;\n\t\tn2s(p,rr->epoch);\n\t\tmemcpy(&(s->s3->read_sequence[2]), p, 6);\n\t\tp+=6;\n\t\tn2s(p,rr->length);\n\t\tif (!s->first_packet)\n\t\t\t{\n\t\t\tif (version != s->version)\n\t\t\t\t{\n\t\t\t\trr->length = 0;\n\t\t\t\ts->packet_length = 0;\n\t\t\t\tgoto again;\n\t\t\t\t}\n\t\t\t}\n\t\tif ((version & 0xff00) != (s->version & 0xff00))\n\t\t\t{\n\t\t\trr->length = 0;\n\t\t\ts->packet_length = 0;\n\t\t\tgoto again;\n\t\t\t}\n\t\tif (rr->length > SSL3_RT_MAX_ENCRYPTED_LENGTH)\n\t\t\t{\n\t\t\trr->length = 0;\n\t\t\ts->packet_length = 0;\n\t\t\tgoto again;\n\t\t\t}\n\t\t}\n\tif (rr->length > s->packet_length-DTLS1_RT_HEADER_LENGTH)\n\t\t{\n\t\ti=rr->length;\n\t\tn=ssl3_read_n(s,i,i,1);\n\t\tif (n <= 0) return(n);\n\t\tif ( n != i)\n\t\t\t{\n\t\t\trr->length = 0;\n\t\t\ts->packet_length = 0;\n\t\t\tgoto again;\n\t\t\t}\n\t\t}\n\ts->rstate=SSL_ST_READ_HEADER;\n\tbitmap = dtls1_get_bitmap(s, rr, &is_next_epoch);\n\tif ( bitmap == NULL)\n\t\t{\n\t\trr->length = 0;\n\t\ts->packet_length = 0;\n\t\tgoto again;\n\t\t}\n#ifndef OPENSSL_NO_SCTP\n\tif (!BIO_dgram_is_sctp(SSL_get_rbio(s)))\n  \t\t{\n#endif\n\t\tif (!(s->d1->listen && rr->type == SSL3_RT_HANDSHAKE &&\n\t\t    *p == SSL3_MT_CLIENT_HELLO) &&\n\t\t    !dtls1_record_replay_check(s, bitmap))\n\t\t\t{\n\t\t\trr->length = 0;\n\t\t\ts->packet_length=0;\n\t\t\tgoto again;\n\t\t\t}\n#ifndef OPENSSL_NO_SCTP\n  \t\t}\n#endif\n\tif (rr->length == 0) goto again;\n\tif (is_next_epoch)\n\t\t{\n\t\tif ((SSL_in_init(s) || s->in_handshake) && !s->d1->listen)\n\t\t\t{\n\t\t\tdtls1_buffer_record(s, &(s->d1->unprocessed_rcds), rr->seq_num);\n\t\t\t}\n\t\trr->length = 0;\n\t\ts->packet_length = 0;\n\t\tgoto again;\n\t\t}\n\tif (!dtls1_process_record(s))\n\t\t{\n\t\trr->length = 0;\n\t\ts->packet_length = 0;\n\t\tgoto again;\n\t\t}\n\treturn(1);\n\t}', 'static int\ndtls1_process_record(SSL *s)\n{\n\tint i,al;\n\tint enc_err;\n\tSSL_SESSION *sess;\n\tSSL3_RECORD *rr;\n\tunsigned int mac_size;\n\tunsigned char md[EVP_MAX_MD_SIZE];\n\trr= &(s->s3->rrec);\n\tsess = s->session;\n\trr->input= &(s->packet[DTLS1_RT_HEADER_LENGTH]);\n\tif (rr->length > SSL3_RT_MAX_ENCRYPTED_LENGTH)\n\t\t{\n\t\tal=SSL_AD_RECORD_OVERFLOW;\n\t\tSSLerr(SSL_F_DTLS1_PROCESS_RECORD,SSL_R_ENCRYPTED_LENGTH_TOO_LONG);\n\t\tgoto f_err;\n\t\t}\n\trr->data=rr->input;\n\trr->orig_len=rr->length;\n\tenc_err = s->method->ssl3_enc->enc(s,0);\n\tif (enc_err == 0)\n\t\t{\n\t\trr->length = 0;\n\t\ts->packet_length = 0;\n\t\tgoto err;\n\t\t}\n#ifdef TLS_DEBUG\nprintf("dec %d\\n",rr->length);\n{ unsigned int z; for (z=0; z<rr->length; z++) printf("%02X%c",rr->data[z],((z+1)%16)?\' \':\'\\n\'); }\nprintf("\\n");\n#endif\n\tif ((sess != NULL) &&\n\t    (s->enc_read_ctx != NULL) &&\n\t    (EVP_MD_CTX_md(s->read_hash) != NULL))\n\t\t{\n\t\tunsigned char *mac = NULL;\n\t\tunsigned char mac_tmp[EVP_MAX_MD_SIZE];\n\t\tmac_size=EVP_MD_CTX_size(s->read_hash);\n\t\tOPENSSL_assert(mac_size <= EVP_MAX_MD_SIZE);\n\t\tif (rr->orig_len < mac_size ||\n\t\t    (EVP_CIPHER_CTX_mode(s->enc_read_ctx) == EVP_CIPH_CBC_MODE &&\n\t\t     rr->orig_len < mac_size+1))\n\t\t\t{\n\t\t\tal=SSL_AD_DECODE_ERROR;\n\t\t\tSSLerr(SSL_F_SSL3_GET_RECORD,SSL_R_LENGTH_TOO_SHORT);\n\t\t\tgoto f_err;\n\t\t\t}\n\t\tif (EVP_CIPHER_CTX_mode(s->enc_read_ctx) == EVP_CIPH_CBC_MODE)\n\t\t\t{\n\t\t\tmac = mac_tmp;\n\t\t\tssl3_cbc_copy_mac(mac_tmp, rr, mac_size);\n\t\t\trr->length -= mac_size;\n\t\t\t}\n\t\telse\n\t\t\t{\n\t\t\trr->length -= mac_size;\n\t\t\tmac = &rr->data[rr->length];\n\t\t\t}\n\t\ti=s->method->ssl3_enc->mac(s,md,0  );\n\t\tif (i < 0 || mac == NULL || CRYPTO_memcmp(md, mac, (size_t)mac_size) != 0)\n\t\t\tenc_err = -1;\n\t\tif (rr->length > SSL3_RT_MAX_COMPRESSED_LENGTH+mac_size)\n\t\t\tenc_err = -1;\n\t\t}\n\tif (enc_err < 0)\n\t\t{\n\t\trr->length = 0;\n\t\ts->packet_length = 0;\n\t\tgoto err;\n\t\t}\n\tif (s->expand != NULL)\n\t\t{\n\t\tif (rr->length > SSL3_RT_MAX_COMPRESSED_LENGTH)\n\t\t\t{\n\t\t\tal=SSL_AD_RECORD_OVERFLOW;\n\t\t\tSSLerr(SSL_F_DTLS1_PROCESS_RECORD,SSL_R_COMPRESSED_LENGTH_TOO_LONG);\n\t\t\tgoto f_err;\n\t\t\t}\n\t\tif (!ssl3_do_uncompress(s))\n\t\t\t{\n\t\t\tal=SSL_AD_DECOMPRESSION_FAILURE;\n\t\t\tSSLerr(SSL_F_DTLS1_PROCESS_RECORD,SSL_R_BAD_DECOMPRESSION);\n\t\t\tgoto f_err;\n\t\t\t}\n\t\t}\n\tif (rr->length > SSL3_RT_MAX_PLAIN_LENGTH)\n\t\t{\n\t\tal=SSL_AD_RECORD_OVERFLOW;\n\t\tSSLerr(SSL_F_DTLS1_PROCESS_RECORD,SSL_R_DATA_LENGTH_TOO_LONG);\n\t\tgoto f_err;\n\t\t}\n\trr->off=0;\n\ts->packet_length=0;\n\tdtls1_record_bitmap_update(s, &(s->d1->bitmap));\n\treturn(1);\nf_err:\n\tssl3_send_alert(s,SSL3_AL_FATAL,al);\nerr:\n\treturn(0);\n}', 'void ssl3_cbc_copy_mac(unsigned char* out,\n\t\t       const SSL3_RECORD *rec,\n\t\t       unsigned md_size)\n\t{\n#if defined(CBC_MAC_ROTATE_IN_PLACE)\n\tunsigned char rotated_mac_buf[EVP_MAX_MD_SIZE*2];\n\tunsigned char *rotated_mac;\n#else\n\tunsigned char rotated_mac[EVP_MAX_MD_SIZE];\n#endif\n\tunsigned mac_end = rec->length;\n\tunsigned mac_start = mac_end - md_size;\n\tunsigned scan_start = 0;\n\tunsigned i, j;\n\tunsigned div_spoiler;\n\tunsigned rotate_offset;\n\tOPENSSL_assert(rec->orig_len >= md_size);\n\tOPENSSL_assert(md_size <= EVP_MAX_MD_SIZE);\n#if defined(CBC_MAC_ROTATE_IN_PLACE)\n\trotated_mac = (unsigned char*) (((intptr_t)(rotated_mac_buf + 64)) & ~63);\n#endif\n\tif (rec->orig_len > md_size + 255 + 1)\n\t\tscan_start = rec->orig_len - (md_size + 255 + 1);\n\tdiv_spoiler = md_size >> 1;\n\tdiv_spoiler <<= (sizeof(div_spoiler)-1)*8;\n\trotate_offset = (div_spoiler + mac_start - scan_start) % md_size;\n\tmemset(rotated_mac, 0, md_size);\n\tfor (i = scan_start; i < rec->orig_len;)\n\t\t{\n\t\tfor (j = 0; j < md_size && i < rec->orig_len; i++, j++)\n\t\t\t{\n\t\t\tunsigned char mac_started = constant_time_ge(i, mac_start);\n\t\t\tunsigned char mac_ended = constant_time_ge(i, mac_end);\n\t\t\tunsigned char b = 0;\n\t\t\tb = rec->data[i];\n\t\t\trotated_mac[j] |= b & mac_started & ~mac_ended;\n\t\t\t}\n\t\t}\n#if defined(CBC_MAC_ROTATE_IN_PLACE)\n\tj = 0;\n\tfor (i = 0; i < md_size; i++)\n\t\t{\n\t\tunsigned char offset = (div_spoiler + rotate_offset + i) % md_size;\n\t\tout[j++] = rotated_mac[offset];\n\t\t}\n#else\n\tmemset(out, 0, md_size);\n\tfor (i = 0; i < md_size; i++)\n\t\t{\n\t\tunsigned char offset = (div_spoiler + md_size - rotate_offset + i) % md_size;\n\t\tfor (j = 0; j < md_size; j++)\n\t\t\tout[j] |= rotated_mac[i] & constant_time_eq_8(j, offset);\n\t\t}\n#endif\n\t}', 'static unsigned constant_time_ge(unsigned a, unsigned b)\n\t{\n\ta -= b;\n\treturn DUPLICATE_MSB_TO_ALL(~a);\n\t}']