apps/srp.c:604: error: BUFFER_OVERRUN_L3
  Offset: [-1, +oo] Size: 2500 by call to `srp_create_user`.
Showing all 14 steps of the trace


apps/srp.c:426:2: Call
424.   
425.   #ifndef OPENSSL_NO_ENGINE
426.   	setup_engine(bio_err, engine, 0);
        ^
427.   #endif
428.   

apps/apps.c:1473:1: Parameter `engine->strlen`
  1471.   	}
  1472.   
  1473. > ENGINE *setup_engine(BIO *err, const char *engine, int debug)
  1474.           {
  1475.           ENGINE *e = NULL;

apps/srp.c:604:18: Call
602.   				row[DB_srpsalt] = NULL;
603.   				row[DB_srpinfo] = NULL;
604.   				if (!(gNid = srp_create_user(user,&(row[DB_srpverifier]), &(row[DB_srpsalt]),gNrow?gNrow[DB_srpsalt]:gN,gNrow?gNrow[DB_srpverifier]:NULL, passout, bio_err,verbose)))
                        ^
605.   					{
606.   						BIO_printf(bio_err, "Cannot create srp verifier for user \"%s\", operation abandoned .\n", user);

apps/srp.c:244:1: Parameter `g->strlen`
  242.   	}
  243.   
  244. > static char *srp_create_user(char *user, char **srp_verifier,
  245.   			     char **srp_usersalt, char *g, char *N,
  246.   			     char *passout, BIO *bio, int verbose)

apps/srp.c:258:15: Call
  256.   		{
  257.   		VERBOSE BIO_printf(bio,"Creating\n user=\"%s\"\n g=\"%s\"\n N=\"%s\"\n",user,g,N);
  258.   		if (!(gNid =SRP_create_verifier(user, password, &salt, srp_verifier, N, g)))
                       ^
  259.   			{
  260.   			BIO_printf(bio,"Internal error creating SRP verifier\n");

crypto/srp/srp_vfy.c:524:1: Array declaration
    522.      create a verifier (*salt,*verifier,g and N are in base64)
    523.   */
    524. > char *SRP_create_verifier(const char *user, const char *pass, char **salt,
    525.   						  char **verifier, const char *N, const char *g)
    526.   	{

crypto/srp/srp_vfy.c:545:15: Call
    543.   		if (!(len = t_fromb64(tmp, N))) goto err;
    544.   		N_bn = BN_bin2bn(tmp, len, NULL);
    545.   		if (!(len = t_fromb64(tmp, g))) goto err;
                         ^
    546.   		g_bn = BN_bin2bn(tmp, len, NULL);
    547.   		defgNid = "*";

crypto/srp/srp_vfy.c:88:2: <Offset trace>
86.   		++src;
87.   	size = strlen(src);
88.   	i = 0;
       ^
89.   	while(i < size)
90.   		{

crypto/srp/srp_vfy.c:88:2: Assignment
      86.   		++src;
      87.   	size = strlen(src);
      88.   	i = 0;
             ^
      89.   	while(i < size)
      90.   		{

crypto/srp/srp_vfy.c:96:2: Assignment
      94.   		++i;
      95.   		}
      96.   	size = i;
             ^
      97.   	i = size - 1;
      98.   	j = size;

crypto/srp/srp_vfy.c:97:2: Assignment
      95.   		}
      96.   	size = i;
      97.   	i = size - 1;
              ^
      98.   	j = size;
      99.   	while(1)

crypto/srp/srp_vfy.c:79:1: <Length trace>
77.    * Convert a base64 string into raw byte array representation.
78.    */
79. > static int t_fromb64(unsigned char *a, const char *src)
80.   	{
81.   	char *loc;

crypto/srp/srp_vfy.c:79:1: Parameter `*a`
      77.    * Convert a base64 string into raw byte array representation.
      78.    */
      79. > static int t_fromb64(unsigned char *a, const char *src)
      80.   	{
      81.   	char *loc;

crypto/srp/srp_vfy.c:101:10: Array access: Offset: [-1, +oo] Size: 2500 by call to `srp_create_user` 
      99.   	while(1)
      100.   		{
      101.   		a[j] = a[i];
                      ^
      102.   		if(--i < 0) break;
      103.   		a[j] |= (a[i] & 3) << 6;

static int t_fromb64(unsigned char *a, const char *src)
	{
	char *loc;
	int i, j;
	int size;
	while(*src && (*src == ' ' || *src == '\t' || *src == '\n'))
		++src;
	size = strlen(src);
	i = 0;
	while(i < size)
		{
		loc = strchr(b64table, src[i]);
		if(loc == (char *) 0) break;
		else a[i] = loc - b64table;
		++i;
		}
	size = i;
	i = size - 1;
	j = size;
	while(1)
		{
		a[j] = a[i];
		if(--i < 0) break;
		a[j] |= (a[i] & 3) << 6;
		--j;
		a[j] = (unsigned char) ((a[i] & 0x3c) >> 2);
		if(--i < 0) break;
		a[j] |= (a[i] & 0xf) << 4;
		--j;
		a[j] = (unsigned char) ((a[i] & 0x30) >> 4);
		if(--i < 0) break;
		a[j] |= (a[i] << 2);
		a[--j] = 0;
		if(--i < 0) break;
		}
	while(a[j] == 0 && j <= size) ++j;
	i = 0;
	while (j <= size) a[i++] = a[j++];
	return i;
	}
['int MAIN(int argc, char **argv)\n\t{\n\tint add_user = 0;\n\tint list_user= 0;\n\tint delete_user= 0;\n\tint modify_user= 0;\n\tchar * user = NULL;\n\tchar *passargin = NULL, *passargout = NULL;\n\tchar *passin = NULL, *passout = NULL;\n        char * gN = NULL;\n\tint gNindex = -1;\n\tchar ** gNrow = NULL;\n\tint maxgN = -1;\n\tchar * userinfo = NULL;\n\tint badops=0;\n\tint ret=1;\n\tint errors=0;\n\tint verbose=0;\n\tint doupdatedb=0;\n\tchar *configfile=NULL;\n\tchar *dbfile=NULL;\n\tCA_DB *db=NULL;\n\tchar **pp ;\n\tint i;\n\tlong errorline = -1;\n\tchar *randfile=NULL;\n#ifndef OPENSSL_NO_ENGINE\n\tchar *engine = NULL;\n#endif\n\tchar *tofree=NULL;\n\tDB_ATTR db_attr;\n#ifdef EFENCE\nEF_PROTECT_FREE=1;\nEF_PROTECT_BELOW=1;\nEF_ALIGNMENT=0;\n#endif\n\tapps_startup();\n\tconf = NULL;\n\tsection = NULL;\n\tif (bio_err == NULL)\n\t\tif ((bio_err=BIO_new(BIO_s_file())) != NULL)\n\t\t\tBIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT);\n\targc--;\n\targv++;\n\twhile (argc >= 1 && badops == 0)\n\t\t{\n\t\tif\t(strcmp(*argv,"-verbose") == 0)\n\t\t\tverbose++;\n\t\telse if\t(strcmp(*argv,"-config") == 0)\n\t\t\t{\n\t\t\tif (--argc < 1) goto bad;\n\t\t\tconfigfile= *(++argv);\n\t\t\t}\n\t\telse if (strcmp(*argv,"-name") == 0)\n\t\t\t{\n\t\t\tif (--argc < 1) goto bad;\n\t\t\tsection= *(++argv);\n\t\t\t}\n\t\telse if\t(strcmp(*argv,"-srpvfile") == 0)\n\t\t\t{\n\t\t\tif (--argc < 1) goto bad;\n\t\t\tdbfile= *(++argv);\n\t\t\t}\n\t\telse if (strcmp(*argv,"-add") == 0)\n\t\t\tadd_user=1;\n\t\telse if (strcmp(*argv,"-delete") == 0)\n\t\t\tdelete_user=1;\n\t\telse if (strcmp(*argv,"-modify") == 0)\n\t\t\tmodify_user=1;\n\t\telse if (strcmp(*argv,"-list") == 0)\n\t\t\tlist_user=1;\n\t\telse if (strcmp(*argv,"-gn") == 0)\n\t\t\t{\n\t\t\tif (--argc < 1) goto bad;\n\t\t\tgN= *(++argv);\n\t\t\t}\n\t\telse if (strcmp(*argv,"-userinfo") == 0)\n\t\t\t{\n\t\t\tif (--argc < 1) goto bad;\n\t\t\tuserinfo= *(++argv);\n\t\t\t}\n\t\telse if (strcmp(*argv,"-passin") == 0)\n\t\t\t{\n\t\t\tif (--argc < 1) goto bad;\n\t\t\tpassargin= *(++argv);\n\t\t\t}\n\t\telse if (strcmp(*argv,"-passout") == 0)\n\t\t\t{\n\t\t\tif (--argc < 1) goto bad;\n\t\t\tpassargout= *(++argv);\n\t\t\t}\n#ifndef OPENSSL_NO_ENGINE\n\t\telse if (strcmp(*argv,"-engine") == 0)\n\t\t\t{\n\t\t\tif (--argc < 1) goto bad;\n\t\t\tengine= *(++argv);\n\t\t\t}\n#endif\n\t\telse if (**argv == \'-\')\n\t\t\t{\nbad:\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\telse\n\t\t\tbreak;\n\t\targc--;\n\t\targv++;\n\t\t}\n\tif (dbfile && configfile)\n\t\t{\n\t\tBIO_printf(bio_err,"-dbfile and -configfile cannot be specified together.\\n");\n\t\tbadops = 1;\n\t\t}\n\tif (add_user+delete_user+modify_user+list_user != 1)\n\t\t{\n\t\tBIO_printf(bio_err,"Exactly one of the options -add, -delete, -modify -list must be specified.\\n");\n\t\tbadops = 1;\n\t\t}\n\tif (delete_user+modify_user+delete_user== 1 && argc <= 0)\n\t\t{\n\t\tBIO_printf(bio_err,"Need at least one user for options -add, -delete, -modify. \\n");\n\t\tbadops = 1;\n\t\t}\n\tif ((passin || passout) && argc != 1 )\n\t\t{\n\t\tBIO_printf(bio_err,"-passin, -passout arguments only valid with one user.\\n");\n\t\tbadops = 1;\n\t\t}\n\tif (badops)\n\t\t{\n\t\tfor (pp=srp_usage; (*pp != NULL); pp++)\n\t\t\tBIO_printf(bio_err,"%s",*pp);\n\t\tBIO_printf(bio_err," -rand file%cfile%c...\\n", LIST_SEPARATOR_CHAR, LIST_SEPARATOR_CHAR);\n\t\tBIO_printf(bio_err,"                 load the file (or the files in the directory) into\\n");\n\t\tBIO_printf(bio_err,"                 the random number generator\\n");\n\t\tgoto err;\n\t\t}\n\tERR_load_crypto_strings();\n#ifndef OPENSSL_NO_ENGINE\n\tsetup_engine(bio_err, engine, 0);\n#endif\n\tif(!app_passwd(bio_err, passargin, passargout, &passin, &passout))\n\t\t{\n\t\tBIO_printf(bio_err, "Error getting passwords\\n");\n\t\tgoto err;\n\t\t}\n        if (!dbfile)\n\t\t{\n\t\ttofree=NULL;\n\t\tif (configfile == NULL) configfile = getenv("OPENSSL_CONF");\n\t\tif (configfile == NULL) configfile = getenv("SSLEAY_CONF");\n\t\tif (configfile == NULL)\n\t\t\t{\n\t\t\tconst char *s=X509_get_default_cert_area();\n\t\t\tsize_t len;\n#ifdef OPENSSL_SYS_VMS\n\t\t\tlen = strlen(s)+sizeof(CONFIG_FILE);\n\t\t\ttofree=OPENSSL_malloc(len);\n\t\t\tstrcpy(tofree,s);\n#else\n\t\t\tlen = strlen(s)+sizeof(CONFIG_FILE)+1;\n\t\t\ttofree=OPENSSL_malloc(len);\n\t\t\tBUF_strlcpy(tofree,s,len);\n\t\t\tBUF_strlcat(tofree,"/",len);\n#endif\n\t\t\tBUF_strlcat(tofree,CONFIG_FILE,len);\n\t\t\tconfigfile=tofree;\n\t\t\t}\n\t\tVERBOSE BIO_printf(bio_err,"Using configuration from %s\\n",configfile);\n\t\tconf = NCONF_new(NULL);\n\t\tif (NCONF_load(conf,configfile,&errorline) <= 0)\n\t\t\t{\n\t\t\tif (errorline <= 0)\n\t\t\t\tBIO_printf(bio_err,"error loading the config file \'%s\'\\n",\n\t\t\t\t\tconfigfile);\n\t\t\telse\n\t\t\t\tBIO_printf(bio_err,"error on line %ld of config file \'%s\'\\n"\n\t\t\t\t\t,errorline,configfile);\n\t\t\tgoto err;\n\t\t\t}\n\t\tif(tofree)\n\t\t\t{\n\t\t\tOPENSSL_free(tofree);\n\t\t\ttofree = NULL;\n\t\t\t}\n\t\tif (!load_config(bio_err, conf))\n\t\t\tgoto err;\n\t\tif (section == NULL)\n\t\t\t{\n\t\t\tVERBOSE BIO_printf(bio_err,"trying to read " ENV_DEFAULT_SRP " in \\" BASE_SECTION \\"\\n");\n\t\t\tsection=NCONF_get_string(conf,BASE_SECTION,ENV_DEFAULT_SRP);\n\t\t\tif (section == NULL)\n\t\t\t\t{\n\t\t\t\tlookup_fail(BASE_SECTION,ENV_DEFAULT_SRP);\n\t\t\t\tgoto err;\n\t\t\t\t}\n\t\t\t}\n\t\tif (randfile == NULL && conf)\n\t        \trandfile = NCONF_get_string(conf, BASE_SECTION, "RANDFILE");\n\t\tVERBOSE BIO_printf(bio_err,"trying to read " ENV_DATABASE " in section \\"%s\\"\\n",section);\n\t\tif ((dbfile=NCONF_get_string(conf,section,ENV_DATABASE)) == NULL)\n\t\t\t{\n\t\t\tlookup_fail(section,ENV_DATABASE);\n\t\t\tgoto err;\n\t\t\t}\n        \t}\n\tif (randfile == NULL)\n\t\tERR_clear_error();\n       \telse\n\t\tapp_RAND_load_file(randfile, bio_err, 0);\n\tVERBOSE BIO_printf(bio_err,"Trying to read SRP verifier file \\"%s\\"\\n",dbfile);\n\tdb = load_index(dbfile, &db_attr);\n\tif (db == NULL) goto err;\n\tfor (i = 0; i < sk_OPENSSL_PSTRING_num(db->db->data); i++)\n\t\t{\n\t\tpp = sk_OPENSSL_PSTRING_value(db->db->data, i);\n\t\tif (pp[DB_srptype][0] == DB_SRP_INDEX)\n\t\t\t{\n\t\t\tmaxgN = i;\n\t\t\tif (gNindex < 0 && gN != NULL && !strcmp(gN, pp[DB_srpid]))\n\t\t\t\tgNindex = i;\n\t\t\tprint_index(db, bio_err, i, verbose > 1);\n\t\t\t}\n\t\t}\n\tVERBOSE BIO_printf(bio_err, "Database initialised\\n");\n\tif (gNindex >= 0)\n\t\t{\n\t\tgNrow = sk_OPENSSL_PSTRING_value(db->db->data,gNindex);\n\t\tprint_entry(db, bio_err, gNindex, verbose > 1, "Default g and N");\n\t\t}\n\telse if (maxgN > 0 && !SRP_get_default_gN(gN))\n\t\t{\n\t\tBIO_printf(bio_err, "No g and N value for index \\"%s\\"\\n", gN);\n\t\tgoto err;\n\t\t}\n\telse\n\t\t{\n\t\tVERBOSE BIO_printf(bio_err, "Database has no g N information.\\n");\n\t\tgNrow = NULL;\n\t\t}\n\tVVERBOSE BIO_printf(bio_err,"Starting user processing\\n");\n\tif (argc > 0)\n\t\tuser = *(argv++) ;\n\twhile (list_user || user)\n\t\t{\n\t\tint userindex = -1;\n\t\tif (user)\n\t\t\tVVERBOSE BIO_printf(bio_err, "Processing user \\"%s\\"\\n", user);\n\t\tif ((userindex = get_index(db, user, \'U\')) >= 0)\n\t\t\t{\n\t\t\tprint_user(db, bio_err, userindex, (verbose > 0) || list_user);\n\t\t\t}\n\t\tif (list_user)\n\t\t\t{\n\t\t\tif (user == NULL)\n\t\t\t\t{\n\t\t\t\tBIO_printf(bio_err,"List all users\\n");\n\t\t\t\tfor (i = 0; i < sk_OPENSSL_PSTRING_num(db->db->data); i++)\n\t\t\t\t\t{\n\t\t\t\t\tprint_user(db,bio_err, i, 1);\n\t\t\t\t\t}\n\t\t\t\tlist_user = 0;\n\t\t\t\t}\n\t\t\telse if (userindex < 0)\n\t\t\t\t{\n\t\t\t\tBIO_printf(bio_err, "user \\"%s\\" does not exist, ignored. t\\n",\n\t\t\t\t\t   user);\n\t\t\t\terrors++;\n\t\t\t\t}\n\t\t\t}\n\t\telse if (add_user)\n\t\t\t{\n\t\t\tif (userindex >= 0)\n\t\t\t\t{\n\t\t\t\tchar **row = sk_OPENSSL_PSTRING_value(db->db->data, userindex);\n\t\t\t\tBIO_printf(bio_err, "user \\"%s\\" reactivated.\\n", user);\n\t\t\t\trow[DB_srptype][0] = \'V\';\n\t\t\t\tdoupdatedb = 1;\n\t\t\t\t}\n\t\t\telse\n\t\t\t\t{\n\t\t\t\tchar *row[DB_NUMBER] ; char *gNid;\n\t\t\t\trow[DB_srpverifier] = NULL;\n\t\t\t\trow[DB_srpsalt] = NULL;\n\t\t\t\trow[DB_srpinfo] = NULL;\n\t\t\t\tif (!(gNid = srp_create_user(user,&(row[DB_srpverifier]), &(row[DB_srpsalt]),gNrow?gNrow[DB_srpsalt]:gN,gNrow?gNrow[DB_srpverifier]:NULL, passout, bio_err,verbose)))\n\t\t\t\t\t{\n\t\t\t\t\t\tBIO_printf(bio_err, "Cannot create srp verifier for user \\"%s\\", operation abandoned .\\n", user);\n\t\t\t\t\t\terrors++;\n\t\t\t\t\t\tgoto err;\n\t\t\t\t\t}\n\t\t\t\trow[DB_srpid] = BUF_strdup(user);\n\t\t\t\trow[DB_srptype] = BUF_strdup("v");\n\t\t\t\trow[DB_srpgN] = BUF_strdup(gNid);\n\t\t\t\tif (!row[DB_srpid] || !row[DB_srpgN] || !row[DB_srptype] || !row[DB_srpverifier] || !row[DB_srpsalt] ||\n\t\t\t\t\t(userinfo && (!(row[DB_srpinfo] = BUF_strdup(userinfo)))) ||\n\t\t\t\t\t!update_index(db, bio_err, row))\n\t\t\t\t\t{\n\t\t\t\t\tif (row[DB_srpid]) OPENSSL_free(row[DB_srpid]);\n\t\t\t\t\tif (row[DB_srpgN]) OPENSSL_free(row[DB_srpgN]);\n\t\t\t\t\tif (row[DB_srpinfo]) OPENSSL_free(row[DB_srpinfo]);\n\t\t\t\t\tif (row[DB_srptype]) OPENSSL_free(row[DB_srptype]);\n\t\t\t\t\tif (row[DB_srpverifier]) OPENSSL_free(row[DB_srpverifier]);\n\t\t\t\t\tif (row[DB_srpsalt]) OPENSSL_free(row[DB_srpsalt]);\n\t\t\t\t\tgoto err;\n\t\t\t\t\t}\n\t\t\t\tdoupdatedb = 1;\n\t\t\t\t}\n\t\t\t}\n\t\telse if (modify_user)\n\t\t\t{\n\t\t\tif (userindex < 0)\n\t\t\t\t{\n\t\t\t\tBIO_printf(bio_err,"user \\"%s\\" does not exist, operation ignored.\\n",user);\n\t\t\t\terrors++;\n\t\t\t\t}\n\t\t\telse\n\t\t\t\t{\n\t\t\t\tchar **row = sk_OPENSSL_PSTRING_value(db->db->data, userindex);\n\t\t\t\tchar type = row[DB_srptype][0];\n\t\t\t\tif (type == \'v\')\n\t\t\t\t\t{\n\t\t\t\t\tBIO_printf(bio_err,"user \\"%s\\" already updated, operation ignored.\\n",user);\n\t\t\t\t\terrors++;\n\t\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\tchar *gNid;\n\t\t\t\t\tif (row[DB_srptype][0] == \'V\')\n\t\t\t\t\t\t{\n\t\t\t\t\t\tint user_gN;\n\t\t\t\t\t\tchar **irow = NULL;\n\t\t\t\t\t\tVERBOSE BIO_printf(bio_err,"Verifying password for user \\"%s\\"\\n",user);\n\t\t\t\t\t\tif ( (user_gN = get_index(db, row[DB_srpgN], DB_SRP_INDEX)) >= 0)\n\t\t\t\t\t\t\tirow = sk_OPENSSL_PSTRING_value(db->db->data, userindex);\n \t\t\t\t\t\tif (!srp_verify_user(user, row[DB_srpverifier], row[DB_srpsalt], irow ? irow[DB_srpsalt] : row[DB_srpgN], irow ? irow[DB_srpverifier] : NULL, passin, bio_err, verbose))\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\tBIO_printf(bio_err, "Invalid password for user \\"%s\\", operation abandoned.\\n", user);\n\t\t\t\t\t\t\terrors++;\n\t\t\t\t\t\t\tgoto err;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\tVERBOSE BIO_printf(bio_err,"Password for user \\"%s\\" ok.\\n",user);\n\t\t\t\t\tif (!(gNid=srp_create_user(user,&(row[DB_srpverifier]), &(row[DB_srpsalt]),gNrow?gNrow[DB_srpsalt]:NULL, gNrow?gNrow[DB_srpverifier]:NULL, passout, bio_err,verbose)))\n\t\t\t\t\t\t{\n\t\t\t\t\t\tBIO_printf(bio_err, "Cannot create srp verifier for user \\"%s\\", operation abandoned.\\n", user);\n\t\t\t\t\t\terrors++;\n\t\t\t\t\t\tgoto err;\n\t\t\t\t\t\t}\n\t\t\t\t\trow[DB_srptype][0] = \'v\';\n\t\t\t\t\trow[DB_srpgN] = BUF_strdup(gNid);\n\t\t\t\t\tif (!row[DB_srpid] || !row[DB_srpgN] || !row[DB_srptype] || !row[DB_srpverifier] || !row[DB_srpsalt] ||\n\t\t\t\t\t\t(userinfo && (!(row[DB_srpinfo] = BUF_strdup(userinfo)))))\n\t\t\t\t\t\tgoto err;\n\t\t\t\t\tdoupdatedb = 1;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\telse if (delete_user)\n\t\t\t{\n\t\t\tif (userindex < 0)\n\t\t\t\t{\n\t\t\t\tBIO_printf(bio_err, "user \\"%s\\" does not exist, operation ignored. t\\n", user);\n\t\t\t\terrors++;\n\t\t\t\t}\n\t\t\telse\n\t\t\t\t{\n\t\t\t\tchar **xpp = sk_OPENSSL_PSTRING_value(db->db->data,userindex);\n\t\t\t\tBIO_printf(bio_err, "user \\"%s\\" revoked. t\\n", user);\n\t\t\t\txpp[DB_srptype][0] = \'R\';\n\t\t\t\tdoupdatedb = 1;\n\t\t\t\t}\n\t\t\t}\n\t\tif (--argc > 0)\n\t\t\tuser = *(argv++) ;\n\t\telse\n\t\t\t{\n\t\t\tuser = NULL;\n\t\t\tlist_user = 0;\n\t\t\t}\n\t\t}\n\tVERBOSE BIO_printf(bio_err,"User procession done.\\n");\n\tif (doupdatedb)\n\t\t{\n\t\tfor (i = 0; i < sk_OPENSSL_PSTRING_num(db->db->data); i++)\n\t\t\t{\n\t\t\tpp = sk_OPENSSL_PSTRING_value(db->db->data,i);\n\t\t\tif (pp[DB_srptype][0] == \'v\')\n\t\t\t\t{\n\t\t\t\tpp[DB_srptype][0] = \'V\';\n\t\t\t\tprint_user(db, bio_err, i, verbose);\n\t\t\t\t}\n\t\t\t}\n\t\tVERBOSE BIO_printf(bio_err, "Trying to update srpvfile.\\n");\n\t\tif (!save_index(dbfile, "new", db)) goto err;\n\t\tVERBOSE BIO_printf(bio_err, "Temporary srpvfile created.\\n");\n\t\tif (!rotate_index(dbfile, "new", "old")) goto err;\n\t\tVERBOSE BIO_printf(bio_err, "srpvfile updated.\\n");\n\t\t}\n\tret = (errors != 0);\nerr:\n\tif (errors != 0)\n\tVERBOSE BIO_printf(bio_err,"User errors %d.\\n",errors);\n\tVERBOSE BIO_printf(bio_err,"SRP terminating with code %d.\\n",ret);\n\tif(tofree)\n\t\tOPENSSL_free(tofree);\n\tif (ret) ERR_print_errors(bio_err);\n\tif (randfile) app_RAND_write_file(randfile, bio_err);\n\tif (conf) NCONF_free(conf);\n\tif (db) free_index(db);\n\tOBJ_cleanup();\n\tapps_shutdown();\n\tOPENSSL_EXIT(ret);\n\t}', 'ENGINE *setup_engine(BIO *err, const char *engine, int debug)\n        {\n        ENGINE *e = NULL;\n        if (engine)\n                {\n\t\tif(strcmp(engine, "auto") == 0)\n\t\t\t{\n\t\t\tBIO_printf(err,"enabling auto ENGINE support\\n");\n\t\t\tENGINE_register_all_complete();\n\t\t\treturn NULL;\n\t\t\t}\n\t\tif((e = ENGINE_by_id(engine)) == NULL\n\t\t\t&& (e = try_load_engine(err, engine, debug)) == NULL)\n\t\t\t{\n\t\t\tBIO_printf(err,"invalid engine \\"%s\\"\\n", engine);\n\t\t\tERR_print_errors(err);\n\t\t\treturn NULL;\n\t\t\t}\n\t\tif (debug)\n\t\t\t{\n\t\t\tENGINE_ctrl(e, ENGINE_CTRL_SET_LOGSTREAM,\n\t\t\t\t0, err, 0);\n\t\t\t}\n                ENGINE_ctrl_cmd(e, "SET_USER_INTERFACE", 0, ui_method, 0, 1);\n\t\tif(!ENGINE_set_default(e, ENGINE_METHOD_ALL))\n\t\t\t{\n\t\t\tBIO_printf(err,"can\'t use that engine\\n");\n\t\t\tERR_print_errors(err);\n\t\t\tENGINE_free(e);\n\t\t\treturn NULL;\n\t\t\t}\n\t\tBIO_printf(err,"engine \\"%s\\" set.\\n", ENGINE_get_id(e));\n\t\tENGINE_free(e);\n\t\t}\n        return e;\n        }', 'static char *srp_create_user(char *user, char **srp_verifier,\n\t\t\t     char **srp_usersalt, char *g, char *N,\n\t\t\t     char *passout, BIO *bio, int verbose)\n\t{\n \tchar password[1024];\n        PW_CB_DATA cb_tmp;\n\tchar *gNid = NULL;\n\tchar *salt = NULL;\n        cb_tmp.prompt_info = user;\n        cb_tmp.password = passout;\n\tif (password_callback(password,1024,1,&cb_tmp) >0)\n\t\t{\n\t\tVERBOSE BIO_printf(bio,"Creating\\n user=\\"%s\\"\\n g=\\"%s\\"\\n N=\\"%s\\"\\n",user,g,N);\n\t\tif (!(gNid =SRP_create_verifier(user, password, &salt, srp_verifier, N, g)))\n\t\t\t{\n\t\t\tBIO_printf(bio,"Internal error creating SRP verifier\\n");\n\t\t\t}\n\t\telse\n\t\t\t*srp_usersalt = salt;\n\t\tVVERBOSE BIO_printf(bio,"gNid=%s salt =\\"%s\\"\\n verifier =\\"%s\\"\\n", gNid,salt, *srp_verifier);\n\t\t}\n\treturn gNid;\n\t}', 'char *SRP_create_verifier(const char *user, const char *pass, char **salt,\n\t\t\t\t\t\t  char **verifier, const char *N, const char *g)\n\t{\n\tint len;\n\tchar * result=NULL;\n\tchar *vf;\n\tBIGNUM *N_bn = NULL, *g_bn = NULL, *s = NULL, *v = NULL;\n\tunsigned char tmp[MAX_LEN];\n\tunsigned char tmp2[MAX_LEN];\n\tchar * defgNid = NULL;\n\tif ((user == NULL)||\n\t\t(pass == NULL)||\n\t\t(salt == NULL)||\n\t\t(verifier == NULL))\n\t\tgoto err;\n\tif (N)\n\t\t{\n\t\tif (!(len = t_fromb64(tmp, N))) goto err;\n\t\tN_bn = BN_bin2bn(tmp, len, NULL);\n\t\tif (!(len = t_fromb64(tmp, g))) goto err;\n\t\tg_bn = BN_bin2bn(tmp, len, NULL);\n\t\tdefgNid = "*";\n\t\t}\n\telse\n\t\t{\n\t\tSRP_gN * gN = SRP_get_gN_by_id(g, NULL) ;\n\t\tif (gN == NULL)\n\t\t\tgoto err;\n\t\tN_bn = gN->N;\n\t\tg_bn = gN->g;\n\t\tdefgNid = gN->id;\n\t\t}\n\tif (*salt == NULL)\n\t\t{\n\t\tRAND_pseudo_bytes(tmp2, SRP_RANDOM_SALT_LEN);\n\t\ts = BN_bin2bn(tmp2, SRP_RANDOM_SALT_LEN, NULL);\n\t\t}\n\telse\n\t\t{\n\t\tif (!(len = t_fromb64(tmp2, *salt)))\n\t\t\tgoto err;\n\t\ts = BN_bin2bn(tmp2, len, NULL);\n\t\t}\n\tif(!SRP_create_verifier_BN(user, pass, &s, &v, N_bn, g_bn)) goto err;\n\tBN_bn2bin(v,tmp);\n\tif (((vf = OPENSSL_malloc(BN_num_bytes(v)*2)) == NULL))\n\t\tgoto err;\n\tt_tob64(vf, tmp, BN_num_bytes(v));\n\t*verifier = vf;\n\tif (*salt == NULL)\n\t\t{\n\t\tchar *tmp_salt;\n\t\tif ((tmp_salt = OPENSSL_malloc(SRP_RANDOM_SALT_LEN * 2)) == NULL)\n\t\t\t{\n\t\t\tOPENSSL_free(vf);\n\t\t\tgoto err;\n\t\t\t}\n\t\tt_tob64(tmp_salt, tmp2, SRP_RANDOM_SALT_LEN);\n\t\t*salt = tmp_salt;\n\t\t}\n\tresult=defgNid;\nerr:\n\tif(N)\n\t\t{\n\t\tBN_free(N_bn);\n\t\tBN_free(g_bn);\n\t\t}\n\treturn result;\n\t}', "static int t_fromb64(unsigned char *a, const char *src)\n\t{\n\tchar *loc;\n\tint i, j;\n\tint size;\n\twhile(*src && (*src == ' ' || *src == '\\t' || *src == '\\n'))\n\t\t++src;\n\tsize = strlen(src);\n\ti = 0;\n\twhile(i < size)\n\t\t{\n\t\tloc = strchr(b64table, src[i]);\n\t\tif(loc == (char *) 0) break;\n\t\telse a[i] = loc - b64table;\n\t\t++i;\n\t\t}\n\tsize = i;\n\ti = size - 1;\n\tj = size;\n\twhile(1)\n\t\t{\n\t\ta[j] = a[i];\n\t\tif(--i < 0) break;\n\t\ta[j] |= (a[i] & 3) << 6;\n\t\t--j;\n\t\ta[j] = (unsigned char) ((a[i] & 0x3c) >> 2);\n\t\tif(--i < 0) break;\n\t\ta[j] |= (a[i] & 0xf) << 4;\n\t\t--j;\n\t\ta[j] = (unsigned char) ((a[i] & 0x30) >> 4);\n\t\tif(--i < 0) break;\n\t\ta[j] |= (a[i] << 2);\n\t\ta[--j] = 0;\n\t\tif(--i < 0) break;\n\t\t}\n\twhile(a[j] == 0 && j <= size) ++j;\n\ti = 0;\n\twhile (j <= size) a[i++] = a[j++];\n\treturn i;\n\t}"]