ssl/ssltest.c:726: error: INTEGER_OVERFLOW_L1
  (0 - 1):unsigned64 by call to `SSL_free`.
Showing all 22 steps of the trace


ssl/ssltest.c:700:3: Call
698.   	if (!verbose)
699.   		{
700.   		print_details(c_ssl, "");
         ^
701.   		}
702.   	if ((number > 1) || (bytes > 1L))

ssl/ssltest.c:241:20: Call
  239.   	if (cert != NULL)
  240.   		{
  241.   		EVP_PKEY *pkey = X509_get_pubkey(cert);
                            ^
  242.   		if (pkey != NULL)
  243.   			{

crypto/x509/x509_cmp.c:257:9: Call
    255.   	if ((x == NULL) || (x->cert_info == NULL))
    256.   		return(NULL);
    257.   	return(X509_PUBKEY_get(x->cert_info->key));
                   ^
    258.   	}
    259.   

crypto/asn1/x_pubkey.c:251:25: Call
      249.   		if (a->parameter && (a->parameter->type == V_ASN1_SEQUENCE))
      250.   			{
      251.   			if ((ret->pkey.dsa = DSA_new()) == NULL)
                                     ^
      252.   				{
      253.   				X509err(X509_F_X509_PUBKEY_GET, ERR_R_MALLOC_FAILURE);

crypto/dsa/dsa_lib.c:86:9: Call
        84.   DSA *DSA_new(void)
        85.   	{
        86.   	return DSA_new_method(NULL);
                      ^
        87.   	}
        88.   

crypto/dsa/dsa_lib.c:128:17: Call
          126.   		}
          127.   	else
          128.   		ret->engine = ENGINE_get_default_DSA();
                                 ^
          129.   	if(ret->engine)
          130.   		{

crypto/engine/tb_dsa.c:106:9: Call
            104.   ENGINE *ENGINE_get_default_DSA(void)
            105.   	{
            106.   	return engine_table_select(&dsa_table, dummy_nid);
                           ^
            107.   	}
            108.   

crypto/engine/eng_table.c:268:6: Call
              266.   	/* Check again inside the lock otherwise we could race against cleanup
              267.   	 * operations. But don't worry about a fprintf(stderr). */
              268.   	if(!int_table_check(table, 0))
                          ^
              269.   		goto end;
              270.   	tmplate.nid = nid;

crypto/engine/eng_table.c:128:11: Call
                126.   	if(!create)
                127.   		return 0;
                128.   	if((lh = lh_new(LHASH_HASH_FN(engine_pile_hash),
                                 ^
                129.   			LHASH_COMP_FN(engine_pile_cmp))) == NULL)
                130.   		return 0;

crypto/lhash/lhash.c:133:2: Assignment
                  131.   	ret->up_load=UP_LOAD;
                  132.   	ret->down_load=DOWN_LOAD;
                  133.   	ret->num_items=0;
                          ^
                  134.   
                  135.   	ret->num_expands=0;

ssl/ssltest.c:726:2: Call
724.   		}
725.   
726.   	SSL_free(s_ssl);
        ^
727.   	SSL_free(c_ssl);
728.   

ssl/ssl_lib.c:408:1: Parameter `s->ctx->sessions->num_items`
  406.   	}
  407.   
  408. > void SSL_free(SSL *s)
  409.   	{
  410.   	int i;

ssl/ssl_lib.c:454:3: Call
  452.   	if (s->session != NULL)
  453.   		{
  454.   		ssl_clear_bad_session(s);
           ^
  455.   		SSL_SESSION_free(s->session);
  456.   		}

ssl/ssl_sess.c:678:1: Parameter `s->ctx->sessions->num_items`
    676.   	}
    677.   
    678. > int ssl_clear_bad_session(SSL *s)
    679.   	{
    680.   	if (	(s->session != NULL) &&

ssl/ssl_sess.c:684:3: Call
    682.   		!(SSL_in_init(s) || SSL_in_before(s)))
    683.   		{
    684.   		SSL_CTX_remove_session(s->ctx,s->session);
             ^
    685.   		return(1);
    686.   		}

ssl/ssl_sess.c:464:1: Parameter `ctx->sessions->num_items`
      462.   	}
      463.   
      464. > int SSL_CTX_remove_session(SSL_CTX *ctx, SSL_SESSION *c)
      465.   {
      466.   	return remove_session_lock(ctx, c, 1);

ssl/ssl_sess.c:466:9: Call
      464.   int SSL_CTX_remove_session(SSL_CTX *ctx, SSL_SESSION *c)
      465.   {
      466.   	return remove_session_lock(ctx, c, 1);
                     ^
      467.   }
      468.   

ssl/ssl_sess.c:469:1: Parameter `ctx->sessions->num_items`
        467.   }
        468.   
        469. > static int remove_session_lock(SSL_CTX *ctx, SSL_SESSION *c, int lck)
        470.   	{
        471.   	SSL_SESSION *r;

ssl/ssl_sess.c:480:21: Call
        478.   			{
        479.   			ret=1;
        480.   			r=(SSL_SESSION *)lh_delete(ctx->sessions,c);
                                   ^
        481.   			SSL_SESSION_list_remove(ctx,c);
        482.   			}

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 - 1):unsigned64 by call to `SSL_free` 
          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;
	const 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((void *)ret);
	}
