1
1

getpass: Use calloc to allocate memory

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Этот коммит содержится в:
Andreas Schneider 2018-09-03 17:47:00 +02:00
родитель 62bff4aff1
Коммит d4a443d56c

Просмотреть файл

@ -49,11 +49,10 @@ static int ssh_gets(const char *prompt, char *buf, size_t len, int verify) {
char *ptr = NULL;
int ok = 0;
tmp = malloc(len);
tmp = calloc(1, len);
if (tmp == NULL) {
return 0;
}
memset(tmp,'\0',len);
/* read the password */
while (!ok) {
@ -80,11 +79,10 @@ static int ssh_gets(const char *prompt, char *buf, size_t len, int verify) {
if (verify) {
char *key_string;
key_string = malloc(len);
key_string = calloc(1, len);
if (key_string == NULL) {
break;
}
memset(key_string, '\0', len);
fprintf(stdout, "\nVerifying, please re-enter. %s", prompt);
fflush(stdout);