apps/x509.c:1219: error: NULL_DEREFERENCE
  pointer `pktmp` last assigned on line 1218 could be null and is dereferenced by call to `EVP_PKEY_copy_parameters()` at line 1219, column 2.
Showing all 84 steps of the trace


apps/x509.c:1212:1: start of procedure sign()
1210.   
1211.   /* self sign */
1212. > static int sign(X509 *x, EVP_PKEY *pkey, int days, int clrext, const EVP_MD *digest, 
1213.   						CONF *conf, char *section)
1214.   	{

apps/x509.c:1218:2: 
1216.   	EVP_PKEY *pktmp;
1217.   
1218. > 	pktmp = X509_get_pubkey(x);
1219.   	EVP_PKEY_copy_parameters(pktmp,pkey);
1220.   	EVP_PKEY_save_parameters(pktmp,1);

crypto/x509/x509_cmp.c:358:1: start of procedure X509_get_pubkey()
  356.   	}
  357.   
  358. > EVP_PKEY *X509_get_pubkey(X509 *x)
  359.   	{
  360.   	if ((x == NULL) || (x->cert_info == NULL))

crypto/x509/x509_cmp.c:360:7: Taking false branch
  358.   EVP_PKEY *X509_get_pubkey(X509 *x)
  359.   	{
  360.   	if ((x == NULL) || (x->cert_info == NULL))
               ^
  361.   		return(NULL);
  362.   	return(X509_PUBKEY_get(x->cert_info->key));

crypto/x509/x509_cmp.c:360:22: Taking false branch
  358.   EVP_PKEY *X509_get_pubkey(X509 *x)
  359.   	{
  360.   	if ((x == NULL) || (x->cert_info == NULL))
                              ^
  361.   		return(NULL);
  362.   	return(X509_PUBKEY_get(x->cert_info->key));

crypto/x509/x509_cmp.c:362:2: 
  360.   	if ((x == NULL) || (x->cert_info == NULL))
  361.   		return(NULL);
  362. > 	return(X509_PUBKEY_get(x->cert_info->key));
  363.   	}
  364.   

crypto/asn1/x_pubkey.c:226:1: start of procedure X509_PUBKEY_get()
    224.   	}
    225.   
    226. > EVP_PKEY *X509_PUBKEY_get(X509_PUBKEY *key)
    227.   	{
    228.   	EVP_PKEY *ret=NULL;

crypto/asn1/x_pubkey.c:228:2: 
    226.   EVP_PKEY *X509_PUBKEY_get(X509_PUBKEY *key)
    227.   	{
    228. > 	EVP_PKEY *ret=NULL;
    229.   	long j;
    230.   	int type;

crypto/asn1/x_pubkey.c:237:6: Taking false branch
    235.   #endif
    236.   
    237.   	if (key == NULL) goto err;
                ^
    238.   
    239.   	if (key->pkey != NULL)

crypto/asn1/x_pubkey.c:239:6: Taking false branch
    237.   	if (key == NULL) goto err;
    238.   
    239.   	if (key->pkey != NULL)
                ^
    240.   		{
    241.   		CRYPTO_add(&key->pkey->references, 1, CRYPTO_LOCK_EVP_PKEY);

crypto/asn1/x_pubkey.c:245:6: Taking false branch
    243.   		}
    244.   
    245.   	if (key->public_key == NULL) goto err;
                ^
    246.   
    247.   	type=OBJ_obj2nid(key->algor->algorithm);

crypto/asn1/x_pubkey.c:247:2: 
    245.   	if (key->public_key == NULL) goto err;
    246.   
    247. > 	type=OBJ_obj2nid(key->algor->algorithm);
    248.   	if ((ret = EVP_PKEY_new()) == NULL)
    249.   		{

crypto/objects/obj_dat.c:366:1: start of procedure OBJ_obj2nid()
      364.   	}
      365.   
      366. > int OBJ_obj2nid(const ASN1_OBJECT *a)
      367.   	{
      368.   	ASN1_OBJECT **op;

crypto/objects/obj_dat.c:371:6: Taking false branch
      369.   	ADDED_OBJ ad,*adp;
      370.   
      371.   	if (a == NULL)
                  ^
      372.   		return(NID_undef);
      373.   	if (a->nid != 0)

crypto/objects/obj_dat.c:373:6: Taking false branch
      371.   	if (a == NULL)
      372.   		return(NID_undef);
      373.   	if (a->nid != 0)
                  ^
      374.   		return(a->nid);
      375.   

crypto/objects/obj_dat.c:376:6: Taking true branch
      374.   		return(a->nid);
      375.   
      376.   	if (added != NULL)
                  ^
      377.   		{
      378.   		ad.type=ADDED_DATA;

crypto/objects/obj_dat.c:378:3: 
      376.   	if (added != NULL)
      377.   		{
      378. > 		ad.type=ADDED_DATA;
      379.   		ad.obj=(ASN1_OBJECT *)a; /* XXX: ugly but harmless */
      380.   		adp=(ADDED_OBJ *)lh_retrieve(added,&ad);

crypto/objects/obj_dat.c:379:3: 
      377.   		{
      378.   		ad.type=ADDED_DATA;
      379. > 		ad.obj=(ASN1_OBJECT *)a; /* XXX: ugly but harmless */
      380.   		adp=(ADDED_OBJ *)lh_retrieve(added,&ad);
      381.   		if (adp != NULL) return (adp->obj->nid);

crypto/objects/obj_dat.c:380:3: 
      378.   		ad.type=ADDED_DATA;
      379.   		ad.obj=(ASN1_OBJECT *)a; /* XXX: ugly but harmless */
      380. > 		adp=(ADDED_OBJ *)lh_retrieve(added,&ad);
      381.   		if (adp != NULL) return (adp->obj->nid);
      382.   		}

crypto/lhash/lhash.c:248:1: start of procedure lh_retrieve()
        246.   	}
        247.   
        248. > void *lh_retrieve(LHASH *lh, const void *data)
        249.   	{
        250.   	unsigned long hash;

crypto/lhash/lhash.c:254:2: 
        252.   	const void *ret;
        253.   
        254. > 	lh->error=0;
        255.   	rn=getrn(lh,data,&hash);
        256.   

crypto/lhash/lhash.c:255:2: Skipping getrn(): empty list of specs
        253.   
        254.   	lh->error=0;
        255.   	rn=getrn(lh,data,&hash);
                ^
        256.   
        257.   	if (*rn == NULL)

crypto/lhash/lhash.c:257:6: Taking false branch
        255.   	rn=getrn(lh,data,&hash);
        256.   
        257.   	if (*rn == NULL)
                    ^
        258.   		{
        259.   		lh->num_retrieve_miss++;

crypto/lhash/lhash.c:264:3: 
        262.   	else
        263.   		{
        264. > 		ret= (*rn)->data;
        265.   		lh->num_retrieve++;
        266.   		}

crypto/lhash/lhash.c:265:3: 
        263.   		{
        264.   		ret= (*rn)->data;
        265. > 		lh->num_retrieve++;
        266.   		}
        267.   	return((void *)ret);

crypto/lhash/lhash.c:267:2: 
        265.   		lh->num_retrieve++;
        266.   		}
        267. > 	return((void *)ret);
        268.   	}
        269.   

crypto/lhash/lhash.c:268:2: return from a call to lh_retrieve
        266.   		}
        267.   	return((void *)ret);
        268.   	}
                ^
        269.   
        270.   static void doall_util_fn(LHASH *lh, int use_arg, LHASH_DOALL_FN_TYPE func,

crypto/objects/obj_dat.c:381:7: Taking true branch
      379.   		ad.obj=(ASN1_OBJECT *)a; /* XXX: ugly but harmless */
      380.   		adp=(ADDED_OBJ *)lh_retrieve(added,&ad);
      381.   		if (adp != NULL) return (adp->obj->nid);
                   ^
      382.   		}
      383.   	op=(ASN1_OBJECT **)OBJ_bsearch((char *)&a,(char *)obj_objs,NUM_OBJ,

crypto/objects/obj_dat.c:381:20: 
      379.   		ad.obj=(ASN1_OBJECT *)a; /* XXX: ugly but harmless */
      380.   		adp=(ADDED_OBJ *)lh_retrieve(added,&ad);
      381. > 		if (adp != NULL) return (adp->obj->nid);
      382.   		}
      383.   	op=(ASN1_OBJECT **)OBJ_bsearch((char *)&a,(char *)obj_objs,NUM_OBJ,

crypto/objects/obj_dat.c:388:2: return from a call to OBJ_obj2nid
      386.   		return(NID_undef);
      387.   	return((*op)->nid);
      388.   	}
              ^
      389.   
      390.   /* Convert an object name into an ASN1_OBJECT

crypto/asn1/x_pubkey.c:248:6: 
    246.   
    247.   	type=OBJ_obj2nid(key->algor->algorithm);
    248. > 	if ((ret = EVP_PKEY_new()) == NULL)
    249.   		{
    250.   		X509err(X509_F_X509_PUBKEY_GET, ERR_R_MALLOC_FAILURE);

crypto/evp/p_lib.c:301:1: start of procedure EVP_PKEY_new()
      299.   	}
      300.   
      301. > EVP_PKEY *EVP_PKEY_new(void)
      302.   	{
      303.   	EVP_PKEY *ret;

crypto/evp/p_lib.c:305:2: 
      303.   	EVP_PKEY *ret;
      304.   
      305. > 	ret=(EVP_PKEY *)OPENSSL_malloc(sizeof(EVP_PKEY));
      306.   	if (ret == NULL)
      307.   		{

crypto/mem.c:291:1: start of procedure CRYPTO_malloc()
        289.   	}
        290.   
        291. > void *CRYPTO_malloc(int num, const char *file, int line)
        292.   	{
        293.   	void *ret = NULL;

crypto/mem.c:293:2: 
        291.   void *CRYPTO_malloc(int num, const char *file, int line)
        292.   	{
        293. > 	void *ret = NULL;
        294.   	extern unsigned char cleanse_ctr;
        295.   

crypto/mem.c:296:6: Taking false branch
        294.   	extern unsigned char cleanse_ctr;
        295.   
        296.   	if (num <= 0) return NULL;
                    ^
        297.   
        298.   	allow_customize = 0;

crypto/mem.c:298:2: 
        296.   	if (num <= 0) return NULL;
        297.   
        298. > 	allow_customize = 0;
        299.   	if (malloc_debug_func != NULL)
        300.   		{

crypto/mem.c:299:6: Taking true branch
        297.   
        298.   	allow_customize = 0;
        299.   	if (malloc_debug_func != NULL)
                    ^
        300.   		{
        301.   		allow_customize_debug = 0;

crypto/mem.c:301:3: 
        299.   	if (malloc_debug_func != NULL)
        300.   		{
        301. > 		allow_customize_debug = 0;
        302.   		malloc_debug_func(NULL, num, file, line, 0);
        303.   		}

crypto/mem.c:302:3: Skipping __function_pointer__(): unresolved function pointer
        300.   		{
        301.   		allow_customize_debug = 0;
        302.   		malloc_debug_func(NULL, num, file, line, 0);
                 ^
        303.   		}
        304.   	ret = malloc_ex_func(num,file,line);

crypto/mem.c:304:2: Skipping __function_pointer__(): unresolved function pointer
        302.   		malloc_debug_func(NULL, num, file, line, 0);
        303.   		}
        304.   	ret = malloc_ex_func(num,file,line);
                ^
        305.   #ifdef LEVITTE_DEBUG_MEM
        306.   	fprintf(stderr, "LEVITTE_DEBUG_MEM:         > 0x%p (%d)\n", ret, num);

crypto/mem.c:308:6: Taking true branch
        306.   	fprintf(stderr, "LEVITTE_DEBUG_MEM:         > 0x%p (%d)\n", ret, num);
        307.   #endif
        308.   	if (malloc_debug_func != NULL)
                    ^
        309.   		malloc_debug_func(ret, num, file, line, 1);
        310.   

crypto/mem.c:309:3: Skipping __function_pointer__(): unresolved function pointer
        307.   #endif
        308.   	if (malloc_debug_func != NULL)
        309.   		malloc_debug_func(ret, num, file, line, 1);
                 ^
        310.   
        311.           /* Create a dependency on the value of 'cleanse_ctr' so our memory

crypto/mem.c:314:12: Taking false branch
        312.            * sanitisation function can't be optimised out. NB: We only do
        313.            * this for >2Kb so the overhead doesn't bother us. */
        314.           if(ret && (num > 2048))
                          ^
        315.                   ((unsigned char *)ret)[0] = cleanse_ctr;
        316.   

crypto/mem.c:317:2: 
        315.                   ((unsigned char *)ret)[0] = cleanse_ctr;
        316.   
        317. > 	return ret;
        318.   	}
        319.   

crypto/mem.c:318:2: return from a call to CRYPTO_malloc
        316.   
        317.   	return ret;
        318.   	}
                ^
        319.   
        320.   void *CRYPTO_realloc(void *str, int num, const char *file, int line)

crypto/evp/p_lib.c:306:6: Taking true branch
      304.   
      305.   	ret=(EVP_PKEY *)OPENSSL_malloc(sizeof(EVP_PKEY));
      306.   	if (ret == NULL)
                  ^
      307.   		{
      308.   		EVPerr(EVP_F_EVP_PKEY_NEW,ERR_R_MALLOC_FAILURE);

crypto/evp/p_lib.c:308:3: 
      306.   	if (ret == NULL)
      307.   		{
      308. > 		EVPerr(EVP_F_EVP_PKEY_NEW,ERR_R_MALLOC_FAILURE);
      309.   		return(NULL);
      310.   		}

crypto/err/err.c:664:1: start of procedure ERR_put_error()
        662.   /********************************************************/
        663.   
        664. > void ERR_put_error(int lib, int func, int reason, const char *file,
        665.   	     int line)
        666.   	{

crypto/err/err.c:688:2: Skipping ERR_get_state(): empty list of specs
        686.   	}
        687.   #endif
        688.   	es=ERR_get_state();
                ^
        689.   
        690.   	es->top=(es->top+1)%ERR_NUM_ERRORS;

crypto/err/err.c:690:2: 
        688.   	es=ERR_get_state();
        689.   
        690. > 	es->top=(es->top+1)%ERR_NUM_ERRORS;
        691.   	if (es->top == es->bottom)
        692.   		es->bottom=(es->bottom+1)%ERR_NUM_ERRORS;

crypto/err/err.c:691:6: Taking false branch
        689.   
        690.   	es->top=(es->top+1)%ERR_NUM_ERRORS;
        691.   	if (es->top == es->bottom)
                    ^
        692.   		es->bottom=(es->bottom+1)%ERR_NUM_ERRORS;
        693.   	es->err_flags[es->top]=0;

crypto/err/err.c:693:2: 
        691.   	if (es->top == es->bottom)
        692.   		es->bottom=(es->bottom+1)%ERR_NUM_ERRORS;
        693. > 	es->err_flags[es->top]=0;
        694.   	es->err_buffer[es->top]=ERR_PACK(lib,func,reason);
        695.   	es->err_file[es->top]=file;

crypto/err/err.c:694:2: 
        692.   		es->bottom=(es->bottom+1)%ERR_NUM_ERRORS;
        693.   	es->err_flags[es->top]=0;
        694. > 	es->err_buffer[es->top]=ERR_PACK(lib,func,reason);
        695.   	es->err_file[es->top]=file;
        696.   	es->err_line[es->top]=line;

crypto/err/err.c:695:2: 
        693.   	es->err_flags[es->top]=0;
        694.   	es->err_buffer[es->top]=ERR_PACK(lib,func,reason);
        695. > 	es->err_file[es->top]=file;
        696.   	es->err_line[es->top]=line;
        697.   	err_clear_data(es,es->top);

crypto/err/err.c:696:2: 
        694.   	es->err_buffer[es->top]=ERR_PACK(lib,func,reason);
        695.   	es->err_file[es->top]=file;
        696. > 	es->err_line[es->top]=line;
        697.   	err_clear_data(es,es->top);
        698.   	}

crypto/err/err.c:697:2: Taking true branch
        695.   	es->err_file[es->top]=file;
        696.   	es->err_line[es->top]=line;
        697.   	err_clear_data(es,es->top);
                ^
        698.   	}
        699.   