['int main(int argc, char *argv[])\n\t{\n\tchar *CApath=NULL,*CAfile=NULL;\n\tint badop=0;\n\tint bio_pair=0;\n\tint force=0;\n\tint tls1=0,ssl2=0,ssl3=0,ret=1;\n\tint client_auth=0;\n\tint server_auth=0,i;\n\tint app_verify=0;\n\tchar *server_cert=TEST_SERVER_CERT;\n\tchar *server_key=NULL;\n\tchar *client_cert=TEST_CLIENT_CERT;\n\tchar *client_key=NULL;\n\tSSL_CTX *s_ctx=NULL;\n\tSSL_CTX *c_ctx=NULL;\n\tSSL_METHOD *meth=NULL;\n\tSSL *c_ssl,*s_ssl;\n\tint number=1,reuse=0;\n\tlong bytes=1L;\n#ifndef OPENSSL_NO_DH\n\tDH *dh;\n\tint dhe1024 = 0, dhe1024dsa = 0;\n#endif\n\tint no_dhe = 0;\n\tint print_time = 0;\n\tclock_t s_time = 0, c_time = 0;\n\tint comp = 0;\n\tCOMP_METHOD *cm = NULL;\n\tverbose = 0;\n\tdebug = 0;\n\tcipher = 0;\n\tCRYPTO_set_locking_callback(lock_dbg_cb);\n\tif (!((getenv("OPENSSL_DEBUG_MEMORY") != NULL) && (0 == strcmp(getenv("OPENSSL_DEBUG_MEMORY"), "off"))))\n\t\t{\n\t\tCRYPTO_malloc_debug_init();\n\t\tCRYPTO_set_mem_debug_options(V_CRYPTO_MDEBUG_ALL);\n\t\t}\n\telse\n\t\t{\n\t\tCRYPTO_set_mem_debug_functions(0, 0, 0, 0, 0);\n\t\t}\n\tCRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);\n\tRAND_seed(rnd_seed, sizeof rnd_seed);\n\tbio_err=BIO_new_fp(stderr,BIO_NOCLOSE);\n\tbio_stdout=BIO_new_fp(stdout,BIO_NOCLOSE);\n\targc--;\n\targv++;\n\twhile (argc >= 1)\n\t\t{\n\t\tif\t(strcmp(*argv,"-server_auth") == 0)\n\t\t\tserver_auth=1;\n\t\telse if\t(strcmp(*argv,"-client_auth") == 0)\n\t\t\tclient_auth=1;\n\t\telse if\t(strcmp(*argv,"-v") == 0)\n\t\t\tverbose=1;\n\t\telse if\t(strcmp(*argv,"-d") == 0)\n\t\t\tdebug=1;\n\t\telse if\t(strcmp(*argv,"-reuse") == 0)\n\t\t\treuse=1;\n#ifndef OPENSSL_NO_DH\n\t\telse if\t(strcmp(*argv,"-dhe1024") == 0)\n\t\t\tdhe1024=1;\n\t\telse if\t(strcmp(*argv,"-dhe1024dsa") == 0)\n\t\t\tdhe1024dsa=1;\n#endif\n\t\telse if\t(strcmp(*argv,"-no_dhe") == 0)\n\t\t\tno_dhe=1;\n\t\telse if\t(strcmp(*argv,"-ssl2") == 0)\n\t\t\tssl2=1;\n\t\telse if\t(strcmp(*argv,"-tls1") == 0)\n\t\t\ttls1=1;\n\t\telse if\t(strcmp(*argv,"-ssl3") == 0)\n\t\t\tssl3=1;\n\t\telse if\t(strncmp(*argv,"-num",4) == 0)\n\t\t\t{\n\t\t\tif (--argc < 1) goto bad;\n\t\t\tnumber= atoi(*(++argv));\n\t\t\tif (number == 0) number=1;\n\t\t\t}\n\t\telse if\t(strcmp(*argv,"-bytes") == 0)\n\t\t\t{\n\t\t\tif (--argc < 1) goto bad;\n\t\t\tbytes= atol(*(++argv));\n\t\t\tif (bytes == 0L) bytes=1L;\n\t\t\ti=strlen(argv[0]);\n\t\t\tif (argv[0][i-1] == \'k\') bytes*=1024L;\n\t\t\tif (argv[0][i-1] == \'m\') bytes*=1024L*1024L;\n\t\t\t}\n\t\telse if\t(strcmp(*argv,"-cert") == 0)\n\t\t\t{\n\t\t\tif (--argc < 1) goto bad;\n\t\t\tserver_cert= *(++argv);\n\t\t\t}\n\t\telse if\t(strcmp(*argv,"-s_cert") == 0)\n\t\t\t{\n\t\t\tif (--argc < 1) goto bad;\n\t\t\tserver_cert= *(++argv);\n\t\t\t}\n\t\telse if\t(strcmp(*argv,"-key") == 0)\n\t\t\t{\n\t\t\tif (--argc < 1) goto bad;\n\t\t\tserver_key= *(++argv);\n\t\t\t}\n\t\telse if\t(strcmp(*argv,"-s_key") == 0)\n\t\t\t{\n\t\t\tif (--argc < 1) goto bad;\n\t\t\tserver_key= *(++argv);\n\t\t\t}\n\t\telse if\t(strcmp(*argv,"-c_cert") == 0)\n\t\t\t{\n\t\t\tif (--argc < 1) goto bad;\n\t\t\tclient_cert= *(++argv);\n\t\t\t}\n\t\telse if\t(strcmp(*argv,"-c_key") == 0)\n\t\t\t{\n\t\t\tif (--argc < 1) goto bad;\n\t\t\tclient_key= *(++argv);\n\t\t\t}\n\t\telse if\t(strcmp(*argv,"-cipher") == 0)\n\t\t\t{\n\t\t\tif (--argc < 1) goto bad;\n\t\t\tcipher= *(++argv);\n\t\t\t}\n\t\telse if\t(strcmp(*argv,"-CApath") == 0)\n\t\t\t{\n\t\t\tif (--argc < 1) goto bad;\n\t\t\tCApath= *(++argv);\n\t\t\t}\n\t\telse if\t(strcmp(*argv,"-CAfile") == 0)\n\t\t\t{\n\t\t\tif (--argc < 1) goto bad;\n\t\t\tCAfile= *(++argv);\n\t\t\t}\n\t\telse if\t(strcmp(*argv,"-bio_pair") == 0)\n\t\t\t{\n\t\t\tbio_pair = 1;\n\t\t\t}\n\t\telse if\t(strcmp(*argv,"-f") == 0)\n\t\t\t{\n\t\t\tforce = 1;\n\t\t\t}\n\t\telse if\t(strcmp(*argv,"-time") == 0)\n\t\t\t{\n\t\t\tprint_time = 1;\n\t\t\t}\n\t\telse if\t(strcmp(*argv,"-zlib") == 0)\n\t\t\t{\n\t\t\tcomp = COMP_ZLIB;\n\t\t\t}\n\t\telse if\t(strcmp(*argv,"-rle") == 0)\n\t\t\t{\n\t\t\tcomp = COMP_RLE;\n\t\t\t}\n\t\telse if\t(strcmp(*argv,"-app_verify") == 0)\n\t\t\t{\n\t\t\tapp_verify = 1;\n\t\t\t}\n\t\telse\n\t\t\t{\n\t\t\tfprintf(stderr,"unknown option %s\\n",*argv);\n\t\t\tbadop=1;\n\t\t\tbreak;\n\t\t\t}\n\t\targc--;\n\t\targv++;\n\t\t}\n\tif (badop)\n\t\t{\nbad:\n\t\tsv_usage();\n\t\tgoto end;\n\t\t}\n\tif (!ssl2 && !ssl3 && !tls1 && number > 1 && !reuse && !force)\n\t\t{\n\t\tfprintf(stderr, "This case cannot work.  Use -f to perform "\n\t\t\t"the test anyway (and\\n-d to see what happens), "\n\t\t\t"or add one of -ssl2, -ssl3, -tls1, -reuse\\n"\n\t\t\t"to avoid protocol mismatch.\\n");\n\t\texit(1);\n\t\t}\n\tif (print_time)\n\t\t{\n\t\tif (!bio_pair)\n\t\t\t{\n\t\t\tfprintf(stderr, "Using BIO pair (-bio_pair)\\n");\n\t\t\tbio_pair = 1;\n\t\t\t}\n\t\tif (number < 50 && !force)\n\t\t\tfprintf(stderr, "Warning: For accurate timings, use more connections (e.g. -num 1000)\\n");\n\t\t}\n\tSSL_library_init();\n\tSSL_load_error_strings();\n\tif (comp == COMP_ZLIB) cm = COMP_zlib();\n\tif (comp == COMP_RLE) cm = COMP_rle();\n\tif (cm != NULL)\n\t\t{\n\t\tif (cm->type != NID_undef)\n\t\t\tSSL_COMP_add_compression_method(comp, cm);\n\t\telse\n\t\t\t{\n\t\t\tfprintf(stderr,\n\t\t\t\t"Warning: %s compression not supported\\n",\n\t\t\t\t(comp == COMP_RLE ? "rle" :\n\t\t\t\t\t(comp == COMP_ZLIB ? "zlib" :\n\t\t\t\t\t\t"unknown")));\n\t\t\tERR_print_errors_fp(stderr);\n\t\t\t}\n\t\t}\n#if !defined(OPENSSL_NO_SSL2) && !defined(OPENSSL_NO_SSL3)\n\tif (ssl2)\n\t\tmeth=SSLv2_method();\n\telse\n\tif (tls1)\n\t\tmeth=TLSv1_method();\n\telse\n\tif (ssl3)\n\t\tmeth=SSLv3_method();\n\telse\n\t\tmeth=SSLv23_method();\n#else\n#ifdef OPENSSL_NO_SSL2\n\tmeth=SSLv3_method();\n#else\n\tmeth=SSLv2_method();\n#endif\n#endif\n\tc_ctx=SSL_CTX_new(meth);\n\ts_ctx=SSL_CTX_new(meth);\n\tif ((c_ctx == NULL) || (s_ctx == NULL))\n\t\t{\n\t\tERR_print_errors(bio_err);\n\t\tgoto end;\n\t\t}\n\tif (cipher != NULL)\n\t\t{\n\t\tSSL_CTX_set_cipher_list(c_ctx,cipher);\n\t\tSSL_CTX_set_cipher_list(s_ctx,cipher);\n\t\t}\n#ifndef OPENSSL_NO_DH\n\tif (!no_dhe)\n\t\t{\n\t\tif (dhe1024dsa)\n\t\t\t{\n\t\t\tSSL_CTX_set_options(s_ctx, SSL_OP_SINGLE_DH_USE);\n\t\t\tdh=get_dh1024dsa();\n\t\t\t}\n\t\telse if (dhe1024)\n\t\t\tdh=get_dh1024();\n\t\telse\n\t\t\tdh=get_dh512();\n\t\tSSL_CTX_set_tmp_dh(s_ctx,dh);\n\t\tDH_free(dh);\n\t\t}\n#else\n\t(void)no_dhe;\n#endif\n#ifndef OPENSSL_NO_RSA\n\tSSL_CTX_set_tmp_rsa_callback(s_ctx,tmp_rsa_cb);\n#endif\n\tif (!SSL_CTX_use_certificate_file(s_ctx,server_cert,SSL_FILETYPE_PEM))\n\t\t{\n\t\tERR_print_errors(bio_err);\n\t\t}\n\telse if (!SSL_CTX_use_PrivateKey_file(s_ctx,\n\t\t(server_key?server_key:server_cert), SSL_FILETYPE_PEM))\n\t\t{\n\t\tERR_print_errors(bio_err);\n\t\tgoto end;\n\t\t}\n\tif (client_auth)\n\t\t{\n\t\tSSL_CTX_use_certificate_file(c_ctx,client_cert,\n\t\t\tSSL_FILETYPE_PEM);\n\t\tSSL_CTX_use_PrivateKey_file(c_ctx,\n\t\t\t(client_key?client_key:client_cert),\n\t\t\tSSL_FILETYPE_PEM);\n\t\t}\n\tif (\t(!SSL_CTX_load_verify_locations(s_ctx,CAfile,CApath)) ||\n\t\t(!SSL_CTX_set_default_verify_paths(s_ctx)) ||\n\t\t(!SSL_CTX_load_verify_locations(c_ctx,CAfile,CApath)) ||\n\t\t(!SSL_CTX_set_default_verify_paths(c_ctx)))\n\t\t{\n\t\tERR_print_errors(bio_err);\n\t\t}\n\tif (client_auth)\n\t\t{\n\t\tBIO_printf(bio_err,"client authentication\\n");\n\t\tSSL_CTX_set_verify(s_ctx,\n\t\t\tSSL_VERIFY_PEER|SSL_VERIFY_FAIL_IF_NO_PEER_CERT,\n\t\t\tverify_callback);\n\t\tif (app_verify)\n\t\t\t{\n\t\t\tSSL_CTX_set_cert_verify_callback(s_ctx, app_verify_callback, app_verify_arg);\n\t\t\t}\n\t\t}\n\tif (server_auth)\n\t\t{\n\t\tBIO_printf(bio_err,"server authentication\\n");\n\t\tSSL_CTX_set_verify(c_ctx,SSL_VERIFY_PEER,\n\t\t\tverify_callback);\n\t\tif (app_verify)\n\t\t\t{\n\t\t\tSSL_CTX_set_cert_verify_callback(s_ctx, app_verify_callback, app_verify_arg);\n\t\t\t}\n\t\t}\n\t{\n\t\tint session_id_context = 0;\n\t\tSSL_CTX_set_session_id_context(s_ctx, (void *)&session_id_context, sizeof session_id_context);\n\t}\n\tc_ssl=SSL_new(c_ctx);\n\ts_ssl=SSL_new(s_ctx);\n#ifndef OPENSSL_NO_KRB5\n\tif (c_ssl  &&  c_ssl->kssl_ctx)\n                {\n                char\tlocalhost[257];\n\t\tif (gethostname(localhost, 256) == 0)\n                        {\n\t\t\tkssl_ctx_setstring(c_ssl->kssl_ctx, KSSL_SERVER,\n                                localhost);\n\t\t\t}\n\t\t}\n#endif\n\tfor (i=0; i<number; i++)\n\t\t{\n\t\tif (!reuse) SSL_set_session(c_ssl,NULL);\n\t\tif (bio_pair)\n\t\t\tret=doit_biopair(s_ssl,c_ssl,bytes,&s_time,&c_time);\n\t\telse\n\t\t\tret=doit(s_ssl,c_ssl,bytes);\n\t\t}\n\tif (!verbose)\n\t\t{\n\t\tprint_details(c_ssl, "");\n\t\t}\n\tif ((number > 1) || (bytes > 1L))\n\t\tBIO_printf(bio_stdout, "%d handshakes of %ld bytes done\\n",number,bytes);\n\tif (print_time)\n\t\t{\n#ifdef CLOCKS_PER_SEC\n\t\tBIO_printf(bio_stdout, "Approximate total server time: %6.2f s\\n"\n\t\t\t"Approximate total client time: %6.2f s\\n",\n\t\t\t(double)s_time/CLOCKS_PER_SEC,\n\t\t\t(double)c_time/CLOCKS_PER_SEC);\n#else\n\t\tBIO_printf(bio_stdout,\n\t\t\t"Approximate total server time: %6.2f units\\n"\n\t\t\t"Approximate total client time: %6.2f units\\n",\n\t\t\t(double)s_time,\n\t\t\t(double)c_time);\n#endif\n\t\t}\n\tSSL_free(s_ssl);\n\tSSL_free(c_ssl);\nend:\n\tif (s_ctx != NULL) SSL_CTX_free(s_ctx);\n\tif (c_ctx != NULL) SSL_CTX_free(c_ctx);\n\tif (bio_stdout != NULL) BIO_free(bio_stdout);\n#ifndef OPENSSL_NO_RSA\n\tfree_tmp_rsa();\n#endif\n\tENGINE_cleanup();\n\tCRYPTO_cleanup_all_ex_data();\n\tERR_free_strings();\n\tERR_remove_state(0);\n\tEVP_cleanup();\n\tCRYPTO_mem_leaks(bio_err);\n\tif (bio_err != NULL) BIO_free(bio_err);\n\tEXIT(ret);\n\t}', 'static void print_details(SSL *c_ssl, const char *prefix)\n\t{\n\tSSL_CIPHER *ciph;\n\tX509 *cert;\n\tciph=SSL_get_current_cipher(c_ssl);\n\tBIO_printf(bio_stdout,"%s%s, cipher %s %s",\n\t\tprefix,\n\t\tSSL_get_version(c_ssl),\n\t\tSSL_CIPHER_get_version(ciph),\n\t\tSSL_CIPHER_get_name(ciph));\n\tcert=SSL_get_peer_certificate(c_ssl);\n\tif (cert != NULL)\n\t\t{\n\t\tEVP_PKEY *pkey = X509_get_pubkey(cert);\n\t\tif (pkey != NULL)\n\t\t\t{\n\t\t\tif (0)\n\t\t\t\t;\n#ifndef OPENSSL_NO_RSA\n\t\t\telse if (pkey->type == EVP_PKEY_RSA && pkey->pkey.rsa != NULL\n\t\t\t\t&& pkey->pkey.rsa->n != NULL)\n\t\t\t\t{\n\t\t\t\tBIO_printf(bio_stdout, ", %d bit RSA",\n\t\t\t\t\tBN_num_bits(pkey->pkey.rsa->n));\n\t\t\t\t}\n#endif\n#ifndef OPENSSL_NO_DSA\n\t\t\telse if (pkey->type == EVP_PKEY_DSA && pkey->pkey.dsa != NULL\n\t\t\t\t&& pkey->pkey.dsa->p != NULL)\n\t\t\t\t{\n\t\t\t\tBIO_printf(bio_stdout, ", %d bit DSA",\n\t\t\t\t\tBN_num_bits(pkey->pkey.dsa->p));\n\t\t\t\t}\n#endif\n\t\t\tEVP_PKEY_free(pkey);\n\t\t\t}\n\t\tX509_free(cert);\n\t\t}\n\tBIO_printf(bio_stdout,"\\n");\n\t}', 'EVP_PKEY *X509_get_pubkey(X509 *x)\n\t{\n\tif ((x == NULL) || (x->cert_info == NULL))\n\t\treturn(NULL);\n\treturn(X509_PUBKEY_get(x->cert_info->key));\n\t}', 'EVP_PKEY *X509_PUBKEY_get(X509_PUBKEY *key)\n\t{\n\tEVP_PKEY *ret=NULL;\n\tlong j;\n\tint type;\n\tunsigned char *p;\n#if !defined(OPENSSL_NO_DSA) || !defined(OPENSSL_NO_ECDSA)\n\tconst unsigned char *cp;\n\tX509_ALGOR *a;\n#endif\n\tif (key == NULL) goto err;\n\tif (key->pkey != NULL)\n\t\t{\n\t\tCRYPTO_add(&key->pkey->references, 1, CRYPTO_LOCK_EVP_PKEY);\n\t\treturn(key->pkey);\n\t\t}\n\tif (key->public_key == NULL) goto err;\n\ttype=OBJ_obj2nid(key->algor->algorithm);\n\tif ((ret = EVP_PKEY_new()) == NULL)\n\t\t{\n\t\tX509err(X509_F_X509_PUBKEY_GET, ERR_R_MALLOC_FAILURE);\n\t\tgoto err;\n\t\t}\n\tret->type = EVP_PKEY_type(type);\n#if !defined(OPENSSL_NO_DSA) || !defined(OPENSSL_NO_ECDSA)\n\ta=key->algor;\n#endif\n\tif (0)\n\t\t;\n#ifndef OPENSSL_NO_DSA\n\telse if (ret->type == EVP_PKEY_DSA)\n\t\t{\n\t\tif (a->parameter && (a->parameter->type == V_ASN1_SEQUENCE))\n\t\t\t{\n\t\t\tif ((ret->pkey.dsa = DSA_new()) == NULL)\n\t\t\t\t{\n\t\t\t\tX509err(X509_F_X509_PUBKEY_GET, ERR_R_MALLOC_FAILURE);\n\t\t\t\tgoto err;\n\t\t\t\t}\n\t\t\tret->pkey.dsa->write_params=0;\n\t\t\tcp=p=a->parameter->value.sequence->data;\n\t\t\tj=a->parameter->value.sequence->length;\n\t\t\tif (!d2i_DSAparams(&ret->pkey.dsa, &cp, (long)j))\n\t\t\t\tgoto err;\n\t\t\t}\n\t\tret->save_parameters=1;\n\t\t}\n#endif\n#ifndef OPENSSL_NO_ECDSA\n\telse if (ret->type == EVP_PKEY_ECDSA)\n\t\t{\n\t\tif (a->parameter && (a->parameter->type == V_ASN1_SEQUENCE))\n\t\t\t{\n\t\t\tif ((ret->pkey.ecdsa= ECDSA_new()) == NULL)\n\t\t\t\t{\n\t\t\t\tX509err(X509_F_X509_PUBKEY_GET, ERR_R_MALLOC_FAILURE);\n\t\t\t\tgoto err;\n\t\t\t\t}\n\t\t\tret->pkey.ecdsa->write_params = 0;\n\t\t\tcp = p = a->parameter->value.sequence->data;\n\t\t\tj = a->parameter->value.sequence->length;\n\t\t\tif (!d2i_ECDSAParameters(&ret->pkey.ecdsa, &cp, (long)j))\n\t\t\t\t{\n\t\t\t\tX509err(X509_F_X509_PUBKEY_GET, ERR_R_ECDSA_LIB);\n\t\t\t\tgoto err;\n\t\t\t\t}\n\t\t\t}\n\t\tret->save_parameters = 1;\n\t\t}\n#endif\n\tp=key->public_key->data;\n        j=key->public_key->length;\n        if ((ret = d2i_PublicKey(type, &ret, &p, (long)j)) == NULL)\n\t\t{\n\t\tX509err(X509_F_X509_PUBKEY_GET, X509_R_ERR_ASN1_LIB);\n\t\tgoto err;\n\t\t}\n\tkey->pkey = ret;\n\tCRYPTO_add(&ret->references, 1, CRYPTO_LOCK_EVP_PKEY);\n\treturn(ret);\nerr:\n\tif (ret != NULL)\n\t\tEVP_PKEY_free(ret);\n\treturn(NULL);\n\t}', 'DSA *DSA_new(void)\n\t{\n\treturn DSA_new_method(NULL);\n\t}', 'DSA *DSA_new_method(ENGINE *engine)\n\t{\n\tDSA *ret;\n\tret=(DSA *)OPENSSL_malloc(sizeof(DSA));\n\tif (ret == NULL)\n\t\t{\n\t\tDSAerr(DSA_F_DSA_NEW_METHOD,ERR_R_MALLOC_FAILURE);\n\t\treturn(NULL);\n\t\t}\n\tret->meth = DSA_get_default_method();\n\tif (engine)\n\t\t{\n\t\tif (!ENGINE_init(engine))\n\t\t\t{\n\t\t\tDSAerr(DSA_F_DSA_NEW_METHOD, ERR_R_ENGINE_LIB);\n\t\t\tOPENSSL_free(ret);\n\t\t\treturn NULL;\n\t\t\t}\n\t\tret->engine = engine;\n\t\t}\n\telse\n\t\tret->engine = ENGINE_get_default_DSA();\n\tif(ret->engine)\n\t\t{\n\t\tret->meth = ENGINE_get_DSA(ret->engine);\n\t\tif(!ret->meth)\n\t\t\t{\n\t\t\tDSAerr(DSA_F_DSA_NEW_METHOD,\n\t\t\t\tERR_R_ENGINE_LIB);\n\t\t\tENGINE_finish(ret->engine);\n\t\t\tOPENSSL_free(ret);\n\t\t\treturn NULL;\n\t\t\t}\n\t\t}\n\tret->pad=0;\n\tret->version=0;\n\tret->write_params=1;\n\tret->p=NULL;\n\tret->q=NULL;\n\tret->g=NULL;\n\tret->pub_key=NULL;\n\tret->priv_key=NULL;\n\tret->kinv=NULL;\n\tret->r=NULL;\n\tret->method_mont_p=NULL;\n\tret->references=1;\n\tret->flags=ret->meth->flags;\n\tCRYPTO_new_ex_data(CRYPTO_EX_INDEX_DSA, ret, &ret->ex_data);\n\tif ((ret->meth->init != NULL) && !ret->meth->init(ret))\n\t\t{\n\t\tif (ret->engine)\n\t\t\tENGINE_finish(ret->engine);\n\t\tCRYPTO_free_ex_data(CRYPTO_EX_INDEX_DSA, ret, &ret->ex_data);\n\t\tOPENSSL_free(ret);\n\t\tret=NULL;\n\t\t}\n\treturn(ret);\n\t}', 'ENGINE *ENGINE_get_default_DSA(void)\n\t{\n\treturn engine_table_select(&dsa_table, dummy_nid);\n\t}', 'ENGINE *engine_table_select(ENGINE_TABLE **table, int nid)\n#else\nENGINE *engine_table_select_tmp(ENGINE_TABLE **table, int nid, const char *f, int l)\n#endif\n\t{\n\tENGINE *ret = NULL;\n\tENGINE_PILE tmplate, *fnd=NULL;\n\tint initres, loop = 0;\n\tif(!(*table))\n\t\t{\n#ifdef ENGINE_TABLE_DEBUG\n\t\tfprintf(stderr, "engine_table_dbg: %s:%d, nid=%d, no "\n\t\t\t"registered for anything!\\n", f, l, nid);\n#endif\n\t\treturn NULL;\n\t\t}\n\tCRYPTO_w_lock(CRYPTO_LOCK_ENGINE);\n\tif(!int_table_check(table, 0))\n\t\tgoto end;\n\ttmplate.nid = nid;\n\tfnd = lh_retrieve(&(*table)->piles, &tmplate);\n\tif(!fnd)\n\t\tgoto end;\n\tif(fnd->funct && engine_unlocked_init(fnd->funct))\n\t\t{\n#ifdef ENGINE_TABLE_DEBUG\n\t\tfprintf(stderr, "engine_table_dbg: %s:%d, nid=%d, using "\n\t\t\t"ENGINE \'%s\' cached\\n", f, l, nid, fnd->funct->id);\n#endif\n\t\tret = fnd->funct;\n\t\tgoto end;\n\t\t}\n\tif(fnd->uptodate)\n\t\t{\n\t\tret = fnd->funct;\n\t\tgoto end;\n\t\t}\ntrynext:\n\tret = sk_ENGINE_value(fnd->sk, loop++);\n\tif(!ret)\n\t\t{\n#ifdef ENGINE_TABLE_DEBUG\n\t\tfprintf(stderr, "engine_table_dbg: %s:%d, nid=%d, no "\n\t\t\t\t"registered implementations would initialise\\n",\n\t\t\t\tf, l, nid);\n#endif\n\t\tgoto end;\n\t\t}\n#if 0\n\tret->struct_ref++; engine_ref_debug(ret, 0, 1)\n#endif\n\tif((ret->funct_ref > 0) || !(table_flags & ENGINE_TABLE_FLAG_NOINIT))\n\t\tinitres = engine_unlocked_init(ret);\n\telse\n\t\tinitres = 0;\n#if 0\n\tret->struct_ref--; engine_ref_debug(ret, 0, -1);\n#endif\n\tif(initres)\n\t\t{\n\t\tif((fnd->funct != ret) && engine_unlocked_init(ret))\n\t\t\t{\n\t\t\tif(fnd->funct)\n\t\t\t\tengine_unlocked_finish(fnd->funct, 0);\n\t\t\tfnd->funct = ret;\n#ifdef ENGINE_TABLE_DEBUG\n\t\t\tfprintf(stderr, "engine_table_dbg: %s:%d, nid=%d, "\n\t\t\t\t"setting default to \'%s\'\\n", f, l, nid, ret->id);\n#endif\n\t\t\t}\n#ifdef ENGINE_TABLE_DEBUG\n\t\tfprintf(stderr, "engine_table_dbg: %s:%d, nid=%d, using "\n\t\t\t\t"newly initialised \'%s\'\\n", f, l, nid, ret->id);\n#endif\n\t\tgoto end;\n\t\t}\n\tgoto trynext;\nend:\n\tif(fnd)\n\t\tfnd->uptodate = 1;\n#ifdef ENGINE_TABLE_DEBUG\n\tif(ret)\n\t\tfprintf(stderr, "engine_table_dbg: %s:%d, nid=%d, caching "\n\t\t\t\t"ENGINE \'%s\'\\n", f, l, nid, ret->id);\n\telse\n\t\tfprintf(stderr, "engine_table_dbg: %s:%d, nid=%d, caching "\n\t\t\t\t"\'no matching ENGINE\'\\n", f, l, nid);\n#endif\n\tCRYPTO_w_unlock(CRYPTO_LOCK_ENGINE);\n\tERR_clear_error();\n\treturn ret;\n\t}', 'static int int_table_check(ENGINE_TABLE **t, int create)\n\t{\n\tLHASH *lh;\n\tif(*t)\n\t\treturn 1;\n\tif(!create)\n\t\treturn 0;\n\tif((lh = lh_new(LHASH_HASH_FN(engine_pile_hash),\n\t\t\tLHASH_COMP_FN(engine_pile_cmp))) == NULL)\n\t\treturn 0;\n\t*t = (ENGINE_TABLE *)lh;\n\treturn 1;\n\t}', 'LHASH *lh_new(LHASH_HASH_FN_TYPE h, LHASH_COMP_FN_TYPE c)\n\t{\n\tLHASH *ret;\n\tint i;\n\tif ((ret=(LHASH *)OPENSSL_malloc(sizeof(LHASH))) == NULL)\n\t\tgoto err0;\n\tif ((ret->b=(LHASH_NODE **)OPENSSL_malloc(sizeof(LHASH_NODE *)*MIN_NODES)) == NULL)\n\t\tgoto err1;\n\tfor (i=0; i<MIN_NODES; i++)\n\t\tret->b[i]=NULL;\n\tret->comp=((c == NULL)?(LHASH_COMP_FN_TYPE)strcmp:c);\n\tret->hash=((h == NULL)?(LHASH_HASH_FN_TYPE)lh_strhash:h);\n\tret->num_nodes=MIN_NODES/2;\n\tret->num_alloc_nodes=MIN_NODES;\n\tret->p=0;\n\tret->pmax=MIN_NODES/2;\n\tret->up_load=UP_LOAD;\n\tret->down_load=DOWN_LOAD;\n\tret->num_items=0;\n\tret->num_expands=0;\n\tret->num_expand_reallocs=0;\n\tret->num_contracts=0;\n\tret->num_contract_reallocs=0;\n\tret->num_hash_calls=0;\n\tret->num_comp_calls=0;\n\tret->num_insert=0;\n\tret->num_replace=0;\n\tret->num_delete=0;\n\tret->num_no_delete=0;\n\tret->num_retrieve=0;\n\tret->num_retrieve_miss=0;\n\tret->num_hash_comps=0;\n\tret->error=0;\n\treturn(ret);\nerr1:\n\tOPENSSL_free(ret);\nerr0:\n\treturn(NULL);\n\t}', 'void SSL_free(SSL *s)\n\t{\n\tint i;\n\tif(s == NULL)\n\t    return;\n\ti=CRYPTO_add(&s->references,-1,CRYPTO_LOCK_SSL);\n#ifdef REF_PRINT\n\tREF_PRINT("SSL",s);\n#endif\n\tif (i > 0) return;\n#ifdef REF_CHECK\n\tif (i < 0)\n\t\t{\n\t\tfprintf(stderr,"SSL_free, bad reference count\\n");\n\t\tabort();\n\t\t}\n#endif\n\tCRYPTO_free_ex_data(CRYPTO_EX_INDEX_SSL, s, &s->ex_data);\n\tif (s->bbio != NULL)\n\t\t{\n\t\tif (s->bbio == s->wbio)\n\t\t\t{\n\t\t\ts->wbio=BIO_pop(s->wbio);\n\t\t\t}\n\t\tBIO_free(s->bbio);\n\t\ts->bbio=NULL;\n\t\t}\n\tif (s->rbio != NULL)\n\t\tBIO_free_all(s->rbio);\n\tif ((s->wbio != NULL) && (s->wbio != s->rbio))\n\t\tBIO_free_all(s->wbio);\n\tif (s->init_buf != NULL) BUF_MEM_free(s->init_buf);\n\tif (s->cipher_list != NULL) sk_SSL_CIPHER_free(s->cipher_list);\n\tif (s->cipher_list_by_id != NULL) sk_SSL_CIPHER_free(s->cipher_list_by_id);\n\tif (s->session != NULL)\n\t\t{\n\t\tssl_clear_bad_session(s);\n\t\tSSL_SESSION_free(s->session);\n\t\t}\n\tssl_clear_cipher_ctx(s);\n\tif (s->cert != NULL) ssl_cert_free(s->cert);\n\tif (s->ctx) SSL_CTX_free(s->ctx);\n\tif (s->client_CA != NULL)\n\t\tsk_X509_NAME_pop_free(s->client_CA,X509_NAME_free);\n\tif (s->method != NULL) s->method->ssl_free(s);\n\tOPENSSL_free(s);\n\t}', 'int ssl_clear_bad_session(SSL *s)\n\t{\n\tif (\t(s->session != NULL) &&\n\t\t!(s->shutdown & SSL_SENT_SHUTDOWN) &&\n\t\t!(SSL_in_init(s) || SSL_in_before(s)))\n\t\t{\n\t\tSSL_CTX_remove_session(s->ctx,s->session);\n\t\treturn(1);\n\t\t}\n\telse\n\t\treturn(0);\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 = (SSL_SESSION *)lh_retrieve(ctx->sessions,c)) == c)\n\t\t\t{\n\t\t\tret=1;\n\t\t\tr=(SSL_SESSION *)lh_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\tconst void *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((void *)ret);\n\t}']