apps/pkcs12.c:260: error: BUFFER_OVERRUN_L2
  Offset added: [50, 8192] Size: 400 by call to `EVP_read_pw_string`.
Showing all 11 steps of the trace


apps/pkcs12.c:99:1: Array declaration
97.   #endif
98.   
99. > int MAIN(int argc, char **argv)
100.   {
101.       char *infile=NULL, *outfile=NULL, *keyname = NULL;	

apps/pkcs12.c:260:5: Call
258.       }
259.       if (twopass) {
260.   	if(EVP_read_pw_string (macpass, 50, "Enter MAC Password:", export_cert)) {
           ^
261.       	    BIO_printf (bio_err, "Can't read Password\n");
262.       	    goto end;

crypto/evp/evp_key.c:88:1: Parameter `len`
  86.   #endif
  87.   
  88. > int EVP_read_pw_string(char *buf, int len, const char *prompt, int verify)
  89.   	{
  90.   	if ((prompt == NULL) && (prompt_string[0] != '\0'))

crypto/evp/evp_key.c:92:9: Call
  90.   	if ((prompt == NULL) && (prompt_string[0] != '\0'))
  91.   		prompt=prompt_string;
  92.   	return(des_read_pw_string(buf,len,prompt,verify));
                ^
  93.   	}
  94.   

crypto/des/read_pwd.c:201:1: Parameter `*buf`
    199.   static jmp_buf save;
    200.   
    201. > int des_read_pw_string(char *buf, int length, const char *prompt,
    202.   	     int verify)
    203.   	{

crypto/des/read_pwd.c:207:6: Call
    205.   	int ret;
    206.   
    207.   	ret=des_read_pw(buf,buff,(length>BUFSIZ)?BUFSIZ:length,prompt,verify);
                ^
    208.   	memset(buff,0,BUFSIZ);
    209.   	return(ret);

crypto/des/read_pwd.c:226:1: <Offset trace>
224.   
225.   /* return 0 if ok, 1 (or -1) otherwise */
226. > int des_read_pw(char *buf, char *buff, int size, const char *prompt,
227.   	     int verify)
228.   	{

crypto/des/read_pwd.c:226:1: Parameter `size`
      224.   
      225.   /* return 0 if ok, 1 (or -1) otherwise */
      226. > int des_read_pw(char *buf, char *buff, int size, const char *prompt,
      227.   	     int verify)
      228.   	{

crypto/des/read_pwd.c:226:1: <Length trace>
224.   
225.   /* return 0 if ok, 1 (or -1) otherwise */
226. > int des_read_pw(char *buf, char *buff, int size, const char *prompt,
227.   	     int verify)
228.   	{

crypto/des/read_pwd.c:226:1: Parameter `*buf`
      224.   
      225.   /* return 0 if ok, 1 (or -1) otherwise */
      226. > int des_read_pw(char *buf, char *buff, int size, const char *prompt,
      227.   	     int verify)
      228.   	{

crypto/des/read_pwd.c:324:3: Array access: Offset added: [50, 8192] Size: 400 by call to `EVP_read_pw_string` 
      322.   
      323.   		buf[0]='\0';
      324.   		fgets(buf,size,tty);
               ^
      325.   		if (feof(tty)) goto error;
      326.   		if (ferror(tty)) goto error;

int des_read_pw(char *buf, char *buff, int size, const char *prompt,
	     int verify)
	{
#ifdef VMS
	struct IOSB iosb;
	$DESCRIPTOR(terminal,"TT");
	long tty_orig[3], tty_new[3];
	long status;
	unsigned short channel = 0;
#else
#ifndef MSDOS
	TTY_STRUCT tty_orig,tty_new;
#endif
#endif
	int number;
	int ok;
	static int ps;
	int is_a_tty;
	static FILE *tty;
	char *p;
	if (setjmp(save))
		{
		ok=0;
		goto error;
		}
	number=5;
	ok=0;
	ps=0;
	is_a_tty=1;
	tty=NULL;
#ifndef MSDOS
	if ((tty=fopen("/dev/tty","r")) == NULL)
		tty=stdin;
#else
	if ((tty=fopen("con","r")) == NULL)
		tty=stdin;
#endif
#if defined(TTY_get) && !defined(VMS)
	if (TTY_get(fileno(tty),&tty_orig) == -1)
		{
#ifdef ENOTTY
		if (errno == ENOTTY)
			is_a_tty=0;
		else
#endif
#ifdef EINVAL
		if (errno == EINVAL)
			is_a_tty=0;
		else
#endif
			return(-1);
		}
	memcpy(&(tty_new),&(tty_orig),sizeof(tty_orig));
#endif
#ifdef VMS
	status = SYS$ASSIGN(&terminal,&channel,0,0);
	if (status != SS$_NORMAL)
		return(-1);
	status=SYS$QIOW(0,channel,IO$_SENSEMODE,&iosb,0,0,tty_orig,12,0,0,0,0);
	if ((status != SS$_NORMAL) || (iosb.iosb$w_value != SS$_NORMAL))
		return(-1);
#endif
	pushsig();
	ps=1;
#ifdef TTY_FLAGS
	tty_new.TTY_FLAGS &= ~ECHO;
#endif
#if defined(TTY_set) && !defined(VMS)
	if (is_a_tty && (TTY_set(fileno(tty),&tty_new) == -1))
		return(-1);
#endif
#ifdef VMS
	tty_new[0] = tty_orig[0];
	tty_new[1] = tty_orig[1] | TT$M_NOECHO;
	tty_new[2] = tty_orig[2];
	status = SYS$QIOW(0,channel,IO$_SETMODE,&iosb,0,0,tty_new,12,0,0,0,0);
	if ((status != SS$_NORMAL) || (iosb.iosb$w_value != SS$_NORMAL))
		return(-1);
#endif
	ps=2;
	while ((!ok) && (number--))
		{
		fputs(prompt,stderr);
		fflush(stderr);
		buf[0]='\0';
		fgets(buf,size,tty);
		if (feof(tty)) goto error;
		if (ferror(tty)) goto error;
		if ((p=(char *)strchr(buf,'\n')) != NULL)
			*p='\0';
		else	read_till_nl(tty);
		if (verify)
			{
			fprintf(stderr,"\nVerifying password - %s",prompt);
			fflush(stderr);
			buff[0]='\0';
			fgets(buff,size,tty);
			if (feof(tty)) goto error;
			if ((p=(char *)strchr(buff,'\n')) != NULL)
				*p='\0';
			else	read_till_nl(tty);
			if (strcmp(buf,buff) != 0)
				{
				fprintf(stderr,"\nVerify failure");
				fflush(stderr);
				break;
				}
			}
		ok=1;
		}
error:
	fprintf(stderr,"\n");
#ifdef DEBUG
	perror("fgets(tty)");
#endif
#if defined(TTY_set) && !defined(VMS)
	if (ps >= 2) TTY_set(fileno(tty),&tty_orig);
#endif
#ifdef VMS
	if (ps >= 2)
		status = SYS$QIOW(0,channel,IO$_SETMODE,&iosb,0,0
			,tty_orig,12,0,0,0,0);
#endif
	if (ps >= 1) popsig();
	if (stdin != tty) fclose(tty);
#ifdef VMS
	status = SYS$DASSGN(channel);
#endif
	return(!ok);
	}
['int MAIN(int argc, char **argv)\n{\n    char *infile=NULL, *outfile=NULL, *keyname = NULL;\n    char *certfile=NULL;\n    BIO *in=NULL, *out = NULL, *inkey = NULL, *certsin = NULL;\n    char **args;\n    char *name = NULL;\n    PKCS12 *p12 = NULL;\n    char pass[50], macpass[50];\n    int export_cert = 0;\n    int options = 0;\n    int chain = 0;\n    int badarg = 0;\n    int iter = _ITER_;\n    int maciter = 1;\n    int twopass = 0;\n    int keytype = 0;\n    int cert_pbe = NID_pbe_WithSHA1And40BitRC2_CBC;\n    int ret = 1;\n    int macver = 1;\n    STACK *canames = NULL;\n    apps_startup();\n    enc = EVP_des_ede3_cbc();\n    if (bio_err == NULL ) bio_err = BIO_new_fp (stderr, BIO_NOCLOSE);\n    args = argv + 1;\n    while (*args) {\n\tif (*args[0] == \'-\') {\n\t\tif (!strcmp (*args, "-nokeys")) options |= NOKEYS;\n\t\telse if (!strcmp (*args, "-keyex")) keytype = KEY_EX;\n\t\telse if (!strcmp (*args, "-keysig")) keytype = KEY_SIG;\n\t\telse if (!strcmp (*args, "-nocerts")) options |= NOCERTS;\n\t\telse if (!strcmp (*args, "-clcerts")) options |= CLCERTS;\n\t\telse if (!strcmp (*args, "-cacerts")) options |= CACERTS;\n\t\telse if (!strcmp (*args, "-noout")) options |= (NOKEYS|NOCERTS);\n\t\telse if (!strcmp (*args, "-info")) options |= INFO;\n\t\telse if (!strcmp (*args, "-chain")) chain = 1;\n\t\telse if (!strcmp (*args, "-twopass")) twopass = 1;\n\t\telse if (!strcmp (*args, "-nomacver")) macver = 0;\n\t\telse if (!strcmp (*args, "-descert"))\n    \t\t\tcert_pbe = NID_pbe_WithSHA1And3_Key_TripleDES_CBC;\n\t\telse if (!strcmp (*args, "-export")) export_cert = 1;\n\t\telse if (!strcmp (*args, "-des")) enc=EVP_des_cbc();\n#ifndef NO_IDEA\n\t\telse if (!strcmp (*args, "-idea")) enc=EVP_idea_cbc();\n#endif\n\t\telse if (!strcmp (*args, "-des3")) enc = EVP_des_ede3_cbc();\n\t\telse if (!strcmp (*args, "-noiter")) iter = 1;\n\t\telse if (!strcmp (*args, "-maciter")) maciter = _ITER_;\n\t\telse if (!strcmp (*args, "-nodes")) enc=NULL;\n\t\telse if (!strcmp (*args, "-inkey")) {\n\t\t    if (args[1]) {\n\t\t\targs++;\n\t\t\tkeyname = *args;\n\t\t    } else badarg = 1;\n\t\t} else if (!strcmp (*args, "-certfile")) {\n\t\t    if (args[1]) {\n\t\t\targs++;\n\t\t\tcertfile = *args;\n\t\t    } else badarg = 1;\n\t\t} else if (!strcmp (*args, "-name")) {\n\t\t    if (args[1]) {\n\t\t\targs++;\n\t\t\tname = *args;\n\t\t    } else badarg = 1;\n\t\t} else if (!strcmp (*args, "-caname")) {\n\t\t    if (args[1]) {\n\t\t\targs++;\n\t\t\tif (!canames) canames = sk_new(NULL);\n\t\t\tsk_push(canames, *args);\n\t\t    } else badarg = 1;\n\t\t} else if (!strcmp (*args, "-in")) {\n\t\t    if (args[1]) {\n\t\t\targs++;\n\t\t\tinfile = *args;\n\t\t    } else badarg = 1;\n\t\t} else if (!strcmp (*args, "-out")) {\n\t\t    if (args[1]) {\n\t\t\targs++;\n\t\t\toutfile = *args;\n\t\t    } else badarg = 1;\n\t\t} else badarg = 1;\n\t} else badarg = 1;\n\targs++;\n    }\n    if (badarg) {\n\tBIO_printf (bio_err, "Usage: pkcs12 [options]\\n");\n\tBIO_printf (bio_err, "where options are\\n");\n\tBIO_printf (bio_err, "-export       output PKCS12 file\\n");\n\tBIO_printf (bio_err, "-chain        add certificate chain\\n");\n\tBIO_printf (bio_err, "-inkey file   private key if not infile\\n");\n\tBIO_printf (bio_err, "-certfile f   add all certs in f\\n");\n\tBIO_printf (bio_err, "-name \\"name\\"  use name as friendly name\\n");\n\tBIO_printf (bio_err, "-caname \\"nm\\"  use nm as CA friendly name (can be used more than once).\\n");\n\tBIO_printf (bio_err, "-in  infile   input filename\\n");\n\tBIO_printf (bio_err, "-out outfile  output filename\\n");\n\tBIO_printf (bio_err, "-noout        don\'t output anything, just verify.\\n");\n\tBIO_printf (bio_err, "-nomacver     don\'t verify MAC.\\n");\n\tBIO_printf (bio_err, "-nocerts      don\'t output certificates.\\n");\n\tBIO_printf (bio_err, "-clcerts      only output client certificates.\\n");\n\tBIO_printf (bio_err, "-cacerts      only output CA certificates.\\n");\n\tBIO_printf (bio_err, "-nokeys       don\'t output private keys.\\n");\n\tBIO_printf (bio_err, "-info         give info about PKCS#12 structure.\\n");\n\tBIO_printf (bio_err, "-des          encrypt private keys with DES\\n");\n\tBIO_printf (bio_err, "-des3         encrypt private keys with triple DES (default)\\n");\n#ifndef NO_IDEA\n\tBIO_printf (bio_err, "-idea         encrypt private keys with idea\\n");\n#endif\n\tBIO_printf (bio_err, "-nodes        don\'t encrypt private keys\\n");\n\tBIO_printf (bio_err, "-noiter       don\'t use encryption iteration\\n");\n\tBIO_printf (bio_err, "-maciter      use MAC iteration\\n");\n\tBIO_printf (bio_err, "-twopass      separate MAC, encryption passwords\\n");\n\tBIO_printf (bio_err, "-descert      encrypt PKCS#12 certificates with triple DES (default RC2-40)\\n");\n\tBIO_printf (bio_err, "-keyex        set MS key exchange type\\n");\n\tBIO_printf (bio_err, "-keysig       set MS key signature type\\n");\n    \tgoto end;\n    }\n    ERR_load_crypto_strings();\n    in = BIO_new (BIO_s_file());\n    out = BIO_new (BIO_s_file());\n    if (!infile) BIO_set_fp (in, stdin, BIO_NOCLOSE);\n    else {\n        if (BIO_read_filename (in, infile) <= 0) {\n\t    perror (infile);\n\t    goto end;\n\t}\n    }\n   if (certfile) {\n    \tcertsin = BIO_new (BIO_s_file());\n        if (BIO_read_filename (certsin, certfile) <= 0) {\n\t    perror (certfile);\n\t    goto end;\n\t}\n    }\n    if (keyname) {\n    \tinkey = BIO_new (BIO_s_file());\n        if (BIO_read_filename (inkey, keyname) <= 0) {\n\t    perror (keyname);\n\t    goto end;\n\t}\n     }\n    if (!outfile) BIO_set_fp (out, stdout, BIO_NOCLOSE);\n    else {\n        if (BIO_write_filename (out, outfile) <= 0) {\n\t    perror (outfile);\n\t    goto end;\n\t}\n    }\n    if (twopass) {\n\tif(EVP_read_pw_string (macpass, 50, "Enter MAC Password:", export_cert)) {\n    \t    BIO_printf (bio_err, "Can\'t read Password\\n");\n    \t    goto end;\n       \t}\n    }\nif (export_cert) {\n\tEVP_PKEY *key;\n\tSTACK *bags, *safes;\n\tPKCS12_SAFEBAG *bag;\n\tPKCS8_PRIV_KEY_INFO *p8;\n\tPKCS7 *authsafe;\n\tX509 *cert, *ucert = NULL;\n\tSTACK *certs;\n\tchar *catmp;\n\tint i, pmatch = 0;\n\tunsigned char keyid[EVP_MAX_MD_SIZE];\n\tint keyidlen;\n\tkey = PEM_read_bio_PrivateKey(inkey ? inkey : in, NULL, NULL);\n\tif (!inkey) BIO_reset(in);\n\tif (!key) {\n\t\tBIO_printf (bio_err, "Error loading private key\\n");\n\t\tERR_print_errors(bio_err);\n\t\tgoto end;\n\t}\n\tcerts = sk_new(NULL);\n\tif(!cert_load(in, certs)) {\n\t\tBIO_printf(bio_err, "Error loading certificates from input\\n");\n\t\tERR_print_errors(bio_err);\n\t\tgoto end;\n\t}\n\tbags = sk_new (NULL);\n\tif (certsin) {\n\t\tif(!cert_load(certsin, certs)) {\n\t\t\tBIO_printf(bio_err, "Error loading certificates from certfile\\n");\n\t\t\tERR_print_errors(bio_err);\n\t\t\tgoto end;\n\t\t}\n\t    \tBIO_free(certsin);\n \t}\n\tfor(i = 0; i < sk_num(certs); i++) {\n\t\t\tcert = (X509 *)sk_value(certs, i);\n\t\t\tif(X509_check_private_key(cert, key)) {\n\t\t\t\tucert = cert;\n\t\t\t\tbreak;\n\t\t\t}\n\t}\n\tif(!ucert) {\n\t\tBIO_printf(bio_err, "No certificate matches private key\\n");\n\t\tgoto end;\n\t}\n\tif (chain) {\n        \tint vret;\n\t\tSTACK *chain2;\n\t\tvret = get_cert_chain (ucert, &chain2);\n\t\tif (vret) {\n\t\t\tBIO_printf (bio_err, "Error %s getting chain.\\n",\n\t\t\t\t\tX509_verify_cert_error_string(vret));\n\t\t\tgoto end;\n\t\t}\n\t\tfor (i = 1; i < sk_num (chain2) ; i++)\n\t\t\t\t sk_push(certs, sk_value (chain2, i));\n\t\tsk_free(chain2);\n    \t}\n\tfor(i = 0; i < sk_num(certs); i++) {\n\t\tcert = (X509 *)sk_value(certs, i);\n\t\tbag = M_PKCS12_x5092certbag(cert);\n\t\tif(cert == ucert) {\n\t\t\tif(name) PKCS12_add_friendlyname(bag, name, -1);\n\t\t\tX509_digest(cert, EVP_sha1(), keyid, &keyidlen);\n\t\t\tPKCS12_add_localkeyid(bag, keyid, keyidlen);\n\t\t\tpmatch = 1;\n\t\t} else if((catmp = sk_shift(canames)))\n\t\t\t\tPKCS12_add_friendlyname(bag, catmp, -1);\n\t\tsk_push(bags, (char *)bag);\n\t}\n\tif (canames) sk_free(canames);\n\tif(EVP_read_pw_string (pass, 50, "Enter Export Password:", 1)) {\n\t    BIO_printf (bio_err, "Can\'t read Password\\n");\n\t    goto end;\n        }\n\tif (!twopass) strcpy(macpass, pass);\n\tauthsafe = PKCS12_pack_p7encdata (cert_pbe, pass, -1, NULL, 0,\n\t\t\t\t\t\t\t\t iter, bags);\n\tsk_pop_free(bags, PKCS12_SAFEBAG_free);\n\tif (!authsafe) {\n\t\tERR_print_errors (bio_err);\n\t\tgoto end;\n\t}\n\tsafes = sk_new (NULL);\n\tsk_push (safes, (char *)authsafe);\n\tp8 = EVP_PKEY2PKCS8 (key);\n\tEVP_PKEY_free(key);\n\tif(keytype) PKCS8_add_keyusage(p8, keytype);\n\tbag = PKCS12_MAKE_SHKEYBAG (NID_pbe_WithSHA1And3_Key_TripleDES_CBC,\n\t\t\tpass, -1, NULL, 0, iter, p8);\n\tPKCS8_PRIV_KEY_INFO_free(p8);\n        if (name) PKCS12_add_friendlyname (bag, name, -1);\n\tPKCS12_add_localkeyid (bag, keyid, keyidlen);\n\tbags = sk_new(NULL);\n\tsk_push (bags, (char *)bag);\n\tauthsafe = PKCS12_pack_p7data (bags);\n\tsk_pop_free(bags, PKCS12_SAFEBAG_free);\n\tsk_push (safes, (char *)authsafe);\n\tp12 = PKCS12_init (NID_pkcs7_data);\n\tM_PKCS12_pack_authsafes (p12, safes);\n\tsk_pop_free(safes, PKCS7_free);\n\tPKCS12_set_mac (p12, macpass, -1, NULL, 0, maciter, NULL);\n\ti2d_PKCS12_bio (out, p12);\n\tPKCS12_free(p12);\n\tret = 0;\n\tgoto end;\n}\n    if (!(p12 = d2i_PKCS12_bio (in, NULL))) {\n\tERR_print_errors(bio_err);\n\tgoto end;\n    }\n    if(EVP_read_pw_string (pass, 50, "Enter Import Password:", 0)) {\n\tBIO_printf (bio_err, "Can\'t read Password\\n");\n\tgoto end;\n    }\n    if (!twopass) strcpy(macpass, pass);\n    if (options & INFO) BIO_printf (bio_err, "MAC Iteration %ld\\n", p12->mac->iter ? ASN1_INTEGER_get (p12->mac->iter) : 1);\n    if(macver) {\n\tif (!PKCS12_verify_mac (p12, macpass, -1)) {\n\t    BIO_printf (bio_err, "Mac verify errror: invalid password?\\n");\n\t    ERR_print_errors (bio_err);\n\t    goto end;\n\t} else BIO_printf (bio_err, "MAC verified OK\\n");\n    }\n    if (!dump_certs_keys_p12 (out, p12, pass, -1, options)) {\n\tBIO_printf(bio_err, "Error outputting keys and certificates\\n");\n\tERR_print_errors (bio_err);\n\tgoto end;\n    }\n    PKCS12_free(p12);\n    ret = 0;\n    end:\n    EXIT(ret);\n}', "int EVP_read_pw_string(char *buf, int len, const char *prompt, int verify)\n\t{\n\tif ((prompt == NULL) && (prompt_string[0] != '\\0'))\n\t\tprompt=prompt_string;\n\treturn(des_read_pw_string(buf,len,prompt,verify));\n\t}", 'int des_read_pw_string(char *buf, int length, const char *prompt,\n\t     int verify)\n\t{\n\tchar buff[BUFSIZ];\n\tint ret;\n\tret=des_read_pw(buf,buff,(length>BUFSIZ)?BUFSIZ:length,prompt,verify);\n\tmemset(buff,0,BUFSIZ);\n\treturn(ret);\n\t}', 'int des_read_pw(char *buf, char *buff, int size, const char *prompt,\n\t     int verify)\n\t{\n#ifdef VMS\n\tstruct IOSB iosb;\n\t$DESCRIPTOR(terminal,"TT");\n\tlong tty_orig[3], tty_new[3];\n\tlong status;\n\tunsigned short channel = 0;\n#else\n#ifndef MSDOS\n\tTTY_STRUCT tty_orig,tty_new;\n#endif\n#endif\n\tint number;\n\tint ok;\n\tstatic int ps;\n\tint is_a_tty;\n\tstatic FILE *tty;\n\tchar *p;\n\tif (setjmp(save))\n\t\t{\n\t\tok=0;\n\t\tgoto error;\n\t\t}\n\tnumber=5;\n\tok=0;\n\tps=0;\n\tis_a_tty=1;\n\ttty=NULL;\n#ifndef MSDOS\n\tif ((tty=fopen("/dev/tty","r")) == NULL)\n\t\ttty=stdin;\n#else\n\tif ((tty=fopen("con","r")) == NULL)\n\t\ttty=stdin;\n#endif\n#if defined(TTY_get) && !defined(VMS)\n\tif (TTY_get(fileno(tty),&tty_orig) == -1)\n\t\t{\n#ifdef ENOTTY\n\t\tif (errno == ENOTTY)\n\t\t\tis_a_tty=0;\n\t\telse\n#endif\n#ifdef EINVAL\n\t\tif (errno == EINVAL)\n\t\t\tis_a_tty=0;\n\t\telse\n#endif\n\t\t\treturn(-1);\n\t\t}\n\tmemcpy(&(tty_new),&(tty_orig),sizeof(tty_orig));\n#endif\n#ifdef VMS\n\tstatus = SYS$ASSIGN(&terminal,&channel,0,0);\n\tif (status != SS$_NORMAL)\n\t\treturn(-1);\n\tstatus=SYS$QIOW(0,channel,IO$_SENSEMODE,&iosb,0,0,tty_orig,12,0,0,0,0);\n\tif ((status != SS$_NORMAL) || (iosb.iosb$w_value != SS$_NORMAL))\n\t\treturn(-1);\n#endif\n\tpushsig();\n\tps=1;\n#ifdef TTY_FLAGS\n\ttty_new.TTY_FLAGS &= ~ECHO;\n#endif\n#if defined(TTY_set) && !defined(VMS)\n\tif (is_a_tty && (TTY_set(fileno(tty),&tty_new) == -1))\n\t\treturn(-1);\n#endif\n#ifdef VMS\n\ttty_new[0] = tty_orig[0];\n\ttty_new[1] = tty_orig[1] | TT$M_NOECHO;\n\ttty_new[2] = tty_orig[2];\n\tstatus = SYS$QIOW(0,channel,IO$_SETMODE,&iosb,0,0,tty_new,12,0,0,0,0);\n\tif ((status != SS$_NORMAL) || (iosb.iosb$w_value != SS$_NORMAL))\n\t\treturn(-1);\n#endif\n\tps=2;\n\twhile ((!ok) && (number--))\n\t\t{\n\t\tfputs(prompt,stderr);\n\t\tfflush(stderr);\n\t\tbuf[0]=\'\\0\';\n\t\tfgets(buf,size,tty);\n\t\tif (feof(tty)) goto error;\n\t\tif (ferror(tty)) goto error;\n\t\tif ((p=(char *)strchr(buf,\'\\n\')) != NULL)\n\t\t\t*p=\'\\0\';\n\t\telse\tread_till_nl(tty);\n\t\tif (verify)\n\t\t\t{\n\t\t\tfprintf(stderr,"\\nVerifying password - %s",prompt);\n\t\t\tfflush(stderr);\n\t\t\tbuff[0]=\'\\0\';\n\t\t\tfgets(buff,size,tty);\n\t\t\tif (feof(tty)) goto error;\n\t\t\tif ((p=(char *)strchr(buff,\'\\n\')) != NULL)\n\t\t\t\t*p=\'\\0\';\n\t\t\telse\tread_till_nl(tty);\n\t\t\tif (strcmp(buf,buff) != 0)\n\t\t\t\t{\n\t\t\t\tfprintf(stderr,"\\nVerify failure");\n\t\t\t\tfflush(stderr);\n\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\tok=1;\n\t\t}\nerror:\n\tfprintf(stderr,"\\n");\n#ifdef DEBUG\n\tperror("fgets(tty)");\n#endif\n#if defined(TTY_set) && !defined(VMS)\n\tif (ps >= 2) TTY_set(fileno(tty),&tty_orig);\n#endif\n#ifdef VMS\n\tif (ps >= 2)\n\t\tstatus = SYS$QIOW(0,channel,IO$_SETMODE,&iosb,0,0\n\t\t\t,tty_orig,12,0,0,0,0);\n#endif\n\tif (ps >= 1) popsig();\n\tif (stdin != tty) fclose(tty);\n#ifdef VMS\n\tstatus = SYS$DASSGN(channel);\n#endif\n\treturn(!ok);\n\t}']