crypto/err/err.c:697:2: Taking false branch
        695.   	es->err_file[es->top]=file;
        696.   	es->err_line[es->top]=line;
        697.   	err_clear_data(es,es->top);
                ^
        698.   	}
        699.   

crypto/err/err.c:697:2: Loop condition is false. Leaving loop
        695.   	es->err_file[es->top]=file;
        696.   	es->err_line[es->top]=line;
        697.   	err_clear_data(es,es->top);
                ^
        698.   	}
        699.   

crypto/err/err.c:698:2: return from a call to ERR_put_error
        696.   	es->err_line[es->top]=line;
        697.   	err_clear_data(es,es->top);
        698.   	}
                ^
        699.   
        700.   void ERR_clear_error(void)

crypto/evp/p_lib.c:309:3: 
      307.   		{
      308.   		EVPerr(EVP_F_EVP_PKEY_NEW,ERR_R_MALLOC_FAILURE);
      309. > 		return(NULL);
      310.   		}
      311.   	ret->type=EVP_PKEY_NONE;

crypto/evp/p_lib.c:317:2: return from a call to EVP_PKEY_new
      315.   	ret->save_parameters=1;
      316.   	return(ret);
      317.   	}
              ^
      318.   
      319.   int EVP_PKEY_assign(EVP_PKEY *pkey, int type, char *key)

