mirror of
https://git.libssh.org/projects/libssh.git
synced 2025-11-30 13:01:23 +03:00
getpass: Use calloc to allocate memory
Signed-off-by: Andreas Schneider <asn@cryptomilk.org> Reviewed-by: Jakub Jelen <jjelen@redhat.com>
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user