mirror of
https://git.libssh.org/projects/libssh.git
synced 2025-12-12 15:41:16 +03:00
getpass: Use explicit_bzero()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
This commit is contained in:
@@ -87,7 +87,7 @@ static int ssh_gets(const char *prompt, char *buf, size_t len, int verify) {
|
|||||||
fprintf(stdout, "\nVerifying, please re-enter. %s", prompt);
|
fprintf(stdout, "\nVerifying, please re-enter. %s", prompt);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
if (! fgets(key_string, len, stdin)) {
|
if (! fgets(key_string, len, stdin)) {
|
||||||
memset(key_string, '\0', len);
|
explicit_bzero(key_string, len);
|
||||||
SAFE_FREE(key_string);
|
SAFE_FREE(key_string);
|
||||||
clearerr(stdin);
|
clearerr(stdin);
|
||||||
continue;
|
continue;
|
||||||
@@ -98,17 +98,17 @@ static int ssh_gets(const char *prompt, char *buf, size_t len, int verify) {
|
|||||||
fprintf(stdout, "\n");
|
fprintf(stdout, "\n");
|
||||||
if (strcmp(buf, key_string)) {
|
if (strcmp(buf, key_string)) {
|
||||||
printf("\n\07\07Mismatch - try again\n");
|
printf("\n\07\07Mismatch - try again\n");
|
||||||
memset(key_string, '\0', len);
|
explicit_bzero(key_string, len);
|
||||||
SAFE_FREE(key_string);
|
SAFE_FREE(key_string);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
memset(key_string, '\0', len);
|
explicit_bzero(key_string, len);
|
||||||
SAFE_FREE(key_string);
|
SAFE_FREE(key_string);
|
||||||
}
|
}
|
||||||
ok = 1;
|
ok = 1;
|
||||||
}
|
}
|
||||||
memset(tmp, '\0', len);
|
explicit_bzero(tmp, len);
|
||||||
free(tmp);
|
free(tmp);
|
||||||
|
|
||||||
return ok;
|
return ok;
|
||||||
@@ -150,7 +150,7 @@ int ssh_getpass(const char *prompt,
|
|||||||
SetConsoleMode(h, mode);
|
SetConsoleMode(h, mode);
|
||||||
|
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
memset (buf, '\0', len);
|
explicit_bzero(buf, len);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -271,7 +271,7 @@ int ssh_getpass(const char *prompt,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
memset (buf, '\0', len);
|
explicit_bzero(buf, len);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user