crypto/asn1/x_pubkey.c:248:6: Taking true branch
    246.   
    247.   	type=OBJ_obj2nid(key->algor->algorithm);
    248.   	if ((ret = EVP_PKEY_new()) == NULL)
                ^
    249.   		{
    250.   		X509err(X509_F_X509_PUBKEY_GET, ERR_R_MALLOC_FAILURE);

crypto/asn1/x_pubkey.c:250:3: 
    248.   	if ((ret = EVP_PKEY_new()) == NULL)
    249.   		{
    250. > 		X509err(X509_F_X509_PUBKEY_GET, ERR_R_MALLOC_FAILURE);
    251.   		goto err;
    252.   		}

crypto/err/err.c:664:1: start of procedure ERR_put_error()
      662.   /********************************************************/
      663.   
      664. > void ERR_put_error(int lib, int func, int reason, const char *file,
      665.   	     int line)
      666.   	{

crypto/err/err.c:688:2: Skipping ERR_get_state(): empty list of specs
      686.   	}
      687.   #endif
      688.   	es=ERR_get_state();
              ^
      689.   
      690.   	es->top=(es->top+1)%ERR_NUM_ERRORS;

crypto/err/err.c:690:2: 
      688.   	es=ERR_get_state();
      689.   
      690. > 	es->top=(es->top+1)%ERR_NUM_ERRORS;
      691.   	if (es->top == es->bottom)
      692.   		es->bottom=(es->bottom+1)%ERR_NUM_ERRORS;

crypto/err/err.c:691:6: Taking false branch
      689.   
      690.   	es->top=(es->top+1)%ERR_NUM_ERRORS;
      691.   	if (es->top == es->bottom)
                  ^
      692.   		es->bottom=(es->bottom+1)%ERR_NUM_ERRORS;
      693.   	es->err_flags[es->top]=0;

crypto/err/err.c:693:2: 
      691.   	if (es->top == es->bottom)
      692.   		es->bottom=(es->bottom+1)%ERR_NUM_ERRORS;
      693. > 	es->err_flags[es->top]=0;
      694.   	es->err_buffer[es->top]=ERR_PACK(lib,func,reason);
      695.   	es->err_file[es->top]=file;

crypto/err/err.c:694:2: 
      692.   		es->bottom=(es->bottom+1)%ERR_NUM_ERRORS;
      693.   	es->err_flags[es->top]=0;
      694. > 	es->err_buffer[es->top]=ERR_PACK(lib,func,reason);
      695.   	es->err_file[es->top]=file;
      696.   	es->err_line[es->top]=line;

crypto/err/err.c:695:2: 
      693.   	es->err_flags[es->top]=0;
      694.   	es->err_buffer[es->top]=ERR_PACK(lib,func,reason);
      695. > 	es->err_file[es->top]=file;
      696.   	es->err_line[es->top]=line;
      697.   	err_clear_data(es,es->top);

crypto/err/err.c:696:2: 
      694.   	es->err_buffer[es->top]=ERR_PACK(lib,func,reason);
      695.   	es->err_file[es->top]=file;
      696. > 	es->err_line[es->top]=line;
      697.   	err_clear_data(es,es->top);
      698.   	}

