ssl/s3_clnt.c:856: error: INTEGER_OVERFLOW_L2
  ([0, +oo] - 1):unsigned32 by call to `ssl3_send_alert`.
Showing all 14 steps of the trace


ssl/s3_clnt.c:696:4: Call
694.           int need_cert = 1; /* VRS: 0=> will allow null cert if auth == KRB5 */
695.   
696.   	n=ssl3_get_message(s,
          ^
697.   		SSL3_ST_CR_CERT_A,
698.   		SSL3_ST_CR_CERT_B,

ssl/s3_both.c:337:1: Parameter `s->ctx->sessions->p`
  335.    * the body is read in state 'stn'.
  336.    */
  337. > long ssl3_get_message(SSL *s, int st1, int stn, int mt, long max, int *ok)
  338.   	{
  339.   	unsigned char *p;

ssl/s3_clnt.c:856:3: Call
854.   		{
855.   f_err:
856.   		ssl3_send_alert(s,SSL3_AL_FATAL,al);
         ^
857.   		}
858.   err:

ssl/s3_pkt.c:1149:1: Parameter `s->ctx->sessions->p`
  1147.   	}
  1148.   
  1149. > void ssl3_send_alert(SSL *s, int level, int desc)
  1150.   	{
  1151.   	/* Map tls/ssl alert value to correct one */

ssl/s3_pkt.c:1156:3: Call
  1154.   	/* If a fatal one, remove from cache */
  1155.   	if ((level == 2) && (s->session != NULL))
  1156.   		SSL_CTX_remove_session(s->ctx,s->session);
            ^
  1157.   
  1158.   	s->s3->alert_dispatch=1;

ssl/ssl_sess.c:413:1: Parameter `ctx->sessions->p`
    411.   	}
    412.   
    413. > int SSL_CTX_remove_session(SSL_CTX *ctx, SSL_SESSION *c)
    414.   {
    415.   	return remove_session_lock(ctx, c, 1);

ssl/ssl_sess.c:415:9: Call
    413.   int SSL_CTX_remove_session(SSL_CTX *ctx, SSL_SESSION *c)
    414.   {
    415.   	return remove_session_lock(ctx, c, 1);
                   ^
    416.   }
    417.   

ssl/ssl_sess.c:418:1: Parameter `ctx->sessions->p`
      416.   }
      417.   
      418. > static int remove_session_lock(SSL_CTX *ctx, SSL_SESSION *c, int lck)
      419.   	{
      420.   	SSL_SESSION *r;

ssl/ssl_sess.c:426:20: Call
      424.   		{
      425.   		if(lck) CRYPTO_w_lock(CRYPTO_LOCK_SSL_CTX);
      426.   		r=(SSL_SESSION *)lh_delete(ctx->sessions,c);
                                ^
      427.   		if (r != NULL)
      428.   			{

crypto/lhash/lhash.c:217:1: Parameter `lh->pmax`
        215.   	}
        216.   
        217. > void *lh_delete(LHASH *lh, 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:352:1: <LHS trace>
350.   	}
351.   
352. > static void contract(LHASH *lh)
353.   	{
354.   	LHASH_NODE **n,*n1,*np;

crypto/lhash/lhash.c:352:1: Parameter `lh->p`
          350.   	}
          351.   
          352. > static void contract(LHASH *lh)
          353.   	{
          354.   	LHASH_NODE **n,*n1,*np;

crypto/lhash/lhash.c:356:5: Binary operation: ([0, +oo] - 1):unsigned32 by call to `ssl3_send_alert` 
          354.   	LHASH_NODE **n,*n1,*np;
          355.   
          356.   	np=lh->b[lh->p+lh->pmax-1];
                     ^
          357.   	lh->b[lh->p+lh->pmax-1]=NULL; /* 24/07-92 - eay - weird but :-( */
          358.   	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;
		}
	}
['static int ssl3_get_server_certificate(SSL *s)\n\t{\n\tint al,i,ok,ret= -1;\n\tunsigned long n,nc,llen,l;\n\tX509 *x=NULL;\n\tunsigned char *p,*d,*q;\n\tSTACK_OF(X509) *sk=NULL;\n\tSESS_CERT *sc;\n\tEVP_PKEY *pkey=NULL;\n        int need_cert = 1;\n\tn=ssl3_get_message(s,\n\t\tSSL3_ST_CR_CERT_A,\n\t\tSSL3_ST_CR_CERT_B,\n\t\t-1,\n#if defined(MSDOS) && !defined(WIN32)\n\t\t1024*30,\n#else\n\t\t1024*100,\n#endif\n\t\t&ok);\n\tif (!ok) return((int)n);\n\tif (s->s3->tmp.message_type == SSL3_MT_SERVER_KEY_EXCHANGE)\n\t\t{\n\t\ts->s3->tmp.reuse_message=1;\n\t\treturn(1);\n\t\t}\n\tif (s->s3->tmp.message_type != SSL3_MT_CERTIFICATE)\n\t\t{\n\t\tal=SSL_AD_UNEXPECTED_MESSAGE;\n\t\tSSLerr(SSL_F_SSL3_GET_SERVER_CERTIFICATE,SSL_R_BAD_MESSAGE_TYPE);\n\t\tgoto f_err;\n\t\t}\n\td=p=(unsigned char *)s->init_buf->data;\n\tif ((sk=sk_X509_new_null()) == NULL)\n\t\t{\n\t\tSSLerr(SSL_F_SSL3_GET_SERVER_CERTIFICATE,ERR_R_MALLOC_FAILURE);\n\t\tgoto err;\n\t\t}\n\tn2l3(p,llen);\n\tif (llen+3 != n)\n\t\t{\n\t\tal=SSL_AD_DECODE_ERROR;\n\t\tSSLerr(SSL_F_SSL3_GET_SERVER_CERTIFICATE,SSL_R_LENGTH_MISMATCH);\n\t\tgoto f_err;\n\t\t}\n\tfor (nc=0; nc<llen; )\n\t\t{\n\t\tn2l3(p,l);\n\t\tif ((l+nc+3) > llen)\n\t\t\t{\n\t\t\tal=SSL_AD_DECODE_ERROR;\n\t\t\tSSLerr(SSL_F_SSL3_GET_SERVER_CERTIFICATE,SSL_R_CERT_LENGTH_MISMATCH);\n\t\t\tgoto f_err;\n\t\t\t}\n\t\tq=p;\n\t\tx=d2i_X509(NULL,&q,l);\n\t\tif (x == NULL)\n\t\t\t{\n\t\t\tal=SSL_AD_BAD_CERTIFICATE;\n\t\t\tSSLerr(SSL_F_SSL3_GET_SERVER_CERTIFICATE,ERR_R_ASN1_LIB);\n\t\t\tgoto f_err;\n\t\t\t}\n\t\tif (q != (p+l))\n\t\t\t{\n\t\t\tal=SSL_AD_DECODE_ERROR;\n\t\t\tSSLerr(SSL_F_SSL3_GET_SERVER_CERTIFICATE,SSL_R_CERT_LENGTH_MISMATCH);\n\t\t\tgoto f_err;\n\t\t\t}\n\t\tif (!sk_X509_push(sk,x))\n\t\t\t{\n\t\t\tSSLerr(SSL_F_SSL3_GET_SERVER_CERTIFICATE,ERR_R_MALLOC_FAILURE);\n\t\t\tgoto err;\n\t\t\t}\n\t\tx=NULL;\n\t\tnc+=l+3;\n\t\tp=q;\n\t\t}\n\ti=ssl_verify_cert_chain(s,sk);\n\tif ((s->verify_mode != SSL_VERIFY_NONE) && (!i))\n\t\t{\n\t\tal=ssl_verify_alarm_type(s->verify_result);\n\t\tSSLerr(SSL_F_SSL3_GET_SERVER_CERTIFICATE,SSL_R_CERTIFICATE_VERIFY_FAILED);\n\t\tgoto f_err;\n\t\t}\n\tERR_clear_error();\n\tsc=ssl_sess_cert_new();\n\tif (sc == NULL) goto err;\n\tif (s->session->sess_cert) ssl_sess_cert_free(s->session->sess_cert);\n\ts->session->sess_cert=sc;\n\tsc->cert_chain=sk;\n\tx=sk_X509_value(sk,0);\n\tsk=NULL;\n\tpkey=X509_get_pubkey(x);\n        need_cert =\n                ((s->s3->tmp.new_cipher->algorithms & (SSL_MKEY_MASK|SSL_AUTH_MASK))\n                        == (SSL_aKRB5|SSL_kKRB5))? 0: 1;\n#ifdef KSSL_DEBUG\n\tprintf("pkey,x = %p, %p\\n", pkey,x);\n\tprintf("ssl_cert_type(x,pkey) = %d\\n", ssl_cert_type(x,pkey));\n\tprintf("cipher, alg, nc = %s, %lx, %d\\n", s->s3->tmp.new_cipher->name,\n                s->s3->tmp.new_cipher->algorithms, need_cert);\n#endif\n\tif (need_cert  &&  ((pkey == NULL) || EVP_PKEY_missing_parameters(pkey)))\n\t\t{\n\t\tx=NULL;\n\t\tal=SSL3_AL_FATAL;\n\t\tSSLerr(SSL_F_SSL3_GET_SERVER_CERTIFICATE,SSL_R_UNABLE_TO_FIND_PUBLIC_KEY_PARAMETERS);\n\t\tgoto f_err;\n\t\t}\n\ti=ssl_cert_type(x,pkey);\n\tif (need_cert && i < 0)\n\t\t{\n\t\tx=NULL;\n\t\tal=SSL3_AL_FATAL;\n\t\tSSLerr(SSL_F_SSL3_GET_SERVER_CERTIFICATE,SSL_R_UNKNOWN_CERTIFICATE_TYPE);\n\t\tgoto f_err;\n\t\t}\n        if (need_cert)\n                {\n                sc->peer_cert_type=i;\n                CRYPTO_add(&x->references,1,CRYPTO_LOCK_X509);\n                if (sc->peer_pkeys[i].x509 != NULL)\n                        X509_free(sc->peer_pkeys[i].x509);\n                sc->peer_pkeys[i].x509=x;\n                sc->peer_key= &(sc->peer_pkeys[i]);\n                if (s->session->peer != NULL)\n                        X509_free(s->session->peer);\n                CRYPTO_add(&x->references,1,CRYPTO_LOCK_X509);\n                s->session->peer=x;\n                }\n        else\n                {\n                sc->peer_cert_type=i;\n                sc->peer_key= NULL;\n                if (s->session->peer != NULL)\n                        X509_free(s->session->peer);\n                s->session->peer=NULL;\n                }\n\ts->session->verify_result = s->verify_result;\n\tx=NULL;\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\tEVP_PKEY_free(pkey);\n\tX509_free(x);\n\tsk_X509_pop_free(sk,X509_free);\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\tint skip_message;\n\t\tdo\n\t\t\t{\n\t\t\twhile (s->init_num < 4)\n\t\t\t\t{\n\t\t\t\ti=ssl3_read_bytes(s,SSL3_RT_HANDSHAKE,&p[s->init_num],\n\t\t\t\t\t4 - s->init_num);\n\t\t\t\tif (i <= 0)\n\t\t\t\t\t{\n\t\t\t\t\ts->rwstate=SSL_READING;\n\t\t\t\t\t*ok = 0;\n\t\t\t\t\treturn i;\n\t\t\t\t\t}\n\t\t\t\ts->init_num+=i;\n\t\t\t\t}\n\t\t\tskip_message = 0;\n\t\t\tif (!s->server)\n\t\t\t\tif (p[0] == SSL3_MT_HELLO_REQUEST)\n\t\t\t\t\tif (p[1] == 0 && p[2] == 0 &&p[3] == 0)\n\t\t\t\t\t\tskip_message = 1;\n\t\t\t}\n\t\twhile (skip_message);\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\tif ((mt < 0) && (*p == SSL3_MT_CLIENT_HELLO) &&\n\t\t\t\t\t(st1 == SSL3_ST_SR_CERT_A) &&\n\t\t\t\t\t(stn == SSL3_ST_SR_CERT_B))\n\t\t\t{\n\t\t\tssl3_init_finished_mac(s);\n\t\t\t}\n\t\tssl3_finish_mac(s, (unsigned char *)s->init_buf->data, 4);\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\twhile (n > 0)\n\t\t{\n\t\ti=ssl3_read_bytes(s,SSL3_RT_HANDSHAKE,&p[s->init_num],n);\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\ts->init_num += i;\n\t\tn -= i;\n\t\t}\n\tssl3_finish_mac(s, (unsigned char *)s->init_buf->data, s->init_num);\n\t*ok=1;\n\treturn s->init_num;\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,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}', 'void *lh_delete(LHASH *lh, 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}']