apps/x509.c:327: error: INTEGER_OVERFLOW_L2
  ([0, +oo] - 1):unsigned32 by call to `CONF_load`.
Showing all 12 steps of the trace


apps/x509.c:327:17: Call
325.   		long errorline;
326.   		X509V3_CTX ctx2;
327.   		if (!(extconf=CONF_load(NULL,extfile,&errorline))) {
                       ^
328.   			if (errorline <= 0)
329.   				BIO_printf(bio_err,

crypto/conf/conf.c:86:1: Parameter `h->num_nodes`
  84.   
  85.   
  86. > LHASH *CONF_load(LHASH *h, const char *file, long *line)
  87.   	{
  88.   	LHASH *ltmp;

crypto/conf/conf.c:105:9: Call
  103.   		}
  104.   
  105.   	ltmp = CONF_load_fp(h, in, line);
                 ^
  106.   	fclose(in);
  107.   

crypto/conf/conf.c:111:1: Parameter `h->num_nodes`
    109.   }
    110.   
    111. > LHASH *CONF_load_fp(LHASH *h, FILE *in, long *line)
    112.   {
    113.   	BIO *btmp;

crypto/conf/conf.c:119:9: Call
    117.   		return NULL;
    118.   	}
    119.   	ltmp = CONF_load_bio(h, btmp, line);
                   ^
    120.   	BIO_free(btmp);
    121.   	return ltmp;

crypto/conf/conf.c:124:1: Parameter `h->num_nodes`
      122.   }
      123.   
      124. > LHASH *CONF_load_bio(LHASH *h, BIO *in, long *line)
      125.   	{
      126.   	LHASH *ret=NULL;

crypto/conf/conf.c:361:35: Call
      359.   	sprintf(btmp,"%ld",eline);
      360.   	ERR_add_error_data(2,"line ",btmp);
      361.   	if ((h != ret) && (ret != NULL)) CONF_free(ret);
                                               ^
      362.   	if (v != NULL)
      363.   		{

crypto/conf/conf.c:442:1: Parameter `conf->num_nodes`
        440.   	}
        441.   
        442. > void CONF_free(LHASH *conf)
        443.   	{
        444.   	if (conf == NULL) return;

crypto/conf/conf.c:448:2: Call
        446.   	conf->down_load=0; 	/* evil thing to make sure the 'Free()'
        447.   				 * works as expected */
        448.   	lh_doall_arg(conf,(void (*)())value_free_hash,(char *)conf);
                ^
        449.   
        450.   	/* We now have only 'section' entries in the hash table.

crypto/lhash/lhash.c:278:1: <LHS trace>
276.   	}
277.   
278. > void lh_doall_arg(LHASH *lh, void (*func)(), char *arg)
279.   	{
280.   	int i;

crypto/lhash/lhash.c:278:1: Parameter `lh->num_nodes`
          276.   	}
          277.   
          278. > void lh_doall_arg(LHASH *lh, void (*func)(), char *arg)
          279.   	{
          280.   	int i;

crypto/lhash/lhash.c:285:7: Binary operation: ([0, +oo] - 1):unsigned32 by call to `CONF_load` 
          283.   	/* reverse the order so we search from 'top to bottom'
          284.   	 * We were having memory leaks otherwise */
          285.   	for (i=lh->num_nodes-1; i>=0; i--)
                       ^
          286.   		{
          287.   		a=lh->b[i];

void lh_doall_arg(LHASH *lh, void (*func)(), char *arg)
	{
	int i;
	LHASH_NODE *a,*n;
	for (i=lh->num_nodes-1; i>=0; i--)
		{
		a=lh->b[i];
		while (a != NULL)
			{
			n=a->next;
			func(a->data,arg);
			a=n;
			}
		}
	}
['int MAIN(int argc, char **argv)\n\t{\n\tint ret=1;\n\tX509_REQ *req=NULL;\n\tX509 *x=NULL,*xca=NULL;\n\tEVP_PKEY *Upkey=NULL,*CApkey=NULL;\n\tint i,num,badops=0;\n\tBIO *out=NULL;\n\tBIO *STDout=NULL;\n\tint informat,outformat,keyformat,CAformat,CAkeyformat;\n\tchar *infile=NULL,*outfile=NULL,*keyfile=NULL,*CAfile=NULL;\n\tchar *CAkeyfile=NULL,*CAserial=NULL;\n\tint text=0,serial=0,hash=0,subject=0,issuer=0,startdate=0,enddate=0;\n\tint noout=0,sign_flag=0,CA_flag=0,CA_createserial=0;\n\tint C=0;\n\tint x509req=0,days=DEF_DAYS,modulus=0;\n\tchar **pp;\n\tX509_STORE *ctx=NULL;\n\tX509_REQ *rq=NULL;\n\tint fingerprint=0;\n\tchar buf[256];\n\tconst EVP_MD *md_alg,*digest=EVP_md5();\n\tLHASH *extconf = NULL;\n\tchar *extsect = NULL, *extfile = NULL;\n\treqfile=0;\n\tapps_startup();\n\tif (bio_err == NULL)\n\t\tbio_err=BIO_new_fp(stderr,BIO_NOCLOSE);\n\tSTDout=BIO_new_fp(stdout,BIO_NOCLOSE);\n\tinformat=FORMAT_PEM;\n\toutformat=FORMAT_PEM;\n\tkeyformat=FORMAT_PEM;\n\tCAformat=FORMAT_PEM;\n\tCAkeyformat=FORMAT_PEM;\n\tctx=X509_STORE_new();\n\tif (ctx == NULL) goto end;\n\tX509_STORE_set_verify_cb_func(ctx,callb);\n\targc--;\n\targv++;\n\tnum=0;\n\twhile (argc >= 1)\n\t\t{\n\t\tif \t(strcmp(*argv,"-inform") == 0)\n\t\t\t{\n\t\t\tif (--argc < 1) goto bad;\n\t\t\tinformat=str2fmt(*(++argv));\n\t\t\t}\n\t\telse if (strcmp(*argv,"-outform") == 0)\n\t\t\t{\n\t\t\tif (--argc < 1) goto bad;\n\t\t\toutformat=str2fmt(*(++argv));\n\t\t\t}\n\t\telse if (strcmp(*argv,"-keyform") == 0)\n\t\t\t{\n\t\t\tif (--argc < 1) goto bad;\n\t\t\tkeyformat=str2fmt(*(++argv));\n\t\t\t}\n\t\telse if (strcmp(*argv,"-req") == 0)\n\t\t\treqfile=1;\n\t\telse if (strcmp(*argv,"-CAform") == 0)\n\t\t\t{\n\t\t\tif (--argc < 1) goto bad;\n\t\t\tCAformat=str2fmt(*(++argv));\n\t\t\t}\n\t\telse if (strcmp(*argv,"-CAkeyform") == 0)\n\t\t\t{\n\t\t\tif (--argc < 1) goto bad;\n\t\t\tCAformat=str2fmt(*(++argv));\n\t\t\t}\n\t\telse if (strcmp(*argv,"-days") == 0)\n\t\t\t{\n\t\t\tif (--argc < 1) goto bad;\n\t\t\tdays=atoi(*(++argv));\n\t\t\tif (days == 0)\n\t\t\t\t{\n\t\t\t\tBIO_printf(STDout,"bad number of days\\n");\n\t\t\t\tgoto bad;\n\t\t\t\t}\n\t\t\t}\n\t\telse if (strcmp(*argv,"-extfile") == 0)\n\t\t\t{\n\t\t\tif (--argc < 1) goto bad;\n\t\t\textfile= *(++argv);\n\t\t\t}\n\t\telse if (strcmp(*argv,"-in") == 0)\n\t\t\t{\n\t\t\tif (--argc < 1) goto bad;\n\t\t\tinfile= *(++argv);\n\t\t\t}\n\t\telse if (strcmp(*argv,"-out") == 0)\n\t\t\t{\n\t\t\tif (--argc < 1) goto bad;\n\t\t\toutfile= *(++argv);\n\t\t\t}\n\t\telse if (strcmp(*argv,"-signkey") == 0)\n\t\t\t{\n\t\t\tif (--argc < 1) goto bad;\n\t\t\tkeyfile= *(++argv);\n\t\t\tsign_flag= ++num;\n\t\t\t}\n\t\telse if (strcmp(*argv,"-CA") == 0)\n\t\t\t{\n\t\t\tif (--argc < 1) goto bad;\n\t\t\tCAfile= *(++argv);\n\t\t\tCA_flag= ++num;\n\t\t\t}\n\t\telse if (strcmp(*argv,"-CAkey") == 0)\n\t\t\t{\n\t\t\tif (--argc < 1) goto bad;\n\t\t\tCAkeyfile= *(++argv);\n\t\t\t}\n\t\telse if (strcmp(*argv,"-CAserial") == 0)\n\t\t\t{\n\t\t\tif (--argc < 1) goto bad;\n\t\t\tCAserial= *(++argv);\n\t\t\t}\n\t\telse if (strcmp(*argv,"-C") == 0)\n\t\t\tC= ++num;\n\t\telse if (strcmp(*argv,"-serial") == 0)\n\t\t\tserial= ++num;\n\t\telse if (strcmp(*argv,"-modulus") == 0)\n\t\t\tmodulus= ++num;\n\t\telse if (strcmp(*argv,"-x509toreq") == 0)\n\t\t\tx509req= ++num;\n\t\telse if (strcmp(*argv,"-text") == 0)\n\t\t\ttext= ++num;\n\t\telse if (strcmp(*argv,"-hash") == 0)\n\t\t\thash= ++num;\n\t\telse if (strcmp(*argv,"-subject") == 0)\n\t\t\tsubject= ++num;\n\t\telse if (strcmp(*argv,"-issuer") == 0)\n\t\t\tissuer= ++num;\n\t\telse if (strcmp(*argv,"-fingerprint") == 0)\n\t\t\tfingerprint= ++num;\n\t\telse if (strcmp(*argv,"-dates") == 0)\n\t\t\t{\n\t\t\tstartdate= ++num;\n\t\t\tenddate= ++num;\n\t\t\t}\n\t\telse if (strcmp(*argv,"-startdate") == 0)\n\t\t\tstartdate= ++num;\n\t\telse if (strcmp(*argv,"-enddate") == 0)\n\t\t\tenddate= ++num;\n\t\telse if (strcmp(*argv,"-noout") == 0)\n\t\t\tnoout= ++num;\n\t\telse if (strcmp(*argv,"-CAcreateserial") == 0)\n\t\t\tCA_createserial= ++num;\n\t\telse if ((md_alg=EVP_get_digestbyname(&((*argv)[1]))) != NULL)\n\t\t\t{\n\t\t\tdigest=md_alg;\n\t\t\t}\n\t\telse\n\t\t\t{\n\t\t\tBIO_printf(bio_err,"unknown option %s\\n",*argv);\n\t\t\tbadops=1;\n\t\t\tbreak;\n\t\t\t}\n\t\targc--;\n\t\targv++;\n\t\t}\n\tif (badops)\n\t\t{\nbad:\n\t\tfor (pp=x509_usage; (*pp != NULL); pp++)\n\t\t\tBIO_printf(bio_err,*pp);\n\t\tgoto end;\n\t\t}\n\tERR_load_crypto_strings();\n\tX509V3_add_standard_extensions();\n\tif (!X509_STORE_set_default_paths(ctx))\n\t\t{\n\t\tERR_print_errors(bio_err);\n\t\tgoto end;\n\t\t}\n\tif ((CAkeyfile == NULL) && (CA_flag) && (CAformat == FORMAT_PEM))\n\t\t{ CAkeyfile=CAfile; }\n\telse if ((CA_flag) && (CAkeyfile == NULL))\n\t\t{\n\t\tBIO_printf(bio_err,"need to specify a CAkey if using the CA command\\n");\n\t\tgoto end;\n\t\t}\n\tif (extfile) {\n\t\tlong errorline;\n\t\tX509V3_CTX ctx2;\n\t\tif (!(extconf=CONF_load(NULL,extfile,&errorline))) {\n\t\t\tif (errorline <= 0)\n\t\t\t\tBIO_printf(bio_err,\n\t\t\t\t\t"error loading the config file \'%s\'\\n",\n\t\t\t\t\t\t\t\textfile);\n                \telse\n                        \tBIO_printf(bio_err,\n\t\t\t\t       "error on line %ld of config file \'%s\'\\n"\n\t\t\t\t\t\t\t,errorline,extfile);\n\t\t\tgoto end;\n\t\t}\n\t\tif(!(extsect = CONF_get_string(extconf, "default",\n\t\t\t\t\t "extensions"))) extsect = "default";\n\t\tX509V3_set_ctx_test(&ctx2);\n\t\tX509V3_set_conf_lhash(&ctx2, extconf);\n\t\tif(!X509V3_EXT_add_conf(extconf, &ctx2, extsect, NULL)) {\n\t\t\tBIO_printf(bio_err,\n\t\t\t\t"Error Loading extension section %s\\n",\n\t\t\t\t\t\t\t\t extsect);\n\t\t\tERR_print_errors(bio_err);\n\t\t\tgoto end;\n                }\n\t}\n\tif (reqfile)\n\t\t{\n\t\tEVP_PKEY *pkey;\n\t\tX509_CINF *ci;\n\t\tBIO *in;\n\t\tif (!sign_flag && !CA_flag)\n\t\t\t{\n\t\t\tBIO_printf(bio_err,"We need a private key to sign with\\n");\n\t\t\tgoto end;\n\t\t\t}\n\t\tin=BIO_new(BIO_s_file());\n\t\tif (in == NULL)\n\t\t\t{\n\t\t\tERR_print_errors(bio_err);\n\t\t\tgoto end;\n\t\t\t}\n\t\tif (infile == NULL)\n\t\t\tBIO_set_fp(in,stdin,BIO_NOCLOSE|BIO_FP_TEXT);\n\t\telse\n\t\t\t{\n\t\t\tif (BIO_read_filename(in,infile) <= 0)\n\t\t\t\t{\n\t\t\t\tperror(infile);\n\t\t\t\tgoto end;\n\t\t\t\t}\n\t\t\t}\n\t\treq=PEM_read_bio_X509_REQ(in,NULL,NULL);\n\t\tBIO_free(in);\n\t\tif (req == NULL) { perror(infile); goto end; }\n\t\tif (\t(req->req_info == NULL) ||\n\t\t\t(req->req_info->pubkey == NULL) ||\n\t\t\t(req->req_info->pubkey->public_key == NULL) ||\n\t\t\t(req->req_info->pubkey->public_key->data == NULL))\n\t\t\t{\n\t\t\tBIO_printf(bio_err,"The certificate request appears to corrupted\\n");\n\t\t\tBIO_printf(bio_err,"It does not contain a public key\\n");\n\t\t\tgoto end;\n\t\t\t}\n\t\tif ((pkey=X509_REQ_get_pubkey(req)) == NULL)\n\t                {\n\t                BIO_printf(bio_err,"error unpacking public key\\n");\n\t                goto end;\n\t                }\n\t\ti=X509_REQ_verify(req,pkey);\n\t\tEVP_PKEY_free(pkey);\n\t\tif (i < 0)\n\t\t\t{\n\t\t\tBIO_printf(bio_err,"Signature verification error\\n");\n\t\t\tERR_print_errors(bio_err);\n\t\t\tgoto end;\n\t\t\t}\n\t        if (i == 0)\n\t\t\t{\n\t\t\tBIO_printf(bio_err,"Signature did not match the certificate request\\n");\n\t\t\tgoto end;\n\t\t\t}\n\t\telse\n\t\t\tBIO_printf(bio_err,"Signature ok\\n");\n\t\tX509_NAME_oneline(req->req_info->subject,buf,256);\n\t\tBIO_printf(bio_err,"subject=%s\\n",buf);\n\t\tif ((x=X509_new()) == NULL) goto end;\n\t\tci=x->cert_info;\n\t\tif (!ASN1_INTEGER_set(X509_get_serialNumber(x),0)) goto end;\n\t\tif (!X509_set_issuer_name(x,req->req_info->subject)) goto end;\n\t\tif (!X509_set_subject_name(x,req->req_info->subject)) goto end;\n\t\tX509_gmtime_adj(X509_get_notBefore(x),0);\n\t        X509_gmtime_adj(X509_get_notAfter(x),(long)60*60*24*days);\n#if 0\n\t\tX509_PUBKEY_free(ci->key);\n\t\tci->key=req->req_info->pubkey;\n\t        req->req_info->pubkey=NULL;\n#else\n\t\tpkey = X509_REQ_get_pubkey(req);\n\t\tX509_set_pubkey(x,pkey);\n\t\tEVP_PKEY_free(pkey);\n#endif\n\t\t}\n\telse\n\t\tx=load_cert(infile,informat);\n\tif (x == NULL) goto end;\n\tif (CA_flag)\n\t\t{\n\t\txca=load_cert(CAfile,CAformat);\n\t\tif (xca == NULL) goto end;\n\t\t}\n\tif (!noout || text)\n\t\t{\n\t\tOBJ_create("2.99999.3",\n\t\t\t"SET.ex3","SET x509v3 extension 3");\n\t\tout=BIO_new(BIO_s_file());\n\t\tif (out == NULL)\n\t\t\t{\n\t\t\tERR_print_errors(bio_err);\n\t\t\tgoto end;\n\t\t\t}\n\t\tif (outfile == NULL)\n\t\t\tBIO_set_fp(out,stdout,BIO_NOCLOSE);\n\t\telse\n\t\t\t{\n\t\t\tif (BIO_write_filename(out,outfile) <= 0)\n\t\t\t\t{\n\t\t\t\tperror(outfile);\n\t\t\t\tgoto end;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\tif (num)\n\t\t{\n\t\tfor (i=1; i<=num; i++)\n\t\t\t{\n\t\t\tif (issuer == i)\n\t\t\t\t{\n\t\t\t\tX509_NAME_oneline(X509_get_issuer_name(x),\n\t\t\t\t\tbuf,256);\n\t\t\t\tBIO_printf(STDout,"issuer= %s\\n",buf);\n\t\t\t\t}\n\t\t\telse if (subject == i)\n\t\t\t\t{\n\t\t\t\tX509_NAME_oneline(X509_get_subject_name(x),\n\t\t\t\t\tbuf,256);\n\t\t\t\tBIO_printf(STDout,"subject=%s\\n",buf);\n\t\t\t\t}\n\t\t\telse if (serial == i)\n\t\t\t\t{\n\t\t\t\tBIO_printf(STDout,"serial=");\n\t\t\t\ti2a_ASN1_INTEGER(STDout,x->cert_info->serialNumber);\n\t\t\t\tBIO_printf(STDout,"\\n");\n\t\t\t\t}\n\t\t\telse if (hash == i)\n\t\t\t\t{\n\t\t\t\tBIO_printf(STDout,"%08lx\\n",X509_subject_name_hash(x));\n\t\t\t\t}\n\t\t\telse\n\t\t\t\tif (modulus == i)\n\t\t\t\t{\n\t\t\t\tEVP_PKEY *pkey;\n\t\t\t\tpkey=X509_get_pubkey(x);\n\t\t\t\tif (pkey == NULL)\n\t\t\t\t\t{\n\t\t\t\t\tBIO_printf(bio_err,"Modulus=unavailable\\n");\n\t\t\t\t\tERR_print_errors(bio_err);\n\t\t\t\t\tgoto end;\n\t\t\t\t\t}\n\t\t\t\tBIO_printf(STDout,"Modulus=");\n#ifndef NO_RSA\n\t\t\t\tif (pkey->type == EVP_PKEY_RSA)\n\t\t\t\t\tBN_print(STDout,pkey->pkey.rsa->n);\n\t\t\t\telse\n#endif\n#ifndef NO_DSA\n\t\t\t\tif (pkey->type == EVP_PKEY_DSA)\n\t\t\t\t\tBN_print(STDout,pkey->pkey.dsa->pub_key);\n\t\t\t\telse\n#endif\n\t\t\t\t\tBIO_printf(STDout,"Wrong Algorithm type");\n\t\t\t\tBIO_printf(STDout,"\\n");\n\t\t\t\tEVP_PKEY_free(pkey);\n\t\t\t\t}\n\t\t\telse\n\t\t\t\tif (C == i)\n\t\t\t\t{\n\t\t\t\tunsigned char *d;\n\t\t\t\tchar *m;\n\t\t\t\tint y,z;\n\t\t\t\tX509_NAME_oneline(X509_get_subject_name(x),\n\t\t\t\t\tbuf,256);\n\t\t\t\tBIO_printf(STDout,"/* subject:%s */\\n",buf);\n\t\t\t\tm=X509_NAME_oneline(\n\t\t\t\t\tX509_get_issuer_name(x),buf,256);\n\t\t\t\tBIO_printf(STDout,"/* issuer :%s */\\n",buf);\n\t\t\t\tz=i2d_X509(x,NULL);\n\t\t\t\tm=Malloc(z);\n\t\t\t\td=(unsigned char *)m;\n\t\t\t\tz=i2d_X509_NAME(X509_get_subject_name(x),&d);\n\t\t\t\tBIO_printf(STDout,"unsigned char XXX_subject_name[%d]={\\n",z);\n\t\t\t\td=(unsigned char *)m;\n\t\t\t\tfor (y=0; y<z; y++)\n\t\t\t\t\t{\n\t\t\t\t\tBIO_printf(STDout,"0x%02X,",d[y]);\n\t\t\t\t\tif ((y & 0x0f) == 0x0f) BIO_printf(STDout,"\\n");\n\t\t\t\t\t}\n\t\t\t\tif (y%16 != 0) BIO_printf(STDout,"\\n");\n\t\t\t\tBIO_printf(STDout,"};\\n");\n\t\t\t\tz=i2d_X509_PUBKEY(X509_get_X509_PUBKEY(x),&d);\n\t\t\t\tBIO_printf(STDout,"unsigned char XXX_public_key[%d]={\\n",z);\n\t\t\t\td=(unsigned char *)m;\n\t\t\t\tfor (y=0; y<z; y++)\n\t\t\t\t\t{\n\t\t\t\t\tBIO_printf(STDout,"0x%02X,",d[y]);\n\t\t\t\t\tif ((y & 0x0f) == 0x0f)\n\t\t\t\t\t\tBIO_printf(STDout,"\\n");\n\t\t\t\t\t}\n\t\t\t\tif (y%16 != 0) BIO_printf(STDout,"\\n");\n\t\t\t\tBIO_printf(STDout,"};\\n");\n\t\t\t\tz=i2d_X509(x,&d);\n\t\t\t\tBIO_printf(STDout,"unsigned char XXX_certificate[%d]={\\n",z);\n\t\t\t\td=(unsigned char *)m;\n\t\t\t\tfor (y=0; y<z; y++)\n\t\t\t\t\t{\n\t\t\t\t\tBIO_printf(STDout,"0x%02X,",d[y]);\n\t\t\t\t\tif ((y & 0x0f) == 0x0f)\n\t\t\t\t\t\tBIO_printf(STDout,"\\n");\n\t\t\t\t\t}\n\t\t\t\tif (y%16 != 0) BIO_printf(STDout,"\\n");\n\t\t\t\tBIO_printf(STDout,"};\\n");\n\t\t\t\tFree(m);\n\t\t\t\t}\n\t\t\telse if (text == i)\n\t\t\t\t{\n\t\t\t\tX509_print(out,x);\n\t\t\t\t}\n\t\t\telse if (startdate == i)\n\t\t\t\t{\n\t\t\t\tBIO_puts(STDout,"notBefore=");\n\t\t\t\tASN1_TIME_print(STDout,X509_get_notBefore(x));\n\t\t\t\tBIO_puts(STDout,"\\n");\n\t\t\t\t}\n\t\t\telse if (enddate == i)\n\t\t\t\t{\n\t\t\t\tBIO_puts(STDout,"notAfter=");\n\t\t\t\tASN1_TIME_print(STDout,X509_get_notAfter(x));\n\t\t\t\tBIO_puts(STDout,"\\n");\n\t\t\t\t}\n\t\t\telse if (fingerprint == i)\n\t\t\t\t{\n\t\t\t\tint j;\n\t\t\t\tunsigned int n;\n\t\t\t\tunsigned char md[EVP_MAX_MD_SIZE];\n\t\t\t\tif (!X509_digest(x,EVP_md5(),md,&n))\n\t\t\t\t\t{\n\t\t\t\t\tBIO_printf(bio_err,"out of memory\\n");\n\t\t\t\t\tgoto end;\n\t\t\t\t\t}\n\t\t\t\tBIO_printf(STDout,"MD5 Fingerprint=");\n\t\t\t\tfor (j=0; j<(int)n; j++)\n\t\t\t\t\t{\n\t\t\t\t\tBIO_printf(STDout,"%02X%c",md[j],\n\t\t\t\t\t\t(j+1 == (int)n)\n\t\t\t\t\t\t?\'\\n\':\':\');\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\telse if ((sign_flag == i) && (x509req == 0))\n\t\t\t\t{\n\t\t\t\tBIO_printf(bio_err,"Getting Private key\\n");\n\t\t\t\tif (Upkey == NULL)\n\t\t\t\t\t{\n\t\t\t\t\tUpkey=load_key(keyfile,keyformat);\n\t\t\t\t\tif (Upkey == NULL) goto end;\n\t\t\t\t\t}\n#ifndef NO_DSA\n\t\t                if (Upkey->type == EVP_PKEY_DSA)\n\t\t                        digest=EVP_dss1();\n#endif\n\t\t\t\tif (!sign(x,Upkey,days,digest,\n\t\t\t\t\t\t extconf, extsect)) goto end;\n\t\t\t\t}\n\t\t\telse if (CA_flag == i)\n\t\t\t\t{\n\t\t\t\tBIO_printf(bio_err,"Getting CA Private Key\\n");\n\t\t\t\tif (CAkeyfile != NULL)\n\t\t\t\t\t{\n\t\t\t\t\tCApkey=load_key(CAkeyfile,CAkeyformat);\n\t\t\t\t\tif (CApkey == NULL) goto end;\n\t\t\t\t\t}\n#ifndef NO_DSA\n\t\t                if (CApkey->type == EVP_PKEY_DSA)\n\t\t                        digest=EVP_dss1();\n#endif\n\t\t\t\tif (!x509_certify(ctx,CAfile,digest,x,xca,\n\t\t\t\t\tCApkey, CAserial,CA_createserial,days,\n\t\t\t\t\textconf, extsect))\n\t\t\t\t\tgoto end;\n\t\t\t\t}\n\t\t\telse if (x509req == i)\n\t\t\t\t{\n\t\t\t\tEVP_PKEY *pk;\n\t\t\t\tBIO_printf(bio_err,"Getting request Private Key\\n");\n\t\t\t\tif (keyfile == NULL)\n\t\t\t\t\t{\n\t\t\t\t\tBIO_printf(bio_err,"no request key file specified\\n");\n\t\t\t\t\tgoto end;\n\t\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\tpk=load_key(keyfile,FORMAT_PEM);\n\t\t\t\t\tif (pk == NULL) goto end;\n\t\t\t\t\t}\n\t\t\t\tBIO_printf(bio_err,"Generating certificate request\\n");\n\t\t\t\trq=X509_to_X509_REQ(x,pk,EVP_md5());\n\t\t\t\tEVP_PKEY_free(pk);\n\t\t\t\tif (rq == NULL)\n\t\t\t\t\t{\n\t\t\t\t\tERR_print_errors(bio_err);\n\t\t\t\t\tgoto end;\n\t\t\t\t\t}\n\t\t\t\tif (!noout)\n\t\t\t\t\t{\n\t\t\t\t\tX509_REQ_print(out,rq);\n\t\t\t\t\tPEM_write_bio_X509_REQ(out,rq);\n\t\t\t\t\t}\n\t\t\t\tnoout=1;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\tif (noout)\n\t\t{\n\t\tret=0;\n\t\tgoto end;\n\t\t}\n\tif \t(outformat == FORMAT_ASN1)\n\t\ti=i2d_X509_bio(out,x);\n\telse if (outformat == FORMAT_PEM)\n\t\ti=PEM_write_bio_X509(out,x);\n\telse if (outformat == FORMAT_NETSCAPE)\n\t\t{\n\t\tASN1_HEADER ah;\n\t\tASN1_OCTET_STRING os;\n\t\tos.data=(unsigned char *)CERT_HDR;\n\t\tos.length=strlen(CERT_HDR);\n\t\tah.header= &os;\n\t\tah.data=(char *)x;\n\t\tah.meth=X509_asn1_meth();\n\t\ti=ASN1_i2d_bio(i2d_ASN1_HEADER,out,(unsigned char *)&ah);\n\t\t}\n\telse\t{\n\t\tBIO_printf(bio_err,"bad output format specified for outfile\\n");\n\t\tgoto end;\n\t\t}\n\tif (!i) {\n\t\tBIO_printf(bio_err,"unable to write certificate\\n");\n\t\tERR_print_errors(bio_err);\n\t\tgoto end;\n\t\t}\n\tret=0;\nend:\n\tOBJ_cleanup();\n\tCONF_free(extconf);\n\tBIO_free(out);\n\tBIO_free(STDout);\n\tX509_STORE_free(ctx);\n\tX509_REQ_free(req);\n\tX509_free(x);\n\tX509_free(xca);\n\tEVP_PKEY_free(Upkey);\n\tEVP_PKEY_free(CApkey);\n\tX509_REQ_free(rq);\n\tX509V3_EXT_cleanup();\n\tEXIT(ret);\n\t}', 'LHASH *CONF_load(LHASH *h, const char *file, long *line)\n\t{\n\tLHASH *ltmp;\n\tFILE *in=NULL;\n#ifdef VMS\n\tin=fopen(file,"r");\n#else\n\tin=fopen(file,"rb");\n#endif\n\tif (in == NULL)\n\t\t{\n\t\tSYSerr(SYS_F_FOPEN,get_last_sys_error());\n\t\tERR_set_error_data(BUF_strdup(file),\n\t\t\tERR_TXT_MALLOCED|ERR_TXT_STRING);\n\t\tCONFerr(CONF_F_CONF_LOAD,ERR_R_SYS_LIB);\n\t\treturn NULL;\n\t\t}\n\tltmp = CONF_load_fp(h, in, line);\n\tfclose(in);\n\treturn ltmp;\n}', 'LHASH *CONF_load_fp(LHASH *h, FILE *in, long *line)\n{\n\tBIO *btmp;\n\tLHASH *ltmp;\n\tif(!(btmp = BIO_new_fp(in, BIO_NOCLOSE))) {\n\t\tCONFerr(CONF_F_CONF_LOAD_FP,ERR_R_BUF_LIB);\n\t\treturn NULL;\n\t}\n\tltmp = CONF_load_bio(h, btmp, line);\n\tBIO_free(btmp);\n\treturn ltmp;\n}', 'LHASH *CONF_load_bio(LHASH *h, BIO *in, long *line)\n\t{\n\tLHASH *ret=NULL;\n#define BUFSIZE\t512\n\tchar btmp[16];\n\tint bufnum=0,i,ii;\n\tBUF_MEM *buff=NULL;\n\tchar *s,*p,*end;\n\tint again,n;\n\tlong eline=0;\n\tCONF_VALUE *v=NULL,*vv,*tv;\n\tCONF_VALUE *sv=NULL;\n\tchar *section=NULL,*buf;\n\tSTACK_OF(CONF_VALUE) *section_sk=NULL,*ts;\n\tchar *start,*psection,*pname;\n\tif ((buff=BUF_MEM_new()) == NULL)\n\t\t{\n\t\tCONFerr(CONF_F_CONF_LOAD_BIO,ERR_R_BUF_LIB);\n\t\tgoto err;\n\t\t}\n\tsection=(char *)Malloc(10);\n\tif (section == NULL)\n\t\t{\n\t\tCONFerr(CONF_F_CONF_LOAD_BIO,ERR_R_MALLOC_FAILURE);\n\t\tgoto err;\n\t\t}\n\tstrcpy(section,"default");\n\tif (h == NULL)\n\t\t{\n\t\tif ((ret=lh_new(hash,cmp_conf)) == NULL)\n\t\t\t{\n\t\t\tCONFerr(CONF_F_CONF_LOAD_BIO,ERR_R_MALLOC_FAILURE);\n\t\t\tgoto err;\n\t\t\t}\n\t\t}\n\telse\n\t\tret=h;\n\tsv=new_section(ret,section);\n\tif (sv == NULL)\n\t\t{\n\t\tCONFerr(CONF_F_CONF_LOAD_BIO,\n\t\t\t\t\tCONF_R_UNABLE_TO_CREATE_NEW_SECTION);\n\t\tgoto err;\n\t\t}\n\tsection_sk=(STACK_OF(CONF_VALUE) *)sv->value;\n\tbufnum=0;\n\tfor (;;)\n\t\t{\n\t\tagain=0;\n\t\tif (!BUF_MEM_grow(buff,bufnum+BUFSIZE))\n\t\t\t{\n\t\t\tCONFerr(CONF_F_CONF_LOAD_BIO,ERR_R_BUF_LIB);\n\t\t\tgoto err;\n\t\t\t}\n\t\tp= &(buff->data[bufnum]);\n\t\t*p=\'\\0\';\n\t\tBIO_gets(in, p, BUFSIZE-1);\n\t\tp[BUFSIZE-1]=\'\\0\';\n\t\tii=i=strlen(p);\n\t\tif (i == 0) break;\n\t\twhile (i > 0)\n\t\t\t{\n\t\t\tif ((p[i-1] != \'\\r\') && (p[i-1] != \'\\n\'))\n\t\t\t\tbreak;\n\t\t\telse\n\t\t\t\ti--;\n\t\t\t}\n\t\tif (i == ii)\n\t\t\tagain=1;\n\t\telse\n\t\t\t{\n\t\t\tp[i]=\'\\0\';\n\t\t\teline++;\n\t\t\t}\n\t\tbufnum+=i;\n\t\tv=NULL;\n\t\tif (bufnum >= 1)\n\t\t\t{\n\t\t\tp= &(buff->data[bufnum-1]);\n\t\t\tif (\tIS_ESC(p[0]) &&\n\t\t\t\t((bufnum <= 1) || !IS_ESC(p[-1])))\n\t\t\t\t{\n\t\t\t\tbufnum--;\n\t\t\t\tagain=1;\n\t\t\t\t}\n\t\t\t}\n\t\tif (again) continue;\n\t\tbufnum=0;\n\t\tbuf=buff->data;\n\t\tclear_comments(buf);\n\t\tn=strlen(buf);\n\t\ts=eat_ws(buf);\n\t\tif (IS_EOF(*s)) continue;\n\t\tif (*s == \'[\')\n\t\t\t{\n\t\t\tchar *ss;\n\t\t\ts++;\n\t\t\tstart=eat_ws(s);\n\t\t\tss=start;\nagain:\n\t\t\tend=eat_alpha_numeric(ss);\n\t\t\tp=eat_ws(end);\n\t\t\tif (*p != \']\')\n\t\t\t\t{\n\t\t\t\tif (*p != \'\\0\')\n\t\t\t\t\t{\n\t\t\t\t\tss=p;\n\t\t\t\t\tgoto again;\n\t\t\t\t\t}\n\t\t\t\tCONFerr(CONF_F_CONF_LOAD_BIO,\n\t\t\t\t\tCONF_R_MISSING_CLOSE_SQUARE_BRACKET);\n\t\t\t\tgoto err;\n\t\t\t\t}\n\t\t\t*end=\'\\0\';\n\t\t\tif (!str_copy(ret,NULL,&section,start)) goto err;\n\t\t\tif ((sv=get_section(ret,section)) == NULL)\n\t\t\t\tsv=new_section(ret,section);\n\t\t\tif (sv == NULL)\n\t\t\t\t{\n\t\t\t\tCONFerr(CONF_F_CONF_LOAD_BIO,\n\t\t\t\t\tCONF_R_UNABLE_TO_CREATE_NEW_SECTION);\n\t\t\t\tgoto err;\n\t\t\t\t}\n\t\t\tsection_sk=(STACK_OF(CONF_VALUE) *)sv->value;\n\t\t\tcontinue;\n\t\t\t}\n\t\telse\n\t\t\t{\n\t\t\tpname=s;\n\t\t\tpsection=NULL;\n\t\t\tend=eat_alpha_numeric(s);\n\t\t\tif ((end[0] == \':\') && (end[1] == \':\'))\n\t\t\t\t{\n\t\t\t\t*end=\'\\0\';\n\t\t\t\tend+=2;\n\t\t\t\tpsection=pname;\n\t\t\t\tpname=end;\n\t\t\t\tend=eat_alpha_numeric(end);\n\t\t\t\t}\n\t\t\tp=eat_ws(end);\n\t\t\tif (*p != \'=\')\n\t\t\t\t{\n\t\t\t\tCONFerr(CONF_F_CONF_LOAD_BIO,\n\t\t\t\t\t\tCONF_R_MISSING_EQUAL_SIGN);\n\t\t\t\tgoto err;\n\t\t\t\t}\n\t\t\t*end=\'\\0\';\n\t\t\tp++;\n\t\t\tstart=eat_ws(p);\n\t\t\twhile (!IS_EOF(*p))\n\t\t\t\tp++;\n\t\t\tp--;\n\t\t\twhile ((p != start) && (IS_WS(*p)))\n\t\t\t\tp--;\n\t\t\tp++;\n\t\t\t*p=\'\\0\';\n\t\t\tif (!(v=(CONF_VALUE *)Malloc(sizeof(CONF_VALUE))))\n\t\t\t\t{\n\t\t\t\tCONFerr(CONF_F_CONF_LOAD_BIO,\n\t\t\t\t\t\t\tERR_R_MALLOC_FAILURE);\n\t\t\t\tgoto err;\n\t\t\t\t}\n\t\t\tif (psection == NULL) psection=section;\n\t\t\tv->name=(char *)Malloc(strlen(pname)+1);\n\t\t\tv->value=NULL;\n\t\t\tif (v->name == NULL)\n\t\t\t\t{\n\t\t\t\tCONFerr(CONF_F_CONF_LOAD_BIO,\n\t\t\t\t\t\t\tERR_R_MALLOC_FAILURE);\n\t\t\t\tgoto err;\n\t\t\t\t}\n\t\t\tstrcpy(v->name,pname);\n\t\t\tif (!str_copy(ret,psection,&(v->value),start)) goto err;\n\t\t\tif (strcmp(psection,section) != 0)\n\t\t\t\t{\n\t\t\t\tif ((tv=get_section(ret,psection))\n\t\t\t\t\t== NULL)\n\t\t\t\t\ttv=new_section(ret,psection);\n\t\t\t\tif (tv == NULL)\n\t\t\t\t\t{\n\t\t\t\t\tCONFerr(CONF_F_CONF_LOAD_BIO,\n\t\t\t\t\t   CONF_R_UNABLE_TO_CREATE_NEW_SECTION);\n\t\t\t\t\tgoto err;\n\t\t\t\t\t}\n\t\t\t\tts=(STACK_OF(CONF_VALUE) *)tv->value;\n\t\t\t\t}\n\t\t\telse\n\t\t\t\t{\n\t\t\t\ttv=sv;\n\t\t\t\tts=section_sk;\n\t\t\t\t}\n\t\t\tv->section=tv->section;\n\t\t\tif (!sk_CONF_VALUE_push(ts,v))\n\t\t\t\t{\n\t\t\t\tCONFerr(CONF_F_CONF_LOAD_BIO,\n\t\t\t\t\t\t\tERR_R_MALLOC_FAILURE);\n\t\t\t\tgoto err;\n\t\t\t\t}\n\t\t\tvv=(CONF_VALUE *)lh_insert(ret,(char *)v);\n\t\t\tif (vv != NULL)\n\t\t\t\t{\n\t\t\t\tsk_CONF_VALUE_delete_ptr(ts,vv);\n\t\t\t\tFree(vv->name);\n\t\t\t\tFree(vv->value);\n\t\t\t\tFree(vv);\n\t\t\t\t}\n\t\t\tv=NULL;\n\t\t\t}\n\t\t}\n\tif (buff != NULL) BUF_MEM_free(buff);\n\tif (section != NULL) Free(section);\n\treturn(ret);\nerr:\n\tif (buff != NULL) BUF_MEM_free(buff);\n\tif (section != NULL) Free(section);\n\tif (line != NULL) *line=eline;\n\tsprintf(btmp,"%ld",eline);\n\tERR_add_error_data(2,"line ",btmp);\n\tif ((h != ret) && (ret != NULL)) CONF_free(ret);\n\tif (v != NULL)\n\t\t{\n\t\tif (v->name != NULL) Free(v->name);\n\t\tif (v->value != NULL) Free(v->value);\n\t\tif (v != NULL) Free(v);\n\t\t}\n\treturn(NULL);\n\t}', 'void CONF_free(LHASH *conf)\n\t{\n\tif (conf == NULL) return;\n\tconf->down_load=0;\n\tlh_doall_arg(conf,(void (*)())value_free_hash,(char *)conf);\n\tlh_doall_arg(conf,(void (*)())value_free_stack,(char *)conf);\n\tlh_free(conf);\n\t}', 'void lh_doall_arg(LHASH *lh, void (*func)(), char *arg)\n\t{\n\tint i;\n\tLHASH_NODE *a,*n;\n\tfor (i=lh->num_nodes-1; i>=0; i--)\n\t\t{\n\t\ta=lh->b[i];\n\t\twhile (a != NULL)\n\t\t\t{\n\t\t\tn=a->next;\n\t\t\tfunc(a->data,arg);\n\t\t\ta=n;\n\t\t\t}\n\t\t}\n\t}']