ssl/d1_both.c:356: error: INTEGER_OVERFLOW_L2
  ([0, +oo] - 1):unsigned32 by call to `dtls1_get_message_fragment`.
Showing all 15 steps of the trace


ssl/d1_both.c:327:1: Parameter `s->ctx->sessions->p`
325.    * fragments.
326.    */
327. > long dtls1_get_message(SSL *s, int st1, int stn, int mt, long max, int *ok)
328.   	{
329.   	int i, al;

ssl/d1_both.c:356:7: Call
354.   			}
355.   
356.   		i = dtls1_get_message_fragment(s, st1, stn, max, ok);
             ^
357.   		if ( i == DTLS1_HM_BAD_FRAGMENT ||
358.   			i == DTLS1_HM_FRAGMENT_RETRY)  /* bad fragment received */

ssl/d1_both.c:526:1: Parameter `s->ctx->sessions->p`
  524.   
  525.   
  526. > static long
  527.   dtls1_get_message_fragment(SSL *s, int st1, int stn, long max, int *ok)
  528.   	{

ssl/d1_both.c:752:2: Call
  750.   
  751.   f_err:
  752.   	ssl3_send_alert(s,SSL3_AL_FATAL,al);
          ^
  753.   	s->init_num = 0;
  754.   err:

ssl/s3_pkt.c:1317:1: Parameter `s->ctx->sessions->p`
    1315.   	}
    1316.   
    1317. > void ssl3_send_alert(SSL *s, int level, int desc)
    1318.   	{
    1319.   	/* Map tls/ssl alert value to correct one */

ssl/s3_pkt.c:1326:3: Call
    1324.   	/* If a fatal one, remove from cache */
    1325.   	if ((level == 2) && (s->session != NULL))
    1326.   		SSL_CTX_remove_session(s->ctx,s->session);
              ^
    1327.   
    1328.   	s->s3->alert_dispatch=1;

ssl/ssl_sess.c:643:1: Parameter `ctx->sessions->p`
      641.   	}
      642.   
      643. > int SSL_CTX_remove_session(SSL_CTX *ctx, SSL_SESSION *c)
      644.   {
      645.   	return remove_session_lock(ctx, c, 1);

ssl/ssl_sess.c:645:9: Call
      643.   int SSL_CTX_remove_session(SSL_CTX *ctx, SSL_SESSION *c)
      644.   {
      645.   	return remove_session_lock(ctx, c, 1);
                     ^
      646.   }
      647.   

ssl/ssl_sess.c:648:1: Parameter `ctx->sessions->pmax`
        646.   }
        647.   
        648. > static int remove_session_lock(SSL_CTX *ctx, SSL_SESSION *c, int lck)
        649.   	{
        650.   	SSL_SESSION *r;

ssl/ssl_sess.c:659:21: Call
        657.   			{
        658.   			ret=1;
        659.   			r=(SSL_SESSION *)lh_delete(ctx->sessions,c);
                                   ^
        660.   			SSL_SESSION_list_remove(ctx,c);
        661.   			}

crypto/lhash/lhash.c:217:1: Parameter `lh->pmax`
          215.   	}
          216.   
          217. > void *lh_delete(LHASH *lh, const void *data)
          218.   	{
          219.   	unsigned long hash;

crypto/lhash/lhash.c:243:3: Call
          241.   	if ((lh->num_nodes > MIN_NODES) &&
          242.   		(lh->down_load >= (lh->num_items*LH_LOAD_MULT/lh->num_nodes)))
          243.   		contract(lh);
                   ^
          244.   
          245.   	return(ret);

crypto/lhash/lhash.c:364:1: <LHS trace>
362.   	}
363.   
364. > static void contract(LHASH *lh)
365.   	{
366.   	LHASH_NODE **n,*n1,*np;

crypto/lhash/lhash.c:364:1: Parameter `lh->p`
            362.   	}
            363.   
            364. > static void contract(LHASH *lh)
            365.   	{
            366.   	LHASH_NODE **n,*n1,*np;

crypto/lhash/lhash.c:368:5: Binary operation: ([0, +oo] - 1):unsigned32 by call to `dtls1_get_message_fragment` 
            366.   	LHASH_NODE **n,*n1,*np;
            367.   
            368.   	np=lh->b[lh->p+lh->pmax-1];
                       ^
            369.   	lh->b[lh->p+lh->pmax-1]=NULL; /* 24/07-92 - eay - weird but :-( */
            370.   	if (lh->p == 0)

static void contract(LHASH *lh)
	{
	LHASH_NODE **n,*n1,*np;
	np=lh->b[lh->p+lh->pmax-1];
	lh->b[lh->p+lh->pmax-1]=NULL;
	if (lh->p == 0)
		{
		n=(LHASH_NODE **)OPENSSL_realloc(lh->b,
			(unsigned int)(sizeof(LHASH_NODE *)*lh->pmax));
		if (n == NULL)
			{
			lh->error++;
			return;
			}
		lh->num_contract_reallocs++;
		lh->num_alloc_nodes/=2;
		lh->pmax/=2;
		lh->p=lh->pmax-1;
		lh->b=n;
		}
	else
		lh->p--;
	lh->num_nodes--;
	lh->num_contracts++;
	n1=lh->b[(int)lh->p];
	if (n1 == NULL)
		lh->b[(int)lh->p]=np;
	else
		{
		while (n1->next != NULL)
			n1=n1->next;
		n1->next=np;
		}
	}
['long dtls1_get_message(SSL *s, int st1, int stn, int mt, long max, int *ok)\n\t{\n\tint i, al;\n\tif (s->s3->tmp.reuse_message)\n\t\t{\n\t\ts->s3->tmp.reuse_message=0;\n\t\tif ((mt >= 0) && (s->s3->tmp.message_type != mt))\n\t\t\t{\n\t\t\tal=SSL_AD_UNEXPECTED_MESSAGE;\n\t\t\tSSLerr(SSL_F_DTLS1_GET_MESSAGE,SSL_R_UNEXPECTED_MESSAGE);\n\t\t\tgoto f_err;\n\t\t\t}\n\t\t*ok=1;\n\t\ts->init_msg = s->init_buf->data + DTLS1_HM_HEADER_LENGTH;\n\t\ts->init_num = (int)s->s3->tmp.message_size;\n\t\treturn s->init_num;\n\t\t}\n\tdo\n\t\t{\n\t\tif ( s->d1->r_msg_hdr.frag_off == 0)\n\t\t\t{\n\t\t\tmemset(&(s->d1->r_msg_hdr), 0x00, sizeof(struct hm_header_st));\n\t\t\t}\n\t\ti = dtls1_get_message_fragment(s, st1, stn, max, ok);\n\t\tif ( i == DTLS1_HM_BAD_FRAGMENT ||\n\t\t\ti == DTLS1_HM_FRAGMENT_RETRY)\n\t\t\tcontinue;\n\t\telse if ( i <= 0 && !*ok)\n\t\t\treturn i;\n\t\tif (s->d1->r_msg_hdr.msg_len == (unsigned int)s->init_num - DTLS1_HM_HEADER_LENGTH)\n\t\t\t{\n\t\t\tmemset(&(s->d1->r_msg_hdr), 0x00, sizeof(struct hm_header_st));\n\t\t\ts->d1->handshake_read_seq++;\n\t\t\tdtls1_clear_record_buffer(s);\n\t\t\ts->init_msg = s->init_buf->data + DTLS1_HM_HEADER_LENGTH;\n\t\t\treturn s->init_num - DTLS1_HM_HEADER_LENGTH;\n\t\t\t}\n\t\telse\n\t\t\ts->d1->r_msg_hdr.frag_off = i;\n\t\t} while(1) ;\nf_err:\n\tssl3_send_alert(s,SSL3_AL_FATAL,al);\n\t*ok = 0;\n\treturn -1;\n\t}', 'static long\ndtls1_get_message_fragment(SSL *s, int st1, int stn, long max, int *ok)\n\t{\n\tunsigned char *p;\n\tunsigned long l, frag_off, frag_len;\n\tint i,al;\n\tstruct hm_header_st msg_hdr;\n\tunsigned long overlap;\n\tif (dtls1_retrieve_buffered_fragment(s, &l))\n\t{\n\t\tdtls1_process_handshake_fragment(s, l);\n\t\ts->init_msg = s->init_buf->data + DTLS1_HM_HEADER_LENGTH;\n\t\ts->state = stn;\n\t\treturn 1;\n\t}\n\tp = (unsigned char *)s->init_buf->data;\n\ti=s->method->ssl_read_bytes(s,SSL3_RT_HANDSHAKE,&p[s->init_num],\n\t\tDTLS1_HM_HEADER_LENGTH, 0);\n\tif (i <= 0)\n\t\t{\n\t\ts->rwstate=SSL_READING;\n\t\t*ok = 0;\n\t\treturn i;\n\t\t}\n\tOPENSSL_assert(i == DTLS1_HM_HEADER_LENGTH);\n\tp += s->init_num;\n\tdtls1_get_message_header(p, &msg_hdr);\n\tif ( msg_hdr.seq != s->d1->handshake_read_seq)\n\t\treturn dtls1_process_out_of_seq_message(s, &msg_hdr, ok);\n\tl = msg_hdr.msg_len;\n\tfrag_off = msg_hdr.frag_off;\n\tfrag_len = msg_hdr.frag_len;\n\tif ( frag_off + frag_len > l)\n\t\t{\n\t\tal=SSL_AD_ILLEGAL_PARAMETER;\n\t\tSSLerr(SSL_F_DTLS1_GET_MESSAGE_FRAGMENT,SSL_R_EXCESSIVE_MESSAGE_SIZE);\n\t\tgoto f_err;\n\t\t}\n\tif (!s->server && s->d1->r_msg_hdr.frag_off == 0 &&\n\t\tp[0] == SSL3_MT_HELLO_REQUEST)\n\t\t{\n\t\tif (p[1] == 0 && p[2] == 0 &&p[3] == 0)\n\t\t\t{\n\t\t\tif (s->msg_callback)\n\t\t\t\ts->msg_callback(0, s->version, SSL3_RT_HANDSHAKE,\n\t\t\t\t\tp, DTLS1_HM_HEADER_LENGTH, s,\n\t\t\t\t\ts->msg_callback_arg);\n\t\t\ts->init_num = 0;\n\t\t\treturn dtls1_get_message_fragment(s, st1, stn,\n\t\t\t\tmax, ok);\n\t\t\t}\n\t\telse\n\t\t\t{\n\t\t\tal=SSL_AD_UNEXPECTED_MESSAGE;\n\t\t\tSSLerr(SSL_F_DTLS1_GET_MESSAGE_FRAGMENT,SSL_R_UNEXPECTED_MESSAGE);\n\t\t\tgoto f_err;\n\t\t\t}\n\t\t}\n\ts->init_num += i;\n\tif ( s->d1->r_msg_hdr.frag_off == 0)\n\t\t{\n\t\tif (l > (INT_MAX-DTLS1_HM_HEADER_LENGTH))\n\t\t\t{\n\t\t\tal=SSL_AD_ILLEGAL_PARAMETER;\n\t\t\tSSLerr(SSL_F_DTLS1_GET_MESSAGE_FRAGMENT,SSL_R_EXCESSIVE_MESSAGE_SIZE);\n\t\t\tgoto f_err;\n\t\t\t}\n\t\tif (l && !BUF_MEM_grow_clean(s->init_buf,(int)l\n\t\t\t+ DTLS1_HM_HEADER_LENGTH))\n\t\t\t{\n\t\t\tSSLerr(SSL_F_DTLS1_GET_MESSAGE_FRAGMENT,ERR_R_BUF_LIB);\n\t\t\tgoto err;\n\t\t\t}\n\t\tif ( l > (unsigned long)max)\n\t\t\t{\n\t\t\tal=SSL_AD_ILLEGAL_PARAMETER;\n\t\t\tSSLerr(SSL_F_DTLS1_GET_MESSAGE_FRAGMENT,SSL_R_EXCESSIVE_MESSAGE_SIZE);\n\t\t\tgoto f_err;\n\t\t\t}\n\t\ts->s3->tmp.message_size=l;\n\t\t}\n\tif ( frag_len > (unsigned long)max)\n\t\t{\n\t\tal=SSL_AD_ILLEGAL_PARAMETER;\n\t\tSSLerr(SSL_F_DTLS1_GET_MESSAGE_FRAGMENT,SSL_R_EXCESSIVE_MESSAGE_SIZE);\n\t\tgoto f_err;\n\t\t}\n\tif ( frag_len + s->init_num > (INT_MAX - DTLS1_HM_HEADER_LENGTH))\n\t\t{\n\t\tal=SSL_AD_ILLEGAL_PARAMETER;\n\t\tSSLerr(SSL_F_DTLS1_GET_MESSAGE_FRAGMENT,SSL_R_EXCESSIVE_MESSAGE_SIZE);\n\t\tgoto f_err;\n\t\t}\n\tif ( frag_len & !BUF_MEM_grow_clean(s->init_buf, (int)frag_len\n\t\t\t + DTLS1_HM_HEADER_LENGTH + s->init_num))\n\t\t{\n\t\tSSLerr(SSL_F_DTLS1_GET_MESSAGE_FRAGMENT,ERR_R_BUF_LIB);\n\t\tgoto err;\n\t\t}\n\tif ( s->d1->r_msg_hdr.frag_off == 0)\n\t\t{\n\t\ts->s3->tmp.message_type = msg_hdr.type;\n\t\ts->d1->r_msg_hdr.type = msg_hdr.type;\n\t\ts->d1->r_msg_hdr.msg_len = l;\n\t\t}\n\ts->state=stn;\n\tp = (unsigned char *)s->init_buf->data;\n\tif ( frag_len > 0)\n\t\t{\n\t\ti=s->method->ssl_read_bytes(s,SSL3_RT_HANDSHAKE,\n\t\t\t&p[s->init_num],\n\t\t\tfrag_len,0);\n\t\tif (i <= 0)\n\t\t\t{\n\t\t\ts->rwstate=SSL_READING;\n\t\t\t*ok = 0;\n\t\t\treturn i;\n\t\t\t}\n\t\t}\n\telse\n\t\ti = 0;\n\tOPENSSL_assert(i == (int)frag_len);\n#if 0\n\tif ( msg_hdr.seq > s->d1->handshake_read_seq ||\n\t\tfrag_off > s->init_num - DTLS1_HM_HEADER_LENGTH)\n\t{\n\t\tdtls1_buffer_handshake_fragment(s, &msg_hdr);\n\t\treturn DTLS1_HM_FRAGMENT_RETRY;\n\t}\n\tif ( msg_hdr.seq < s->d1->handshake_read_seq ||\n\t\tfrag_off + frag_len < s->init_num - DTLS1_HM_HEADER_LENGTH)\n\t\t{\n\t\ts->init_num -= DTLS1_HM_HEADER_LENGTH;\n\t\treturn DTLS1_HM_FRAGMENT_RETRY;\n\t\t}\n#endif\n\toverlap = (s->init_num - DTLS1_HM_HEADER_LENGTH) - frag_off;\n\tif ( s->init_num > DTLS1_HM_HEADER_LENGTH)\n\t\t{\n\t\tmemmove(&(s->init_buf->data[s->init_num]),\n\t\t\t&(s->init_buf->data[s->init_num + DTLS1_HM_HEADER_LENGTH + overlap]),\n\t\t\tfrag_len - overlap);\n\t\ts->init_num += frag_len - overlap;\n\t\t}\n\telse\n\t\ts->init_num += frag_len;\n\tdtls1_process_handshake_fragment(s, frag_len - overlap);\n\tif (s->msg_callback)\n\t\ts->msg_callback(0, s->version, SSL3_RT_HANDSHAKE, s->init_buf->data,\n\t\t\t(size_t)s->init_num, s,\n\t\t\ts->msg_callback_arg);\n\t*ok=1;\n\treturn s->init_num;\nf_err:\n\tssl3_send_alert(s,SSL3_AL_FATAL,al);\n\ts->init_num = 0;\nerr:\n\t*ok=0;\n\treturn(-1);\n\t}', 'void ssl3_send_alert(SSL *s, int level, int desc)\n\t{\n\tdesc=s->method->ssl3_enc->alert_value(desc);\n\tif (s->version == SSL3_VERSION && desc == SSL_AD_PROTOCOL_VERSION)\n\t\tdesc = SSL_AD_HANDSHAKE_FAILURE;\n\tif (desc < 0) return;\n\tif ((level == 2) && (s->session != NULL))\n\t\tSSL_CTX_remove_session(s->ctx,s->session);\n\ts->s3->alert_dispatch=1;\n\ts->s3->send_alert[0]=level;\n\ts->s3->send_alert[1]=desc;\n\tif (s->s3->wbuf.left == 0)\n\t\ts->method->ssl_dispatch_alert(s);\n\t}', 'int SSL_CTX_remove_session(SSL_CTX *ctx, SSL_SESSION *c)\n{\n\treturn remove_session_lock(ctx, c, 1);\n}', 'static int remove_session_lock(SSL_CTX *ctx, SSL_SESSION *c, int lck)\n\t{\n\tSSL_SESSION *r;\n\tint ret=0;\n\tif ((c != NULL) && (c->session_id_length != 0))\n\t\t{\n\t\tif(lck) CRYPTO_w_lock(CRYPTO_LOCK_SSL_CTX);\n\t\tif ((r = (SSL_SESSION *)lh_retrieve(ctx->sessions,c)) == c)\n\t\t\t{\n\t\t\tret=1;\n\t\t\tr=(SSL_SESSION *)lh_delete(ctx->sessions,c);\n\t\t\tSSL_SESSION_list_remove(ctx,c);\n\t\t\t}\n\t\tif(lck) CRYPTO_w_unlock(CRYPTO_LOCK_SSL_CTX);\n\t\tif (ret)\n\t\t\t{\n\t\t\tr->not_resumable=1;\n\t\t\tif (ctx->remove_session_cb != NULL)\n\t\t\t\tctx->remove_session_cb(ctx,r);\n\t\t\tSSL_SESSION_free(r);\n\t\t\t}\n\t\t}\n\telse\n\t\tret=0;\n\treturn(ret);\n\t}', 'void *lh_delete(LHASH *lh, const void *data)\n\t{\n\tunsigned long hash;\n\tLHASH_NODE *nn,**rn;\n\tvoid *ret;\n\tlh->error=0;\n\trn=getrn(lh,data,&hash);\n\tif (*rn == NULL)\n\t\t{\n\t\tlh->num_no_delete++;\n\t\treturn(NULL);\n\t\t}\n\telse\n\t\t{\n\t\tnn= *rn;\n\t\t*rn=nn->next;\n\t\tret=nn->data;\n\t\tOPENSSL_free(nn);\n\t\tlh->num_delete++;\n\t\t}\n\tlh->num_items--;\n\tif ((lh->num_nodes > MIN_NODES) &&\n\t\t(lh->down_load >= (lh->num_items*LH_LOAD_MULT/lh->num_nodes)))\n\t\tcontract(lh);\n\treturn(ret);\n\t}', 'static void contract(LHASH *lh)\n\t{\n\tLHASH_NODE **n,*n1,*np;\n\tnp=lh->b[lh->p+lh->pmax-1];\n\tlh->b[lh->p+lh->pmax-1]=NULL;\n\tif (lh->p == 0)\n\t\t{\n\t\tn=(LHASH_NODE **)OPENSSL_realloc(lh->b,\n\t\t\t(unsigned int)(sizeof(LHASH_NODE *)*lh->pmax));\n\t\tif (n == NULL)\n\t\t\t{\n\t\t\tlh->error++;\n\t\t\treturn;\n\t\t\t}\n\t\tlh->num_contract_reallocs++;\n\t\tlh->num_alloc_nodes/=2;\n\t\tlh->pmax/=2;\n\t\tlh->p=lh->pmax-1;\n\t\tlh->b=n;\n\t\t}\n\telse\n\t\tlh->p--;\n\tlh->num_nodes--;\n\tlh->num_contracts++;\n\tn1=lh->b[(int)lh->p];\n\tif (n1 == NULL)\n\t\tlh->b[(int)lh->p]=np;\n\telse\n\t\t{\n\t\twhile (n1->next != NULL)\n\t\t\tn1=n1->next;\n\t\tn1->next=np;\n\t\t}\n\t}']