ssl/s2_srvr.c:208: error: INTEGER_OVERFLOW_L2
  ([0, max(0, `s->ctx->sessions->num_items`)] - 1):unsigned64 by call to `get_client_hello`.
Showing all 15 steps of the trace


ssl/s2_srvr.c:145:1: Parameter `s->ctx->sessions->num_items`
143.   			ssl2_get_server_method)
144.   
145. > int ssl2_accept(SSL *s)
146.   	{
147.   	unsigned long l=(unsigned long)time(NULL);

ssl/s2_srvr.c:208:8: Call
206.   		case SSL2_ST_GET_CLIENT_HELLO_C:
207.   			s->shutdown=0;
208.   			ret=get_client_hello(s);
              ^
209.   			if (ret <= 0) goto end;
210.   			s->init_num=0;

ssl/s2_srvr.c:520:1: Parameter `s->ctx->sessions->num_items`
  518.   	}
  519.   
  520. > static int get_client_hello(SSL *s)
  521.   	{
  522.   	int i,n;

ssl/s2_srvr.c:639:6: Call
  637.   	if (!s->hit)
  638.   		{
  639.   		cs=ssl_bytes_to_cipher_list(s,p,s->s2->tmp.cipher_spec_length,
              ^
  640.   			&s->session->ciphers);
  641.   		if (cs == NULL) goto mem_err;

ssl/ssl_lib.c:1391:1: Parameter `s->ctx->sessions->num_items`
    1389.   	}
    1390.   
    1391. > STACK_OF(SSL_CIPHER) *ssl_bytes_to_cipher_list(SSL *s,unsigned char *p,int num,
    1392.   					       STACK_OF(SSL_CIPHER) **skp)
    1393.   	{

ssl/ssl_lib.c:1425:5: Call
    1423.   				{
    1424.   				SSLerr(SSL_F_SSL_BYTES_TO_CIPHER_LIST,SSL_R_SCSV_RECEIVED_WHEN_RENEGOTIATING);
    1425.   				ssl3_send_alert(s,SSL3_AL_FATAL,SSL_AD_HANDSHAKE_FAILURE); 
                ^
    1426.   				goto err;
    1427.   				}

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 `get_client_hello` 
            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 ssl2_accept(SSL *s)\n\t{\n\tunsigned long l=(unsigned long)time(NULL);\n\tBUF_MEM *buf=NULL;\n\tint ret= -1;\n\tlong num1;\n\tvoid (*cb)(const SSL *ssl,int type,int val)=NULL;\n\tint new_state,state;\n\tRAND_add(&l,sizeof(l),0);\n\tERR_clear_error();\n\tclear_sys_error();\n\tif (s->info_callback != NULL)\n\t\tcb=s->info_callback;\n\telse if (s->ctx->info_callback != NULL)\n\t\tcb=s->ctx->info_callback;\n\ts->in_handshake++;\n\tif (!SSL_in_init(s) || SSL_in_before(s)) SSL_clear(s);\n\tif (s->cert == NULL)\n\t\t{\n\t\tSSLerr(SSL_F_SSL2_ACCEPT,SSL_R_NO_CERTIFICATE_SET);\n\t\treturn(-1);\n\t\t}\n\tclear_sys_error();\n\tfor (;;)\n\t\t{\n\t\tstate=s->state;\n\t\tswitch (s->state)\n\t\t\t{\n\t\tcase SSL_ST_BEFORE:\n\t\tcase SSL_ST_ACCEPT:\n\t\tcase SSL_ST_BEFORE|SSL_ST_ACCEPT:\n\t\tcase SSL_ST_OK|SSL_ST_ACCEPT:\n\t\t\ts->server=1;\n\t\t\tif (cb != NULL) cb(s,SSL_CB_HANDSHAKE_START,1);\n\t\t\ts->version=SSL2_VERSION;\n\t\t\ts->type=SSL_ST_ACCEPT;\n\t\t\tbuf=s->init_buf;\n\t\t\tif ((buf == NULL) && ((buf=BUF_MEM_new()) == NULL))\n\t\t\t\t{ ret= -1; goto end; }\n\t\t\tif (!BUF_MEM_grow(buf,(int)\n\t\t\t\tSSL2_MAX_RECORD_LENGTH_3_BYTE_HEADER))\n\t\t\t\t{ ret= -1; goto end; }\n\t\t\ts->init_buf=buf;\n\t\t\ts->init_num=0;\n\t\t\ts->ctx->stats.sess_accept++;\n\t\t\ts->handshake_func=ssl2_accept;\n\t\t\ts->state=SSL2_ST_GET_CLIENT_HELLO_A;\n\t\t\tBREAK;\n\t\tcase SSL2_ST_GET_CLIENT_HELLO_A:\n\t\tcase SSL2_ST_GET_CLIENT_HELLO_B:\n\t\tcase SSL2_ST_GET_CLIENT_HELLO_C:\n\t\t\ts->shutdown=0;\n\t\t\tret=get_client_hello(s);\n\t\t\tif (ret <= 0) goto end;\n\t\t\ts->init_num=0;\n\t\t\ts->state=SSL2_ST_SEND_SERVER_HELLO_A;\n\t\t\tBREAK;\n\t\tcase SSL2_ST_SEND_SERVER_HELLO_A:\n\t\tcase SSL2_ST_SEND_SERVER_HELLO_B:\n\t\t\tret=server_hello(s);\n\t\t\tif (ret <= 0) goto end;\n\t\t\ts->init_num=0;\n\t\t\tif (!s->hit)\n\t\t\t\t{\n\t\t\t\ts->state=SSL2_ST_GET_CLIENT_MASTER_KEY_A;\n\t\t\t\tBREAK;\n\t\t\t\t}\n\t\t\telse\n\t\t\t\t{\n\t\t\t\ts->state=SSL2_ST_SERVER_START_ENCRYPTION;\n\t\t\t\tBREAK;\n\t\t\t\t}\n\t\tcase SSL2_ST_GET_CLIENT_MASTER_KEY_A:\n\t\tcase SSL2_ST_GET_CLIENT_MASTER_KEY_B:\n\t\t\tret=get_client_master_key(s);\n\t\t\tif (ret <= 0) goto end;\n\t\t\ts->init_num=0;\n\t\t\ts->state=SSL2_ST_SERVER_START_ENCRYPTION;\n\t\t\tBREAK;\n\t\tcase SSL2_ST_SERVER_START_ENCRYPTION:\n\t\t\tif (!ssl2_enc_init(s,0))\n\t\t\t\t{ ret= -1; goto end; }\n\t\t\ts->s2->clear_text=0;\n\t\t\ts->state=SSL2_ST_SEND_SERVER_VERIFY_A;\n\t\t\tBREAK;\n\t\tcase SSL2_ST_SEND_SERVER_VERIFY_A:\n\t\tcase SSL2_ST_SEND_SERVER_VERIFY_B:\n\t\t\tret=server_verify(s);\n\t\t\tif (ret <= 0) goto end;\n\t\t\ts->init_num=0;\n\t\t\tif (s->hit)\n\t\t\t\t{\n\t\t\t\ts->state=SSL2_ST_SEND_SERVER_VERIFY_C;\n\t\t\t\tBREAK;\n\t\t\t\t}\n\t\t\telse\n\t\t\t\t{\n\t\t\t\ts->state=SSL2_ST_GET_CLIENT_FINISHED_A;\n\t\t\t\tbreak;\n\t\t\t\t}\n \t\tcase SSL2_ST_SEND_SERVER_VERIFY_C:\n \t\t\tnum1=BIO_ctrl(s->wbio,BIO_CTRL_INFO,0,NULL);\n \t\t\tif (num1 > 0)\n \t\t\t\t{\n\t\t\t\ts->rwstate=SSL_WRITING;\n \t\t\t\tnum1=BIO_flush(s->wbio);\n \t\t\t\tif (num1 <= 0) { ret= -1; goto end; }\n\t\t\t\ts->rwstate=SSL_NOTHING;\n\t\t\t\t}\n \t\t\ts->wbio=BIO_pop(s->wbio);\n \t\t\ts->state=SSL2_ST_GET_CLIENT_FINISHED_A;\n  \t\t\tBREAK;\n\t\tcase SSL2_ST_GET_CLIENT_FINISHED_A:\n\t\tcase SSL2_ST_GET_CLIENT_FINISHED_B:\n\t\t\tret=get_client_finished(s);\n\t\t\tif (ret <= 0)\n\t\t\t\tgoto end;\n\t\t\ts->init_num=0;\n\t\t\ts->state=SSL2_ST_SEND_REQUEST_CERTIFICATE_A;\n\t\t\tBREAK;\n\t\tcase SSL2_ST_SEND_REQUEST_CERTIFICATE_A:\n\t\tcase SSL2_ST_SEND_REQUEST_CERTIFICATE_B:\n\t\tcase SSL2_ST_SEND_REQUEST_CERTIFICATE_C:\n\t\tcase SSL2_ST_SEND_REQUEST_CERTIFICATE_D:\n\t\t\tif (!(s->verify_mode & SSL_VERIFY_PEER) ||\n\t\t\t\t((s->session->peer != NULL) &&\n\t\t\t\t(s->verify_mode & SSL_VERIFY_CLIENT_ONCE)))\n\t\t\t\t{\n\t\t\t\ts->state=SSL2_ST_SEND_SERVER_FINISHED_A;\n\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\telse\n\t\t\t\t{\n\t\t\t\tret=request_certificate(s);\n\t\t\t\tif (ret <= 0) goto end;\n\t\t\t\ts->init_num=0;\n\t\t\t\ts->state=SSL2_ST_SEND_SERVER_FINISHED_A;\n\t\t\t\t}\n\t\t\tBREAK;\n\t\tcase SSL2_ST_SEND_SERVER_FINISHED_A:\n\t\tcase SSL2_ST_SEND_SERVER_FINISHED_B:\n\t\t\tret=server_finish(s);\n\t\t\tif (ret <= 0) goto end;\n\t\t\ts->init_num=0;\n\t\t\ts->state=SSL_ST_OK;\n\t\t\tbreak;\n\t\tcase SSL_ST_OK:\n\t\t\tBUF_MEM_free(s->init_buf);\n\t\t\tssl_free_wbio_buffer(s);\n\t\t\ts->init_buf=NULL;\n\t\t\ts->init_num=0;\n\t\t\tssl_update_cache(s,SSL_SESS_CACHE_SERVER);\n\t\t\ts->ctx->stats.sess_accept_good++;\n\t\t\tret=1;\n\t\t\tif (cb != NULL) cb(s,SSL_CB_HANDSHAKE_DONE,1);\n\t\t\tgoto end;\n\t\tdefault:\n\t\t\tSSLerr(SSL_F_SSL2_ACCEPT,SSL_R_UNKNOWN_STATE);\n\t\t\tret= -1;\n\t\t\tgoto end;\n\t\t\t}\n\t\tif ((cb != NULL) && (s->state != state))\n\t\t\t{\n\t\t\tnew_state=s->state;\n\t\t\ts->state=state;\n\t\t\tcb(s,SSL_CB_ACCEPT_LOOP,1);\n\t\t\ts->state=new_state;\n\t\t\t}\n\t\t}\nend:\n\ts->in_handshake--;\n\tif (cb != NULL)\n\t\tcb(s,SSL_CB_ACCEPT_EXIT,ret);\n\treturn(ret);\n\t}', 'static int get_client_hello(SSL *s)\n\t{\n\tint i,n;\n\tunsigned long len;\n\tunsigned char *p;\n\tSTACK_OF(SSL_CIPHER) *cs;\n\tSTACK_OF(SSL_CIPHER) *cl;\n\tSTACK_OF(SSL_CIPHER) *prio, *allow;\n\tint z;\n\tif (s->state == SSL2_ST_GET_CLIENT_HELLO_A)\n\t\t{\n\t\ts->first_packet=1;\n\t\ts->state=SSL2_ST_GET_CLIENT_HELLO_B;\n\t\t}\n\tp=(unsigned char *)s->init_buf->data;\n\tif (s->state == SSL2_ST_GET_CLIENT_HELLO_B)\n\t\t{\n\t\ti=ssl2_read(s,(char *)&(p[s->init_num]),9-s->init_num);\n\t\tif (i < (9-s->init_num))\n\t\t\treturn(ssl2_part_read(s,SSL_F_GET_CLIENT_HELLO,i));\n\t\ts->init_num = 9;\n\t\tif (*(p++) != SSL2_MT_CLIENT_HELLO)\n\t\t\t{\n\t\t\tif (p[-1] != SSL2_MT_ERROR)\n\t\t\t\t{\n\t\t\t\tssl2_return_error(s,SSL2_PE_UNDEFINED_ERROR);\n\t\t\t\tSSLerr(SSL_F_GET_CLIENT_HELLO,SSL_R_READ_WRONG_PACKET_TYPE);\n\t\t\t\t}\n\t\t\telse\n\t\t\t\tSSLerr(SSL_F_GET_CLIENT_HELLO,SSL_R_PEER_ERROR);\n\t\t\treturn(-1);\n\t\t\t}\n\t\tn2s(p,i);\n\t\tif (i < s->version) s->version=i;\n\t\tn2s(p,i); s->s2->tmp.cipher_spec_length=i;\n\t\tn2s(p,i); s->s2->tmp.session_id_length=i;\n\t\tn2s(p,i); s->s2->challenge_length=i;\n\t\tif (\t(i < SSL2_MIN_CHALLENGE_LENGTH) ||\n\t\t\t(i > SSL2_MAX_CHALLENGE_LENGTH))\n\t\t\t{\n\t\t\tssl2_return_error(s,SSL2_PE_UNDEFINED_ERROR);\n\t\t\tSSLerr(SSL_F_GET_CLIENT_HELLO,SSL_R_INVALID_CHALLENGE_LENGTH);\n\t\t\treturn(-1);\n\t\t\t}\n\t\ts->state=SSL2_ST_GET_CLIENT_HELLO_C;\n\t\t}\n\tp=(unsigned char *)s->init_buf->data;\n\tlen = 9 + (unsigned long)s->s2->tmp.cipher_spec_length + (unsigned long)s->s2->challenge_length + (unsigned long)s->s2->tmp.session_id_length;\n\tif (len > SSL2_MAX_RECORD_LENGTH_3_BYTE_HEADER)\n\t\t{\n\t\tssl2_return_error(s,SSL2_PE_UNDEFINED_ERROR);\n\t\tSSLerr(SSL_F_GET_CLIENT_HELLO,SSL_R_MESSAGE_TOO_LONG);\n\t\treturn -1;\n\t\t}\n\tn = (int)len - s->init_num;\n\ti = ssl2_read(s,(char *)&(p[s->init_num]),n);\n\tif (i != n) return(ssl2_part_read(s,SSL_F_GET_CLIENT_HELLO,i));\n\tif (s->msg_callback)\n\t\ts->msg_callback(0, s->version, 0, p, (size_t)len, s, s->msg_callback_arg);\n\tp += 9;\n\tif ((s->s2->tmp.session_id_length != 0) &&\n\t\t(s->s2->tmp.session_id_length != SSL2_SSL_SESSION_ID_LENGTH))\n\t\t{\n\t\tssl2_return_error(s,SSL2_PE_UNDEFINED_ERROR);\n\t\tSSLerr(SSL_F_GET_CLIENT_HELLO,SSL_R_BAD_SSL_SESSION_ID_LENGTH);\n\t\treturn(-1);\n\t\t}\n\tif (s->s2->tmp.session_id_length == 0)\n\t\t{\n\t\tif (!ssl_get_new_session(s,1))\n\t\t\t{\n\t\t\tssl2_return_error(s,SSL2_PE_UNDEFINED_ERROR);\n\t\t\treturn(-1);\n\t\t\t}\n\t\t}\n\telse\n\t\t{\n\t\ti=ssl_get_prev_session(s,&(p[s->s2->tmp.cipher_spec_length]),\n\t\t\ts->s2->tmp.session_id_length, NULL);\n\t\tif (i == 1)\n\t\t\t{\n\t\t\ts->hit=1;\n\t\t\t}\n\t\telse if (i == -1)\n\t\t\t{\n\t\t\tssl2_return_error(s,SSL2_PE_UNDEFINED_ERROR);\n\t\t\treturn(-1);\n\t\t\t}\n\t\telse\n\t\t\t{\n\t\t\tif (s->cert == NULL)\n\t\t\t\t{\n\t\t\t\tssl2_return_error(s,SSL2_PE_NO_CERTIFICATE);\n\t\t\t\tSSLerr(SSL_F_GET_CLIENT_HELLO,SSL_R_NO_CERTIFICATE_SET);\n\t\t\t\treturn(-1);\n\t\t\t\t}\n\t\t\tif (!ssl_get_new_session(s,1))\n\t\t\t\t{\n\t\t\t\tssl2_return_error(s,SSL2_PE_UNDEFINED_ERROR);\n\t\t\t\treturn(-1);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\tif (!s->hit)\n\t\t{\n\t\tcs=ssl_bytes_to_cipher_list(s,p,s->s2->tmp.cipher_spec_length,\n\t\t\t&s->session->ciphers);\n\t\tif (cs == NULL) goto mem_err;\n\t\tcl=SSL_get_ciphers(s);\n\t\tif (s->options & SSL_OP_CIPHER_SERVER_PREFERENCE)\n\t\t    {\n\t\t    prio=sk_SSL_CIPHER_dup(cl);\n\t\t    if (prio == NULL) goto mem_err;\n\t\t    allow = cs;\n\t\t    }\n\t\telse\n\t\t    {\n\t\t    prio = cs;\n\t\t    allow = cl;\n\t\t    }\n\t\tfor (z=0; z<sk_SSL_CIPHER_num(prio); z++)\n\t\t\t{\n\t\t\tif (sk_SSL_CIPHER_find(allow,sk_SSL_CIPHER_value(prio,z)) < 0)\n\t\t\t\t{\n\t\t\t\t(void)sk_SSL_CIPHER_delete(prio,z);\n\t\t\t\tz--;\n\t\t\t\t}\n\t\t\t}\n\t\tif (s->options & SSL_OP_CIPHER_SERVER_PREFERENCE)\n\t\t    {\n\t\t    sk_SSL_CIPHER_free(s->session->ciphers);\n\t\t    s->session->ciphers = prio;\n\t\t    }\n\t\t}\n\tp+=s->s2->tmp.cipher_spec_length;\n\tp+=s->s2->tmp.session_id_length;\n\tif (s->s2->challenge_length > sizeof s->s2->challenge)\n\t\t{\n\t\tssl2_return_error(s,SSL2_PE_UNDEFINED_ERROR);\n\t\tSSLerr(SSL_F_GET_CLIENT_HELLO, ERR_R_INTERNAL_ERROR);\n\t\treturn -1;\n\t\t}\n\tmemcpy(s->s2->challenge,p,(unsigned int)s->s2->challenge_length);\n\treturn(1);\nmem_err:\n\tSSLerr(SSL_F_GET_CLIENT_HELLO,ERR_R_MALLOC_FAILURE);\n\treturn(0);\n\t}', 'STACK_OF(SSL_CIPHER) *ssl_bytes_to_cipher_list(SSL *s,unsigned char *p,int num,\n\t\t\t\t\t       STACK_OF(SSL_CIPHER) **skp)\n\t{\n\tconst SSL_CIPHER *c;\n\tSTACK_OF(SSL_CIPHER) *sk;\n\tint i,n;\n\tif (s->s3)\n\t\ts->s3->send_connection_binding = 0;\n\tn=ssl_put_cipher_by_char(s,NULL,NULL);\n\tif ((num%n) != 0)\n\t\t{\n\t\tSSLerr(SSL_F_SSL_BYTES_TO_CIPHER_LIST,SSL_R_ERROR_IN_RECEIVED_CIPHER_LIST);\n\t\treturn(NULL);\n\t\t}\n\tif ((skp == NULL) || (*skp == NULL))\n\t\tsk=sk_SSL_CIPHER_new_null();\n\telse\n\t\t{\n\t\tsk= *skp;\n\t\tsk_SSL_CIPHER_zero(sk);\n\t\t}\n\tfor (i=0; i<num; i+=n)\n\t\t{\n\t\tif (s->s3 && (n != 3 || !p[0]) &&\n\t\t\t(p[n-2] == ((SSL3_CK_SCSV >> 8) & 0xff)) &&\n\t\t\t(p[n-1] == (SSL3_CK_SCSV & 0xff)))\n\t\t\t{\n\t\t\tif (s->new_session)\n\t\t\t\t{\n\t\t\t\tSSLerr(SSL_F_SSL_BYTES_TO_CIPHER_LIST,SSL_R_SCSV_RECEIVED_WHEN_RENEGOTIATING);\n\t\t\t\tssl3_send_alert(s,SSL3_AL_FATAL,SSL_AD_HANDSHAKE_FAILURE);\n\t\t\t\tgoto err;\n\t\t\t\t}\n\t\t\ts->s3->send_connection_binding = 1;\n\t\t\tp += n;\n#ifdef OPENSSL_RI_DEBUG\n\t\t\tfprintf(stderr, "SCSV received by server\\n");\n#endif\n\t\t\tcontinue;\n\t\t\t}\n\t\tc=ssl_get_cipher_by_char(s,p);\n\t\tp+=n;\n\t\tif (c != NULL)\n\t\t\t{\n\t\t\tif (!sk_SSL_CIPHER_push(sk,c))\n\t\t\t\t{\n\t\t\t\tSSLerr(SSL_F_SSL_BYTES_TO_CIPHER_LIST,ERR_R_MALLOC_FAILURE);\n\t\t\t\tgoto err;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\tif (skp != NULL)\n\t\t*skp=sk;\n\treturn(sk);\nerr:\n\tif ((skp == NULL) || (*skp == NULL))\n\t\tsk_SSL_CIPHER_free(sk);\n\treturn(NULL);\n\t}', '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}']