crypto/err/err.c:697:2: Taking true branch
      695.   	es->err_file[es->top]=file;
      696.   	es->err_line[es->top]=line;
      697.   	err_clear_data(es,es->top);
              ^
      698.   	}
      699.   

crypto/err/err.c:697:2: Taking false branch
      695.   	es->err_file[es->top]=file;
      696.   	es->err_line[es->top]=line;
      697.   	err_clear_data(es,es->top);
              ^
      698.   	}
      699.   

crypto/err/err.c:697:2: Loop condition is false. Leaving loop
      695.   	es->err_file[es->top]=file;
      696.   	es->err_line[es->top]=line;
      697.   	err_clear_data(es,es->top);
              ^
      698.   	}
      699.   

crypto/err/err.c:698:2: return from a call to ERR_put_error
      696.   	es->err_line[es->top]=line;
      697.   	err_clear_data(es,es->top);
      698.   	}
              ^
      699.   
      700.   void ERR_clear_error(void)

crypto/asn1/x_pubkey.c:337:1: 
    335.   	CRYPTO_add(&ret->references, 1, CRYPTO_LOCK_EVP_PKEY);
    336.   	return(ret);
    337. > err:
    338.   	if (ret != NULL)
    339.   		EVP_PKEY_free(ret);

crypto/asn1/x_pubkey.c:338:6: Taking false branch
    336.   	return(ret);
    337.   err:
    338.   	if (ret != NULL)
                ^
    339.   		EVP_PKEY_free(ret);
    340.   	return(NULL);

