Remove a useless loop around getpass()

According to getpass(3), this library function cannot return NULL.
Verified with a source code inspection.
This commit is contained in:
khorben 2017-02-20 01:38:28 +00:00
parent 29b683511e
commit b4c0f63794
2 changed files with 4 additions and 10 deletions

View File

@ -34,7 +34,7 @@
#if defined(__NetBSD__)
__COPYRIGHT("@(#) Copyright (c) 2009 The NetBSD Foundation, Inc. All rights reserved.");
__RCSID("$NetBSD: netpgp.c,v 1.98 2016/06/28 16:34:40 christos Exp $");
__RCSID("$NetBSD: netpgp.c,v 1.99 2017/02/20 01:38:28 khorben Exp $");
#endif
#include <sys/types.h>
@ -740,14 +740,10 @@ find_passphrase(FILE *passfp, const char *id, char *passphrase, size_t size, int
}
for (i = 0 ; i < attempts ; i++) {
(void) snprintf(prompt, sizeof(prompt), "Enter passphrase for %.16s: ", id);
if ((cp = getpass(prompt)) == NULL) {
break;
}
cp = getpass(prompt);
cc = snprintf(buf, sizeof(buf), "%s", cp);
(void) snprintf(prompt, sizeof(prompt), "Repeat passphrase for %.16s: ", id);
if ((cp = getpass(prompt)) == NULL) {
break;
}
cp = getpass(prompt);
cc = snprintf(passphrase, size, "%s", cp);
if (strcmp(buf, passphrase) == 0) {
(void) memset(buf, 0x0, sizeof(buf));

View File

@ -43,9 +43,7 @@ pass_cb(char *buf, int size, int rwflag, void *u)
USE_ARG(rwflag);
snprintf(prompt, sizeof(prompt), "\"%s\" passphrase: ", (char *)u);
if ((passphrase = getpass(prompt)) == NULL) {
return -1;
}
passphrase = getpass(prompt);
(void) memcpy(buf, passphrase, (size_t)size);
return (int)strlen(passphrase);
}