ssl/s3_pkt.c:809: error: INTEGER_OVERFLOW_L2
  ([0, +oo] - 1):unsigned32 by call to `SSL_CTX_remove_session`.
Showing all 9 steps of the trace


ssl/s3_pkt.c:672:1: Parameter `s->ctx->sessions->p`
670.   	}
671.   
672. > int ssl3_read_bytes(SSL *s, int type, char *buf, int len)
673.   	{
674.   	int al,i,j,n,ret;

ssl/s3_pkt.c:809:5: Call
807.   				ERR_add_error_data(2,"SSL alert number ",tmp);
808.   				s->shutdown|=SSL_RECEIVED_SHUTDOWN;
809.   				SSL_CTX_remove_session(s->ctx,s->session);
           ^
810.   				return(0);
811.   				}

ssl/ssl_sess.c:325:1: Parameter `ctx->sessions->p`
  323.   	}
  324.   
  325. > int SSL_CTX_remove_session(SSL_CTX *ctx, SSL_SESSION *c)
  326.   	{
  327.   	SSL_SESSION *r;

ssl/ssl_sess.c:333:20: Call
  331.   		{
  332.   		CRYPTO_w_lock(CRYPTO_LOCK_SSL_CTX);
  333.   		r=(SSL_SESSION *)lh_delete(ctx->sessions,(char *)c);
                            ^
  334.   		if (r != NULL)
  335.   			{

crypto/lhash/lhash.c:231:1: Parameter `lh->pmax`
    229.   	}
    230.   
    231. > char *lh_delete(LHASH *lh, char *data)
    232.   	{
    233.   	unsigned long hash;

crypto/lhash/lhash.c:257:3: Call
    255.   	if ((lh->num_nodes > MIN_NODES) &&
    256.   		(lh->down_load >= (lh->num_items*LH_LOAD_MULT/lh->num_nodes)))
    257.   		contract(lh);
             ^
    258.   
    259.   	return(ret);

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

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

crypto/lhash/lhash.c:370:5: Binary operation: ([0, +oo] - 1):unsigned32 by call to `SSL_CTX_remove_session` 
      368.   	LHASH_NODE **n,*n1,*np;
      369.   
      370.   	np=lh->b[lh->p+lh->pmax-1];
                 ^
      371.   	lh->b[lh->p+lh->pmax-1]=NULL; /* 24/07-92 - eay - weird but :-( */
      372.   	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 **)Realloc((char *)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;
		}
	}
['int ssl3_read_bytes(SSL *s, int type, char *buf, int len)\n\t{\n\tint al,i,j,n,ret;\n\tSSL3_RECORD *rr;\n\tvoid (*cb)()=NULL;\n\tBIO *bio;\n\tif (s->s3->rbuf.buf == NULL)\n\t\tif (!ssl3_setup_buffers(s))\n\t\t\treturn(-1);\n\tif (!s->in_handshake && SSL_in_init(s))\n\t\t{\n\t\ti=s->handshake_func(s);\n\t\tif (i < 0) return(i);\n\t\tif (i == 0)\n\t\t\t{\n\t\t\tSSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_SSL_HANDSHAKE_FAILURE);\n\t\t\treturn(-1);\n\t\t\t}\n\t\t}\nstart:\n\ts->rwstate=SSL_NOTHING;\n\trr= &(s->s3->rrec);\n\tif ((rr->length == 0) || (s->rstate == SSL_ST_READ_BODY))\n\t\t{\n\t\tret=ssl3_get_record(s);\n\t\tif (ret <= 0) return(ret);\n\t\t}\n\tif (s->s3->change_cipher_spec && (rr->type != SSL3_RT_HANDSHAKE))\n\t\t{\n\t\tal=SSL_AD_UNEXPECTED_MESSAGE;\n\t\tSSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_DATA_BETWEEN_CCS_AND_FINISHED);\n\t\tgoto err;\n\t\t}\n\tif (s->shutdown & SSL_RECEIVED_SHUTDOWN)\n\t\t{\n\t\trr->length=0;\n\t\ts->rwstate=SSL_NOTHING;\n\t\treturn(0);\n\t\t}\n\tif ((rr->type == SSL3_RT_HANDSHAKE) && (rr->length == 4) &&\n\t\t(rr->data[0] == SSL3_MT_CLIENT_REQUEST) &&\n\t\t(s->session != NULL) && (s->session->cipher != NULL))\n\t\t{\n\t\tif ((rr->data[1] != 0) || (rr->data[2] != 0) ||\n\t\t\t(rr->data[3] != 0))\n\t\t\t{\n\t\t\tal=SSL_AD_DECODE_ERROR;\n\t\t\tSSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_BAD_CLIENT_REQUEST);\n\t\t\tgoto err;\n\t\t\t}\n\t\tif (SSL_is_init_finished(s) &&\n\t\t\t!(s->s3->flags & SSL3_FLAGS_NO_RENEGOTIATE_CIPHERS) &&\n\t\t\t!s->s3->renegotiate)\n\t\t\t{\n\t\t\tssl3_renegotiate(s);\n\t\t\tif (ssl3_renegotiate_check(s))\n\t\t\t\t{\n\t\t\t\tn=s->handshake_func(s);\n\t\t\t\tif (n < 0) return(n);\n\t\t\t\tif (n == 0)\n\t\t\t\t\t{\n\t\t\t\t\tSSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_SSL_HANDSHAKE_FAILURE);\n\t\t\t\t\treturn(-1);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\trr->length=0;\n \tgoto start;\n\t\t}\n\tif ((rr->type != type) || (s->shutdown & SSL_SENT_SHUTDOWN))\n\t\t{\n\t\tif (rr->type == SSL3_RT_ALERT)\n\t\t\t{\n\t\t\tif ((rr->length != 2) || (rr->off != 0))\n\t\t\t\t{\n\t\t\t\tal=SSL_AD_DECODE_ERROR;\n\t\t\t\tSSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_BAD_ALERT_RECORD);\n\t\t\t\tgoto f_err;\n\t\t\t\t}\n\t\t\ti=rr->data[0];\n\t\t\tn=rr->data[1];\n\t\t\trr->length=0;\n\t\t\tif (s->info_callback != NULL)\n\t\t\t\tcb=s->info_callback;\n\t\t\telse if (s->ctx->info_callback != NULL)\n\t\t\t\tcb=s->ctx->info_callback;\n\t\t\tif (cb != NULL)\n\t\t\t\t{\n\t\t\t\tj=(i<<8)|n;\n\t\t\t\tcb(s,SSL_CB_READ_ALERT,j);\n\t\t\t\t}\n\t\t\tif (i == 1)\n\t\t\t\t{\n\t\t\t\ts->s3->warn_alert=n;\n\t\t\t\tif (n == SSL_AD_CLOSE_NOTIFY)\n\t\t\t\t\t{\n\t\t\t\t\ts->shutdown|=SSL_RECEIVED_SHUTDOWN;\n\t\t\t\t\treturn(0);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\telse if (i == 2)\n\t\t\t\t{\n\t\t\t\tchar tmp[16];\n\t\t\t\ts->rwstate=SSL_NOTHING;\n\t\t\t\ts->s3->fatal_alert=n;\n\t\t\t\tSSLerr(SSL_F_SSL3_READ_BYTES,\n\t\t\t\t\tSSL_AD_REASON_OFFSET+n);\n\t\t\t\tsprintf(tmp,"%d",n);\n\t\t\t\tERR_add_error_data(2,"SSL alert number ",tmp);\n\t\t\t\ts->shutdown|=SSL_RECEIVED_SHUTDOWN;\n\t\t\t\tSSL_CTX_remove_session(s->ctx,s->session);\n\t\t\t\treturn(0);\n\t\t\t\t}\n\t\t\telse\n\t\t\t\t{\n\t\t\t\tal=SSL_AD_ILLEGAL_PARAMETER;\n\t\t\t\tSSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_UNKNOWN_ALERT_TYPE);\n\t\t\t\tgoto f_err;\n\t\t\t\t}\n\t\t\trr->length=0;\n\t\t\tgoto start;\n\t\t\t}\n\t\tif (s->shutdown & SSL_SENT_SHUTDOWN)\n\t\t\t{\n\t\t\ts->rwstate=SSL_NOTHING;\n\t\t\trr->length=0;\n\t\t\treturn(0);\n\t\t\t}\n\t\tif (rr->type == SSL3_RT_CHANGE_CIPHER_SPEC)\n\t\t\t{\n\t\t\tif (\t(rr->length != 1) || (rr->off != 0) ||\n\t\t\t\t(rr->data[0] != SSL3_MT_CCS))\n\t\t\t\t{\n\t\t\t\ti=SSL_AD_ILLEGAL_PARAMETER;\n\t\t\t\tSSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_BAD_CHANGE_CIPHER_SPEC);\n\t\t\t\tgoto err;\n\t\t\t\t}\n\t\t\trr->length=0;\n\t\t\ts->s3->change_cipher_spec=1;\n\t\t\tif (!do_change_cipher_spec(s))\n\t\t\t\tgoto err;\n\t\t\telse\n\t\t\t\tgoto start;\n\t\t\t}\n\t\tif ((rr->type == SSL3_RT_HANDSHAKE) &&\n\t\t\t!s->in_handshake)\n\t\t\t{\n\t\t\tif (((s->state&SSL_ST_MASK) == SSL_ST_OK) &&\n\t\t\t\t!(s->s3->flags & SSL3_FLAGS_NO_RENEGOTIATE_CIPHERS))\n\t\t\t\t{\n\t\t\t\ts->state=SSL_ST_BEFORE|(s->server)\n\t\t\t\t\t\t?SSL_ST_ACCEPT\n\t\t\t\t\t\t:SSL_ST_CONNECT;\n\t\t\t\ts->new_session=1;\n\t\t\t\t}\n\t\t\tn=s->handshake_func(s);\n\t\t\tif (n < 0) return(n);\n\t\t\tif (n == 0)\n\t\t\t\t{\n\t\t\t\tSSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_SSL_HANDSHAKE_FAILURE);\n\t\t\t\treturn(-1);\n\t\t\t\t}\n\t\t\ts->rwstate=SSL_READING;\n\t\t\tbio=SSL_get_rbio(s);\n\t\t\tBIO_clear_retry_flags(bio);\n\t\t\tBIO_set_retry_read(bio);\n\t\t\treturn(-1);\n\t\t\t}\n\t\tswitch (rr->type)\n\t\t\t{\n\t\tdefault:\n#ifndef NO_TLS\n\t\t\tif (s->version == TLS1_VERSION)\n\t\t\t\t{\n\t\t\t\tgoto start;\n\t\t\t\t}\n#endif\n\t\tcase SSL3_RT_CHANGE_CIPHER_SPEC:\n\t\tcase SSL3_RT_ALERT:\n\t\tcase SSL3_RT_HANDSHAKE:\n\t\t\tal=SSL_AD_UNEXPECTED_MESSAGE;\n\t\t\tSSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_UNEXPECTED_RECORD);\n\t\t\tgoto f_err;\n\t\tcase SSL3_RT_APPLICATION_DATA:\n\t\t\tif (s->s3->in_read_app_data &&\n\t\t\t\t(s->s3->total_renegotiations != 0) &&\n\t\t\t\t((\n\t\t\t\t  (s->state & SSL_ST_CONNECT) &&\n\t\t\t\t  (s->state >= SSL3_ST_CW_CLNT_HELLO_A) &&\n\t\t\t\t  (s->state <= SSL3_ST_CR_SRVR_HELLO_A)\n\t\t\t\t ) || (\n\t\t\t\t  (s->state & SSL_ST_ACCEPT) &&\n\t\t\t\t  (s->state <= SSL3_ST_SW_HELLO_REQ_A) &&\n\t\t\t\t  (s->state >= SSL3_ST_SR_CLNT_HELLO_A)\n\t\t\t\t )\n\t\t\t\t))\n\t\t\t\t{\n\t\t\t\ts->s3->in_read_app_data=0;\n\t\t\t\treturn(-1);\n\t\t\t\t}\n\t\t\telse\n\t\t\t\t{\n\t\t\t\tal=SSL_AD_UNEXPECTED_MESSAGE;\n\t\t\t\tSSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_UNEXPECTED_RECORD);\n\t\t\t\tgoto f_err;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\tif (SSL_in_init(s) && (type == SSL3_RT_APPLICATION_DATA) &&\n\t\t(s->enc_read_ctx == NULL))\n\t\t{\n\t\tal=SSL_AD_UNEXPECTED_MESSAGE;\n\t\tSSLerr(SSL_F_SSL3_READ_BYTES,SSL_R_APP_DATA_IN_HANDSHAKE);\n\t\tgoto f_err;\n\t\t}\n\tif (len <= 0) return(len);\n\tif ((unsigned int)len > rr->length)\n\t\tn=rr->length;\n\telse\n\t\tn=len;\n\tmemcpy(buf,&(rr->data[rr->off]),(unsigned int)n);\n\trr->length-=n;\n\trr->off+=n;\n\tif (rr->length <= 0)\n\t\t{\n\t\ts->rstate=SSL_ST_READ_HEADER;\n\t\trr->off=0;\n\t\t}\n\tif (type == SSL3_RT_HANDSHAKE)\n\t\tssl3_finish_mac(s,buf,n);\n\treturn(n);\nf_err:\n\tssl3_send_alert(s,SSL3_AL_FATAL,al);\nerr:\n\treturn(-1);\n\t}', 'int SSL_CTX_remove_session(SSL_CTX *ctx, SSL_SESSION *c)\n\t{\n\tSSL_SESSION *r;\n\tint ret=0;\n\tif ((c != NULL) && (c->session_id_length != 0))\n\t\t{\n\t\tCRYPTO_w_lock(CRYPTO_LOCK_SSL_CTX);\n\t\tr=(SSL_SESSION *)lh_delete(ctx->sessions,(char *)c);\n\t\tif (r != NULL)\n\t\t\t{\n\t\t\tret=1;\n\t\t\tSSL_SESSION_list_remove(ctx,c);\n\t\t\t}\n\t\tCRYPTO_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}', 'char *lh_delete(LHASH *lh, char *data)\n\t{\n\tunsigned long hash;\n\tLHASH_NODE *nn,**rn;\n\tchar *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\tFree((char *)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 **)Realloc((char *)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}']