crypto/asn1/x_pubkey.c:340:2: 
    338.   	if (ret != NULL)
    339.   		EVP_PKEY_free(ret);
    340. > 	return(NULL);
    341.   	}
    342.   

crypto/asn1/x_pubkey.c:341:2: return from a call to X509_PUBKEY_get
    339.   		EVP_PKEY_free(ret);
    340.   	return(NULL);
    341.   	}
            ^
    342.   
    343.   /* Now two pseudo ASN1 routines that take an EVP_PKEY structure

crypto/x509/x509_cmp.c:363:2: return from a call to X509_get_pubkey
  361.   		return(NULL);
  362.   	return(X509_PUBKEY_get(x->cert_info->key));
  363.   	}
          ^
  364.   
  365.   ASN1_BIT_STRING *X509_get0_pubkey_bitstr(const X509 *x)

apps/x509.c:1219:2: 
1217.   
1218.   	pktmp = X509_get_pubkey(x);
1219. > 	EVP_PKEY_copy_parameters(pktmp,pkey);
1220.   	EVP_PKEY_save_parameters(pktmp,1);
1221.   	EVP_PKEY_free(pktmp);

crypto/evp/p_lib.c:156:1: start of procedure EVP_PKEY_copy_parameters()
  154.   	}
  155.   
  156. > int EVP_PKEY_copy_parameters(EVP_PKEY *to, const EVP_PKEY *from)
  157.   	{
  158.   	if (to->type != from->type)

crypto/evp/p_lib.c:158:6: 
  156.   int EVP_PKEY_copy_parameters(EVP_PKEY *to, const EVP_PKEY *from)
  157.   	{
  158. > 	if (to->type != from->type)
  159.   		{
  160.   		EVPerr(EVP_F_EVP_PKEY_COPY_PARAMETERS,EVP_R_DIFFERENT_KEY_TYPES);

static int sign(X509 *x, EVP_PKEY *pkey, int days, int clrext, const EVP_MD *digest,
						CONF *conf, char *section)
	{
	EVP_PKEY *pktmp;
	pktmp = X509_get_pubkey(x);
	EVP_PKEY_copy_parameters(pktmp,pkey);
	EVP_PKEY_save_parameters(pktmp,1);
	EVP_PKEY_free(pktmp);
	if (!X509_set_issuer_name(x,X509_get_subject_name(x))) goto err;
	if (X509_gmtime_adj(X509_get_notBefore(x),0) == NULL) goto err;
	if (X509_gmtime_adj(X509_get_notAfter(x),(long)60*60*24*days) == NULL)
		goto err;
	if (!X509_set_pubkey(x,pkey)) goto err;
	if (clrext)
		{
		while (X509_get_ext_count(x) > 0) X509_delete_ext(x, 0);
		}
	if (conf)
		{
		X509V3_CTX ctx;
		X509_set_version(x,2);
                X509V3_set_ctx(&ctx, x, x, NULL, NULL, 0);
                X509V3_set_nconf(&ctx, conf);
                if (!X509V3_EXT_add_nconf(conf, &ctx, section, x)) goto err;
		}
	if (!X509_sign(x,pkey,digest)) goto err;
	return 1;
err:
	ERR_print_errors(bio_err);
	return 0;
	}
['static int sign(X509 *x, EVP_PKEY *pkey, int days, int clrext, const EVP_MD *digest,\n\t\t\t\t\t\tCONF *conf, char *section)\n\t{\n\tEVP_PKEY *pktmp;\n\tpktmp = X509_get_pubkey(x);\n\tEVP_PKEY_copy_parameters(pktmp,pkey);\n\tEVP_PKEY_save_parameters(pktmp,1);\n\tEVP_PKEY_free(pktmp);\n\tif (!X509_set_issuer_name(x,X509_get_subject_name(x))) goto err;\n\tif (X509_gmtime_adj(X509_get_notBefore(x),0) == NULL) goto err;\n\tif (X509_gmtime_adj(X509_get_notAfter(x),(long)60*60*24*days) == NULL)\n\t\tgoto err;\n\tif (!X509_set_pubkey(x,pkey)) goto err;\n\tif (clrext)\n\t\t{\n\t\twhile (X509_get_ext_count(x) > 0) X509_delete_ext(x, 0);\n\t\t}\n\tif (conf)\n\t\t{\n\t\tX509V3_CTX ctx;\n\t\tX509_set_version(x,2);\n                X509V3_set_ctx(&ctx, x, x, NULL, NULL, 0);\n                X509V3_set_nconf(&ctx, conf);\n                if (!X509V3_EXT_add_nconf(conf, &ctx, section, x)) goto err;\n\t\t}\n\tif (!X509_sign(x,pkey,digest)) goto err;\n\treturn 1;\nerr:\n\tERR_print_errors(bio_err);\n\treturn 0;\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\tconst unsigned 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_EC\n\telse if (ret->type == EVP_PKEY_EC)\n\t\t{\n\t\tif (a->parameter && (a->parameter->type == V_ASN1_SEQUENCE))\n\t\t\t{\n\t\t\tif ((ret->pkey.eckey= EC_KEY_new()) == NULL)\n\t\t\t\t{\n\t\t\t\tX509err(X509_F_X509_PUBKEY_GET,\n\t\t\t\t\tERR_R_MALLOC_FAILURE);\n\t\t\t\tgoto err;\n\t\t\t\t}\n\t\t\tcp = p = a->parameter->value.sequence->data;\n\t\t\tj = a->parameter->value.sequence->length;\n\t\t\tif (!d2i_ECParameters(&ret->pkey.eckey, &cp, (long)j))\n\t\t\t\t{\n\t\t\t\tX509err(X509_F_X509_PUBKEY_GET, ERR_R_EC_LIB);\n\t\t\t\tgoto err;\n\t\t\t\t}\n\t\t\t}\n\t\telse if (a->parameter && (a->parameter->type == V_ASN1_OBJECT))\n\t\t\t{\n\t\t\tEC_KEY *eckey;\n\t\t\tif (ret->pkey.eckey == NULL)\n\t\t\t\tret->pkey.eckey = EC_KEY_new();\n\t\t\teckey = ret->pkey.eckey;\n\t\t\tif (eckey->group)\n\t\t\t\tEC_GROUP_free(eckey->group);\n\t\t\tif ((eckey->group = EC_GROUP_new_by_nid(\n                             OBJ_obj2nid(a->parameter->value.object))) == NULL)\n\t\t\t\tgoto err;\n\t\t\tEC_GROUP_set_asn1_flag(eckey->group,\n\t\t\t\t\t\tOPENSSL_EC_NAMED_CURVE);\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 (!d2i_PublicKey(type, &ret, &p, (long)j))\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}', 'int OBJ_obj2nid(const ASN1_OBJECT *a)\n\t{\n\tASN1_OBJECT **op;\n\tADDED_OBJ ad,*adp;\n\tif (a == NULL)\n\t\treturn(NID_undef);\n\tif (a->nid != 0)\n\t\treturn(a->nid);\n\tif (added != NULL)\n\t\t{\n\t\tad.type=ADDED_DATA;\n\t\tad.obj=(ASN1_OBJECT *)a;\n\t\tadp=(ADDED_OBJ *)lh_retrieve(added,&ad);\n\t\tif (adp != NULL) return (adp->obj->nid);\n\t\t}\n\top=(ASN1_OBJECT **)OBJ_bsearch((char *)&a,(char *)obj_objs,NUM_OBJ,\n\t\tsizeof(ASN1_OBJECT *),obj_cmp);\n\tif (op == NULL)\n\t\treturn(NID_undef);\n\treturn((*op)->nid);\n\t}', 'void *lh_retrieve(LHASH *lh, const void *data)\n\t{\n\tunsigned long hash;\n\tLHASH_NODE **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_retrieve_miss++;\n\t\treturn(NULL);\n\t\t}\n\telse\n\t\t{\n\t\tret= (*rn)->data;\n\t\tlh->num_retrieve++;\n\t\t}\n\treturn((void *)ret);\n\t}', 'EVP_PKEY *EVP_PKEY_new(void)\n\t{\n\tEVP_PKEY *ret;\n\tret=(EVP_PKEY *)OPENSSL_malloc(sizeof(EVP_PKEY));\n\tif (ret == NULL)\n\t\t{\n\t\tEVPerr(EVP_F_EVP_PKEY_NEW,ERR_R_MALLOC_FAILURE);\n\t\treturn(NULL);\n\t\t}\n\tret->type=EVP_PKEY_NONE;\n\tret->references=1;\n\tret->pkey.ptr=NULL;\n\tret->attributes=NULL;\n\tret->save_parameters=1;\n\treturn(ret);\n\t}', 'void *CRYPTO_malloc(int num, const char *file, int line)\n\t{\n\tvoid *ret = NULL;\n\textern unsigned char cleanse_ctr;\n\tif (num <= 0) return NULL;\n\tallow_customize = 0;\n\tif (malloc_debug_func != NULL)\n\t\t{\n\t\tallow_customize_debug = 0;\n\t\tmalloc_debug_func(NULL, num, file, line, 0);\n\t\t}\n\tret = malloc_ex_func(num,file,line);\n#ifdef LEVITTE_DEBUG_MEM\n\tfprintf(stderr, "LEVITTE_DEBUG_MEM:         > 0x%p (%d)\\n", ret, num);\n#endif\n\tif (malloc_debug_func != NULL)\n\t\tmalloc_debug_func(ret, num, file, line, 1);\n        if(ret && (num > 2048))\n                ((unsigned char *)ret)[0] = cleanse_ctr;\n\treturn ret;\n\t}', 'void ERR_put_error(int lib, int func, int reason, const char *file,\n\t     int line)\n\t{\n\tERR_STATE *es;\n#ifdef _OSD_POSIX\n\tif (strncmp(file,"*POSIX(", sizeof("*POSIX(")-1) == 0) {\n\t\tchar *end;\n\t\tfile += sizeof("*POSIX(")-1;\n\t\tend = &file[strlen(file)-1];\n\t\tif (*end == \')\')\n\t\t\t*end = \'\\0\';\n\t\tif ((end = strrchr(file, \'/\')) != NULL)\n\t\t\tfile = &end[1];\n\t}\n#endif\n\tes=ERR_get_state();\n\tes->top=(es->top+1)%ERR_NUM_ERRORS;\n\tif (es->top == es->bottom)\n\t\tes->bottom=(es->bottom+1)%ERR_NUM_ERRORS;\n\tes->err_flags[es->top]=0;\n\tes->err_buffer[es->top]=ERR_PACK(lib,func,reason);\n\tes->err_file[es->top]=file;\n\tes->err_line[es->top]=line;\n\terr_clear_data(es,es->top);\n\t}', 'int EVP_PKEY_copy_parameters(EVP_PKEY *to, const EVP_PKEY *from)\n\t{\n\tif (to->type != from->type)\n\t\t{\n\t\tEVPerr(EVP_F_EVP_PKEY_COPY_PARAMETERS,EVP_R_DIFFERENT_KEY_TYPES);\n\t\tgoto err;\n\t\t}\n\tif (EVP_PKEY_missing_parameters(from))\n\t\t{\n\t\tEVPerr(EVP_F_EVP_PKEY_COPY_PARAMETERS,EVP_R_MISSING_PARAMETERS);\n\t\tgoto err;\n\t\t}\n#ifndef OPENSSL_NO_DSA\n\tif (to->type == EVP_PKEY_DSA)\n\t\t{\n\t\tBIGNUM *a;\n\t\tif ((a=BN_dup(from->pkey.dsa->p)) == NULL) goto err;\n\t\tif (to->pkey.dsa->p != NULL) BN_free(to->pkey.dsa->p);\n\t\tto->pkey.dsa->p=a;\n\t\tif ((a=BN_dup(from->pkey.dsa->q)) == NULL) goto err;\n\t\tif (to->pkey.dsa->q != NULL) BN_free(to->pkey.dsa->q);\n\t\tto->pkey.dsa->q=a;\n\t\tif ((a=BN_dup(from->pkey.dsa->g)) == NULL) goto err;\n\t\tif (to->pkey.dsa->g != NULL) BN_free(to->pkey.dsa->g);\n\t\tto->pkey.dsa->g=a;\n\t\t}\n#endif\n#ifndef OPENSSL_NO_EC\n\tif (to->type == EVP_PKEY_EC)\n\t\t{\n\t\tif (to->pkey.eckey->group != NULL)\n\t\t\tEC_GROUP_free(to->pkey.eckey->group);\n\t\tif ((to->pkey.eckey->group = EC_GROUP_new(\n\t\t\tEC_GROUP_method_of(from->pkey.eckey->group))) == NULL)\n\t\t\tgoto err;\n\t\tif (!EC_GROUP_copy(to->pkey.eckey->group,\n\t\t\tfrom->pkey.eckey->group)) goto err;\n\t\t}\n#endif\n\treturn(1);\nerr:\n\treturn(0);\n\t}']