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 ssl23_connect(SSL *s)\n\t{\n\tBUF_MEM *buf=NULL;\n\tunsigned long Time=(unsigned long)time(NULL);\n\tvoid (*cb)(const SSL *ssl,int type,int val)=NULL;\n\tint ret= -1;\n\tint new_state,state;\n\tRAND_add(&Time,sizeof(Time),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\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_CONNECT:\n\t\tcase SSL_ST_BEFORE|SSL_ST_CONNECT:\n\t\tcase SSL_ST_OK|SSL_ST_CONNECT:\n\t\t\tif (s->session != NULL)\n\t\t\t\t{\n\t\t\t\tSSLerr(SSL_F_SSL23_CONNECT,SSL_R_SSL23_DOING_SESSION_ID_REUSE);\n\t\t\t\tret= -1;\n\t\t\t\tgoto end;\n\t\t\t\t}\n\t\t\ts->server=0;\n\t\t\tif (cb != NULL) cb(s,SSL_CB_HANDSHAKE_START,1);\n\t\t\ts->type=SSL_ST_CONNECT;\n\t\t\tif (s->init_buf == NULL)\n\t\t\t\t{\n\t\t\t\tif ((buf=BUF_MEM_new()) == NULL)\n\t\t\t\t\t{\n\t\t\t\t\tret= -1;\n\t\t\t\t\tgoto end;\n\t\t\t\t\t}\n\t\t\t\tif (!BUF_MEM_grow(buf,SSL3_RT_MAX_PLAIN_LENGTH))\n\t\t\t\t\t{\n\t\t\t\t\tret= -1;\n\t\t\t\t\tgoto end;\n\t\t\t\t\t}\n\t\t\t\ts->init_buf=buf;\n\t\t\t\tbuf=NULL;\n\t\t\t\t}\n\t\t\tif (!ssl3_setup_buffers(s)) { ret= -1; goto end; }\n\t\t\tssl3_init_finished_mac(s);\n\t\t\ts->state=SSL23_ST_CW_CLNT_HELLO_A;\n\t\t\ts->ctx->stats.sess_connect++;\n\t\t\ts->init_num=0;\n\t\t\tbreak;\n\t\tcase SSL23_ST_CW_CLNT_HELLO_A:\n\t\tcase SSL23_ST_CW_CLNT_HELLO_B:\n\t\t\ts->shutdown=0;\n\t\t\tret=ssl23_client_hello(s);\n\t\t\tif (ret <= 0) goto end;\n\t\t\ts->state=SSL23_ST_CR_SRVR_HELLO_A;\n\t\t\ts->init_num=0;\n\t\t\tbreak;\n\t\tcase SSL23_ST_CR_SRVR_HELLO_A:\n\t\tcase SSL23_ST_CR_SRVR_HELLO_B:\n\t\t\tret=ssl23_get_server_hello(s);\n\t\t\tif (ret >= 0) cb=NULL;\n\t\t\tgoto end;\n\t\tdefault:\n\t\t\tSSLerr(SSL_F_SSL23_CONNECT,SSL_R_UNKNOWN_STATE);\n\t\t\tret= -1;\n\t\t\tgoto end;\n\t\t\t}\n\t\tif (s->debug) { (void)BIO_flush(s->wbio); }\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_CONNECT_LOOP,1);\n\t\t\ts->state=new_state;\n\t\t\t}\n\t\t}\nend:\n\ts->in_handshake--;\n\tif (buf != NULL)\n\t\tBUF_MEM_free(buf);\n\tif (cb != NULL)\n\t\tcb(s,SSL_CB_CONNECT_EXIT,ret);\n\treturn(ret);\n\t}', 'static int ssl23_client_hello(SSL *s)\n\t{\n\tunsigned char *buf;\n\tunsigned char *p,*d;\n\tint i;\n\tunsigned long l;\n\tint version = 0, version_major, version_minor;\n\tint al = 0;\n#ifndef OPENSSL_NO_COMP\n\tint j;\n\tSSL_COMP *comp;\n#endif\n\tint ret;\n\tunsigned long mask, options = s->options;\n\tmask =\tSSL_OP_NO_TLSv1_1|SSL_OP_NO_TLSv1\n#if !defined(OPENSSL_NO_SSL3)\n\t\t|SSL_OP_NO_SSLv3\n#endif\n\t\t;\n#if !defined(OPENSSL_NO_TLS1_2_CLIENT)\n\tversion = TLS1_2_VERSION;\n\tif ((options & SSL_OP_NO_TLSv1_2) && (options & mask) != mask)\n\t\tversion = TLS1_1_VERSION;\n#else\n\tversion = TLS1_1_VERSION;\n#endif\n\tmask &= ~SSL_OP_NO_TLSv1_1;\n\tif ((options & SSL_OP_NO_TLSv1_1) && (options & mask) != mask)\n\t\tversion = TLS1_VERSION;\n\tmask &= ~SSL_OP_NO_TLSv1;\n#if !defined(OPENSSL_NO_SSL3)\n\tif ((options & SSL_OP_NO_TLSv1) && (options & mask) != mask)\n\t\tversion = SSL3_VERSION;\n\tmask &= ~SSL_OP_NO_SSLv3;\n#endif\n\tbuf=(unsigned char *)s->init_buf->data;\n\tif (s->state == SSL23_ST_CW_CLNT_HELLO_A)\n\t\t{\n#if 0\n\t\tif (!ssl_get_new_session(s,0))\n\t\t\t{\n\t\t\treturn(-1);\n\t\t\t}\n#endif\n\t\tp=s->s3->client_random;\n\t\tif (ssl_fill_hello_random(s, 0, p, SSL3_RANDOM_SIZE) <= 0)\n\t\t\treturn -1;\n\t\tif (version == TLS1_2_VERSION)\n\t\t\t{\n\t\t\tversion_major = TLS1_2_VERSION_MAJOR;\n\t\t\tversion_minor = TLS1_2_VERSION_MINOR;\n\t\t\t}\n\t\telse if (tls1_suiteb(s))\n\t\t\t{\n\t\t\tSSLerr(SSL_F_SSL23_CLIENT_HELLO,\n\t\t\t\t\tSSL_R_ONLY_TLS_1_2_ALLOWED_IN_SUITEB_MODE);\n\t\t\treturn -1;\n\t\t\t}\n\t\telse if (version == TLS1_1_VERSION)\n\t\t\t{\n\t\t\tversion_major = TLS1_1_VERSION_MAJOR;\n\t\t\tversion_minor = TLS1_1_VERSION_MINOR;\n\t\t\t}\n\t\telse if (version == TLS1_VERSION)\n\t\t\t{\n\t\t\tversion_major = TLS1_VERSION_MAJOR;\n\t\t\tversion_minor = TLS1_VERSION_MINOR;\n\t\t\t}\n#ifdef OPENSSL_FIPS\n\t\telse if(FIPS_mode())\n\t\t\t{\n\t\t\tSSLerr(SSL_F_SSL23_CLIENT_HELLO,\n\t\t\t\t\tSSL_R_ONLY_TLS_ALLOWED_IN_FIPS_MODE);\n\t\t\treturn -1;\n\t\t\t}\n#endif\n\t\telse if (version == SSL3_VERSION)\n\t\t\t{\n\t\t\tversion_major = SSL3_VERSION_MAJOR;\n\t\t\tversion_minor = SSL3_VERSION_MINOR;\n\t\t\t}\n\t\telse\n\t\t\t{\n\t\t\tSSLerr(SSL_F_SSL23_CLIENT_HELLO,SSL_R_NO_PROTOCOLS_AVAILABLE);\n\t\t\treturn(-1);\n\t\t\t}\n\t\ts->client_version = version;\n\t\td = p = &(buf[9]);\n\t\t*(p++) = version_major;\n\t\t*(p++) = version_minor;\n\t\tmemcpy(p, s->s3->client_random, SSL3_RANDOM_SIZE);\n\t\tp += SSL3_RANDOM_SIZE;\n\t\t*(p++) = 0;\n\t\ti=ssl_cipher_list_to_bytes(s,SSL_get_ciphers(s),&(p[2]),ssl3_put_cipher_by_char);\n\t\tif (i == 0)\n\t\t\t{\n\t\t\tSSLerr(SSL_F_SSL23_CLIENT_HELLO,SSL_R_NO_CIPHERS_AVAILABLE);\n\t\t\treturn -1;\n\t\t\t}\n#ifdef OPENSSL_MAX_TLS1_2_CIPHER_LENGTH\n\t\tif (TLS1_get_version(s) >= TLS1_2_VERSION\n\t\t\t&& i > OPENSSL_MAX_TLS1_2_CIPHER_LENGTH)\n\t\t\ti = OPENSSL_MAX_TLS1_2_CIPHER_LENGTH & ~1;\n#endif\n\t\ts2n(i,p);\n\t\tp+=i;\n#ifdef OPENSSL_NO_COMP\n\t\t*(p++)=1;\n#else\n\t\tif (!ssl_allow_compression(s) || !s->ctx->comp_methods)\n\t\t\tj=0;\n\t\telse\n\t\t\tj=sk_SSL_COMP_num(s->ctx->comp_methods);\n\t\t*(p++)=1+j;\n\t\tfor (i=0; i<j; i++)\n\t\t\t{\n\t\t\tcomp=sk_SSL_COMP_value(s->ctx->comp_methods,i);\n\t\t\t*(p++)=comp->id;\n\t\t\t}\n#endif\n\t\t*(p++)=0;\n#ifndef OPENSSL_NO_TLSEXT\n\t\tif (ssl_prepare_clienthello_tlsext(s) <= 0)\n\t\t\t{\n\t\t\tSSLerr(SSL_F_SSL23_CLIENT_HELLO,SSL_R_CLIENTHELLO_TLSEXT);\n\t\t\treturn -1;\n\t\t\t}\n\t\tif ((p = ssl_add_clienthello_tlsext(s, p, buf+SSL3_RT_MAX_PLAIN_LENGTH, &al)) == NULL)\n\t\t\t{\n\t\t\tssl3_send_alert(s,SSL3_AL_FATAL,al);\n\t\t\tSSLerr(SSL_F_SSL23_CLIENT_HELLO,ERR_R_INTERNAL_ERROR);\n\t\t\treturn -1;\n\t\t\t}\n#endif\n\t\tl = p-d;\n\t\td=&(buf[5]);\n\t\t*(d++)=SSL3_MT_CLIENT_HELLO;\n\t\tl2n3(l,d);\n\t\tl += 4;\n\t\tif (l > SSL3_RT_MAX_PLAIN_LENGTH)\n\t\t\t{\n\t\t\tSSLerr(SSL_F_SSL23_CLIENT_HELLO,ERR_R_INTERNAL_ERROR);\n\t\t\treturn -1;\n\t\t\t}\n\t\td=buf;\n\t\t*(d++) = SSL3_RT_HANDSHAKE;\n\t\t*(d++) = version_major;\n\t\tif (TLS1_get_client_version(s) > TLS1_VERSION)\n\t\t\t*(d++) = 1;\n\t\telse\n\t\t\t*(d++) = version_minor;\n\t\ts2n((int)l,d);\n\t\ts->init_num=p-buf;\n\t\ts->init_off=0;\n\t\tssl3_finish_mac(s,&(buf[5]), s->init_num - 5);\n\t\ts->state=SSL23_ST_CW_CLNT_HELLO_B;\n\t\ts->init_off=0;\n\t\t}\n\tret = ssl23_write_bytes(s);\n\tif ((ret >= 2) && s->msg_callback)\n\t\t{\n\t\ts->msg_callback(1, version, SSL3_RT_HEADER, s->init_buf->data, 5, s, s->msg_callback_arg);\n\t\ts->msg_callback(1, version, SSL3_RT_HANDSHAKE, s->init_buf->data+5, ret-5, s, s->msg_callback_arg);\n\t\t}\n\treturn ret;\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 == SSL3_AL_FATAL) && (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}']