ssl/d1_pkt.c:677: 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/d1_pkt.c:526:1: Parameter `s->ctx->sessions->num_items`
524.    */
525.   /* used only by dtls1_read_bytes */
526. > int dtls1_get_record(SSL *s)
527.   	{
528.   	int ssl_major,ssl_minor;

ssl/d1_pkt.c:542:2: Call
540.   	/* The epoch may have changed.  If so, process all the
541.   	 * pending records.  This is a non-blocking operation. */
542.   	dtls1_process_buffered_records(s);
        ^
543.   
544.   	/* if we're renegotiating, then there may be buffered records */

ssl/d1_pkt.c:291:1: Parameter `s->ctx->sessions->num_items`
  289.                      &((s)->d1->processed_rcds))
  290.   
  291. > static int
  292.   dtls1_process_buffered_records(SSL *s)
  293.       {

ssl/d1_pkt.c:677:7: Call
675.   		}
676.   
677.   	if (!dtls1_process_record(s))
             ^
678.   		{
679.   		rr->length = 0;

ssl/d1_pkt.c:371:1: Parameter `s->ctx->sessions->num_items`
  369.   #endif
  370.   
  371. > static int
  372.   dtls1_process_record(SSL *s)
  373.   {

ssl/d1_pkt.c:511:2: Call
  509.   
  510.   f_err:
  511.   	ssl3_send_alert(s,SSL3_AL_FATAL,al);
          ^
  512.   err:
  513.   	return(0);

ssl/s3_pkt.c:1421:1: Parameter `s->ctx->sessions->num_items`
    1419.   	}
    1420.   
    1421. > int ssl3_send_alert(SSL *s, int level, int desc)
    1422.   	{
    1423.   	/* Map tls/ssl alert value to correct one */

ssl/s3_pkt.c:1430:3: Call
    1428.   	/* If a fatal one, remove from cache */
    1429.   	if ((level == 2) && (s->session != NULL))
    1430.   		SSL_CTX_remove_session(s->ctx,s->session);
              ^
    1431.   
    1432.   	s->s3->alert_dispatch=1;

ssl/ssl_sess.c:658:1: Parameter `ctx->sessions->num_items`
      656.   	}
      657.   
      658. > int SSL_CTX_remove_session(SSL_CTX *ctx, SSL_SESSION *c)
      659.   {
      660.   	return remove_session_lock(ctx, c, 1);

ssl/ssl_sess.c:660:9: Call
      658.   int SSL_CTX_remove_session(SSL_CTX *ctx, SSL_SESSION *c)
      659.   {
      660.   	return remove_session_lock(ctx, c, 1);
                     ^
      661.   }
      662.   

ssl/ssl_sess.c:663:1: Parameter `ctx->sessions->num_items`
        661.   }
        662.   
        663. > static int remove_session_lock(SSL_CTX *ctx, SSL_SESSION *c, int lck)
        664.   	{
        665.   	SSL_SESSION *r;

ssl/ssl_sess.c:674:6: Call
        672.   			{
        673.   			ret=1;
        674.   			r=lh_SSL_SESSION_delete(ctx->sessions,c);
                    ^
        675.   			SSL_SESSION_list_remove(ctx,c);
        676.   			}

crypto/lhash/lhash.c:217:1: <LHS trace>
215.   	}
216.   
217. > void *lh_delete(_LHASH *lh, const void *data)
218.   	{
219.   	unsigned long hash;

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

crypto/lhash/lhash.c:240:2: Binary operation: ([0, max(0, s->ctx->sessions->num_items)] - 1):unsigned64 by call to `dtls1_process_record` 
          238.   		}
          239.   
          240.   	lh->num_items--;
                  ^
          241.   	if ((lh->num_nodes > MIN_NODES) &&
          242.   		(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\t{\n\tint ssl_major,ssl_minor;\n\tint i,n;\n\tSSL3_RECORD *rr;\n\tSSL_SESSION *sess;\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\tsess=s->session;\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\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{\n\t\trr->length = 0;\n\t\ts->packet_length=0;\n\t\tgoto again;\n\t\t}\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)\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\tdtls1_clear_timeouts(s);\n\treturn(1);\n\t}', 'static int\ndtls1_process_buffered_records(SSL *s)\n    {\n    pitem *item;\n    item = pqueue_peek(s->d1->unprocessed_rcds.q);\n    if (item)\n        {\n        DTLS1_RECORD_DATA *rdata;\n        rdata = (DTLS1_RECORD_DATA *)item->data;\n        if (s->d1->unprocessed_rcds.epoch != s->d1->r_epoch)\n            return(1);\n        while (pqueue_peek(s->d1->unprocessed_rcds.q))\n            {\n            dtls1_get_unprocessed_record(s);\n            if ( ! dtls1_process_record(s))\n                return(0);\n            dtls1_buffer_record(s, &(s->d1->processed_rcds),\n                s->s3->rrec.seq_num);\n            }\n        }\n    s->d1->processed_rcds.epoch = s->d1->r_epoch;\n    s->d1->unprocessed_rcds.epoch = s->d1->r_epoch + 1;\n    return(1);\n    }', 'static int\ndtls1_process_record(SSL *s)\n{\n\tint i,al;\n\tint clear=0;\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\tenc_err = s->method->ssl3_enc->enc(s,0);\n\tif (enc_err <= 0)\n\t\t{\n\t\tif (enc_err == 0)\n\t\t\tgoto err;\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 (\t(sess == NULL) ||\n\t\t(s->enc_read_ctx == NULL) ||\n\t\t(s->read_hash == NULL))\n\t\tclear=1;\n\tif (!clear)\n\t\t{\n\t\tint t;\n\t\tt=EVP_MD_CTX_size(s->read_hash);\n\t\tOPENSSL_assert(t >= 0);\n\t\tmac_size=t;\n\t\tif (rr->length > SSL3_RT_MAX_COMPRESSED_LENGTH+mac_size)\n\t\t\t{\n#if 0\n\t\t\tal=SSL_AD_RECORD_OVERFLOW;\n\t\t\tSSLerr(SSL_F_DTLS1_PROCESS_RECORD,SSL_R_PRE_MAC_LENGTH_TOO_LONG);\n\t\t\tgoto f_err;\n#else\n\t\t\tgoto err;\n#endif\n\t\t\t}\n\t\tif (rr->length < mac_size)\n\t\t\t{\n#if 0\n\t\t\tal=SSL_AD_DECODE_ERROR;\n\t\t\tSSLerr(SSL_F_DTLS1_PROCESS_RECORD,SSL_R_LENGTH_TOO_SHORT);\n\t\t\tgoto f_err;\n#else\n\t\t\tgoto err;\n#endif\n\t\t\t}\n\t\trr->length-=mac_size;\n\t\ti=s->method->ssl3_enc->mac(s,md,0);\n\t\tif (i < 0 || memcmp(md,&(rr->data[rr->length]),mac_size) != 0)\n\t\t\t{\n\t\t\tgoto err;\n\t\t\t}\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}', 'int 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 -1;\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\treturn s->method->ssl_dispatch_alert(s);\n\treturn -1;\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 = lh_SSL_SESSION_retrieve(ctx->sessions,c)) == c)\n\t\t\t{\n\t\t\tret=1;\n\t\t\tr=lh_SSL_SESSION_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}']