ssl/s3_srvr.c:784: error: INTEGER_OVERFLOW_L2
  ([0, `s->ctx->sessions->num_items` + 1] - 1):unsigned64 by call to `ssl3_send_alert`.
Showing all 13 steps of the trace


ssl/s3_srvr.c:524:1: Parameter `s->ctx->sessions->num_items`
522.   	}
523.   
524. > static int ssl3_get_client_hello(SSL *s)
525.   	{
526.   	int i,j,ok,al,ret= -1;

ssl/s3_srvr.c:545:4: Call
543.   		s->state=SSL3_ST_SR_CLNT_HELLO_B;
544.   		}
545.   	n=ssl3_get_message(s,
          ^
546.   		SSL3_ST_SR_CLNT_HELLO_B,
547.   		SSL3_ST_SR_CLNT_HELLO_C,

ssl/s3_both.c:258:1: Parameter `s->ctx->sessions->num_items`
  256.   	}
  257.   
  258. > long ssl3_get_message(SSL *s, int st1, int stn, int mt, long max, int *ok)
  259.   	{
  260.   	unsigned char *p;

ssl/s3_srvr.c:784:3: Call
782.   		{
783.   f_err:
784.   		ssl3_send_alert(s,SSL3_AL_FATAL,al);
         ^
785.   		}
786.   err:

ssl/s3_pkt.c:984:1: Parameter `s->ctx->sessions->num_items`
  982.   	}
  983.   
  984. > void ssl3_send_alert(SSL *s, int level, int desc)
  985.   	{
  986.   	/* Map tls/ssl alert value to correct one */

ssl/s3_pkt.c:991:3: Call
  989.   	/* If a fatal one, remove from cache */
  990.   	if ((level == 2) && (s->session != NULL))
  991.   		SSL_CTX_remove_session(s->ctx,s->session);
           ^
  992.   
  993.   	s->s3->alert_dispatch=1;

ssl/ssl_sess.c:320:1: Parameter `ctx->sessions->num_items`
    318.   	}
    319.   
    320. > int SSL_CTX_remove_session(SSL_CTX *ctx, SSL_SESSION *c)
    321.   {
    322.   	return remove_session_lock(ctx, c, 1);

ssl/ssl_sess.c:322:9: Call
    320.   int SSL_CTX_remove_session(SSL_CTX *ctx, SSL_SESSION *c)
    321.   {
    322.   	return remove_session_lock(ctx, c, 1);
                   ^
    323.   }
    324.   

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

ssl/ssl_sess.c:333:20: Call
      331.   		{
      332.   		if(lck) 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:220:1: <LHS trace>
218.   	}
219.   
220. > char *lh_delete(LHASH *lh, char *data)
221.   	{
222.   	unsigned long hash;

crypto/lhash/lhash.c:220:1: Parameter `lh->num_items`
        218.   	}
        219.   
        220. > char *lh_delete(LHASH *lh, char *data)
        221.   	{
        222.   	unsigned long hash;

crypto/lhash/lhash.c:243:2: Binary operation: ([0, s->ctx->sessions->num_items + 1] - 1):unsigned64 by call to `ssl3_send_alert` 
        241.   		}
        242.   
        243.   	lh->num_items--;
                ^
        244.   	if ((lh->num_nodes > MIN_NODES) &&
        245.   		(lh->down_load >= (lh->num_items*LH_LOAD_MULT/lh->num_nodes)))

char *lh_delete(LHASH *lh, char *data)
	{
	unsigned long hash;
	LHASH_NODE *nn,**rn;
	char *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;
		Free((char *)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);
	}
['static int ssl3_get_client_hello(SSL *s)\n\t{\n\tint i,j,ok,al,ret= -1;\n\tlong n;\n\tunsigned long id;\n\tunsigned char *p,*d,*q;\n\tSSL_CIPHER *c;\n\tSSL_COMP *comp=NULL;\n\tSTACK_OF(SSL_CIPHER) *ciphers=NULL;\n\tif (s->state == SSL3_ST_SR_CLNT_HELLO_A)\n\t\t{\n\t\ts->first_packet=1;\n\t\ts->state=SSL3_ST_SR_CLNT_HELLO_B;\n\t\t}\n\tn=ssl3_get_message(s,\n\t\tSSL3_ST_SR_CLNT_HELLO_B,\n\t\tSSL3_ST_SR_CLNT_HELLO_C,\n\t\tSSL3_MT_CLIENT_HELLO,\n\t\tSSL3_RT_MAX_PLAIN_LENGTH,\n\t\t&ok);\n\tif (!ok) return((int)n);\n\td=p=(unsigned char *)s->init_buf->data;\n\tp+=2;\n\tmemcpy(s->s3->client_random,p,SSL3_RANDOM_SIZE);\n\tp+=SSL3_RANDOM_SIZE;\n\tj= *(p++);\n\ts->hit=0;\n\tif (j == 0)\n\t\t{\n\t\tif (!ssl_get_new_session(s,1))\n\t\t\tgoto err;\n\t\t}\n\telse\n\t\t{\n\t\ti=ssl_get_prev_session(s,p,j);\n\t\tif (i == 1)\n\t\t\t{\n\t\t\ts->hit=1;\n\t\t\t}\n\t\telse\n\t\t\t{\n\t\t\tif (!ssl_get_new_session(s,1))\n\t\t\t\tgoto err;\n\t\t\t}\n\t\t}\n\tp+=j;\n\tn2s(p,i);\n\tif ((i == 0) && (j != 0))\n\t\t{\n\t\tal=SSL_AD_ILLEGAL_PARAMETER;\n\t\tSSLerr(SSL_F_SSL3_GET_CLIENT_HELLO,SSL_R_NO_CIPHERS_SPECIFIED);\n\t\tgoto f_err;\n\t\t}\n\tif ((i+p) > (d+n))\n\t\t{\n\t\tal=SSL_AD_DECODE_ERROR;\n\t\tSSLerr(SSL_F_SSL3_GET_CLIENT_HELLO,SSL_R_LENGTH_MISMATCH);\n\t\tgoto f_err;\n\t\t}\n\tif ((i > 0) && (ssl_bytes_to_cipher_list(s,p,i,&(ciphers))\n\t\t== NULL))\n\t\t{\n\t\tgoto err;\n\t\t}\n\tp+=i;\n\tif ((s->hit) && (i > 0))\n\t\t{\n\t\tj=0;\n\t\tid=s->session->cipher->id;\n#ifdef CIPHER_DEBUG\n\t\tprintf("client sent %d ciphers\\n",sk_num(ciphers));\n#endif\n\t\tfor (i=0; i<sk_SSL_CIPHER_num(ciphers); i++)\n\t\t\t{\n\t\t\tc=sk_SSL_CIPHER_value(ciphers,i);\n#ifdef CIPHER_DEBUG\n\t\t\tprintf("client [%2d of %2d]:%s\\n",\n\t\t\t\ti,sk_num(ciphers),SSL_CIPHER_get_name(c));\n#endif\n\t\t\tif (c->id == id)\n\t\t\t\t{\n\t\t\t\tj=1;\n\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\tif (j == 0)\n\t\t\t{\n\t\t\tif ((s->options & SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG) && (sk_SSL_CIPHER_num(ciphers) == 1))\n\t\t\t\t{\n\t\t\t\ts->session->cipher=sk_SSL_CIPHER_value(ciphers,\n\t\t\t\t\t\t\t\t       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_GET_CLIENT_HELLO,SSL_R_REQUIRED_CIPHER_MISSING);\n\t\t\t\tgoto f_err;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\ti= *(p++);\n\tq=p;\n\tfor (j=0; j<i; j++)\n\t\t{\n\t\tif (p[j] == 0) break;\n\t\t}\n\tp+=i;\n\tif (j >= i)\n\t\t{\n\t\tal=SSL_AD_DECODE_ERROR;\n\t\tSSLerr(SSL_F_SSL3_GET_CLIENT_HELLO,SSL_R_NO_COMPRESSION_SPECIFIED);\n\t\tgoto f_err;\n\t\t}\n\ts->s3->tmp.new_compression=NULL;\n\tif (s->ctx->comp_methods != NULL)\n\t\t{\n\t\tint m,nn,o,v,done=0;\n\t\tnn=sk_SSL_COMP_num(s->ctx->comp_methods);\n\t\tfor (m=0; m<nn; m++)\n\t\t\t{\n\t\t\tcomp=sk_SSL_COMP_value(s->ctx->comp_methods,m);\n\t\t\tv=comp->id;\n\t\t\tfor (o=0; o<i; o++)\n\t\t\t\t{\n\t\t\t\tif (v == q[o])\n\t\t\t\t\t{\n\t\t\t\t\tdone=1;\n\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\tif (done) break;\n\t\t\t}\n\t\tif (done)\n\t\t\ts->s3->tmp.new_compression=comp;\n\t\telse\n\t\t\tcomp=NULL;\n\t\t}\n\tif (s->version == SSL3_VERSION)\n\t\t{\n\t\tif (p > (d+n))\n\t\t\t{\n\t\t\tal=SSL_AD_DECODE_ERROR;\n\t\t\tSSLerr(SSL_F_SSL3_GET_CLIENT_HELLO,SSL_R_LENGTH_MISMATCH);\n\t\t\tgoto f_err;\n\t\t\t}\n\t\t}\n\tif (!s->hit)\n\t\t{\n\t\ts->session->compress_meth=(comp == NULL)?0:comp->id;\n\t\tif (s->session->ciphers != NULL)\n\t\t\tsk_SSL_CIPHER_free(s->session->ciphers);\n\t\ts->session->ciphers=ciphers;\n\t\tif (ciphers == NULL)\n\t\t\t{\n\t\t\tal=SSL_AD_ILLEGAL_PARAMETER;\n\t\t\tSSLerr(SSL_F_SSL3_GET_CLIENT_HELLO,SSL_R_NO_CIPHERS_PASSED);\n\t\t\tgoto f_err;\n\t\t\t}\n\t\tciphers=NULL;\n\t\tc=ssl3_choose_cipher(s,s->session->ciphers,\n\t\t\t\t     ssl_get_ciphers_by_id(s));\n\t\tif (c == NULL)\n\t\t\t{\n\t\t\tal=SSL_AD_HANDSHAKE_FAILURE;\n\t\t\tSSLerr(SSL_F_SSL3_GET_CLIENT_HELLO,SSL_R_NO_SHARED_CIPHER);\n\t\t\tgoto f_err;\n\t\t\t}\n\t\ts->s3->tmp.new_cipher=c;\n\t\t}\n\telse\n\t\t{\n#ifdef REUSE_CIPHER_BUG\n\t\tSTACK_OF(SSL_CIPHER) *sk;\n\t\tSSL_CIPHER *nc=NULL;\n\t\tSSL_CIPHER *ec=NULL;\n\t\tif (s->options & SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG)\n\t\t\t{\n\t\t\tsk=s->session->ciphers;\n\t\t\tfor (i=0; i<sk_SSL_CIPHER_num(sk); i++)\n\t\t\t\t{\n\t\t\t\tc=sk_SSL_CIPHER_value(sk,i);\n\t\t\t\tif (c->algorithms & SSL_eNULL)\n\t\t\t\t\tnc=c;\n\t\t\t\tif (SSL_C_IS_EXPORT(c))\n\t\t\t\t\tec=c;\n\t\t\t\t}\n\t\t\tif (nc != NULL)\n\t\t\t\ts->s3->tmp.new_cipher=nc;\n\t\t\telse if (ec != NULL)\n\t\t\t\ts->s3->tmp.new_cipher=ec;\n\t\t\telse\n\t\t\t\ts->s3->tmp.new_cipher=s->session->cipher;\n\t\t\t}\n\t\telse\n#endif\n\t\ts->s3->tmp.new_cipher=s->session->cipher;\n\t\t}\n\tret=1;\n\tif (0)\n\t\t{\nf_err:\n\t\tssl3_send_alert(s,SSL3_AL_FATAL,al);\n\t\t}\nerr:\n\tif (ciphers != NULL) sk_SSL_CIPHER_free(ciphers);\n\treturn(ret);\n\t}', 'long ssl3_get_message(SSL *s, int st1, int stn, int mt, long max, int *ok)\n\t{\n\tunsigned char *p;\n\tunsigned long l;\n\tlong n;\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_SSL3_GET_MESSAGE,SSL_R_UNEXPECTED_MESSAGE);\n\t\t\tgoto f_err;\n\t\t\t}\n\t\t*ok=1;\n\t\treturn((int)s->s3->tmp.message_size);\n\t\t}\n\tp=(unsigned char *)s->init_buf->data;\n\tif (s->state == st1)\n\t\t{\n\t\ti=ssl3_read_bytes(s,SSL3_RT_HANDSHAKE,&p[s->init_num],\n\t\t\t\t  4-s->init_num);\n\t\tif (i < (4-s->init_num))\n\t\t\t{\n\t\t\t*ok=0;\n\t\t\treturn(ssl3_part_read(s,i));\n\t\t\t}\n\t\tif ((mt >= 0) && (*p != mt))\n\t\t\t{\n\t\t\tal=SSL_AD_UNEXPECTED_MESSAGE;\n\t\t\tSSLerr(SSL_F_SSL3_GET_MESSAGE,SSL_R_UNEXPECTED_MESSAGE);\n\t\t\tgoto f_err;\n\t\t\t}\n\t\ts->s3->tmp.message_type= *(p++);\n\t\tn2l3(p,l);\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_SSL3_GET_MESSAGE,SSL_R_EXCESSIVE_MESSAGE_SIZE);\n\t\t\tgoto f_err;\n\t\t\t}\n\t\tif (l && !BUF_MEM_grow(s->init_buf,(int)l))\n\t\t\t{\n\t\t\tSSLerr(SSL_F_SSL3_GET_MESSAGE,ERR_R_BUF_LIB);\n\t\t\tgoto err;\n\t\t\t}\n\t\ts->s3->tmp.message_size=l;\n\t\ts->state=stn;\n\t\ts->init_num=0;\n\t\t}\n\tp=(unsigned char *)s->init_buf->data;\n\tn=s->s3->tmp.message_size;\n\tif (n > 0)\n\t\t{\n\t\ti=ssl3_read_bytes(s,SSL3_RT_HANDSHAKE,&p[s->init_num],n);\n\t\tif (i != (int)n)\n\t\t\t{\n\t\t\t*ok=0;\n\t\t\treturn(ssl3_part_read(s,i));\n\t\t\t}\n\t\t}\n\t*ok=1;\n\treturn(n);\nf_err:\n\tssl3_send_alert(s,SSL3_AL_FATAL,al);\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 (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\tssl3_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\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\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}', '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}']