1
0
mirror of https://git.libssh.org/projects/libssh.git synced 2025-12-12 15:41:16 +03:00

getpass: Fixed possible segfault if len is too small.

This commit is contained in:
Andreas Schneider
2011-01-24 17:06:50 +01:00
parent 20e637968a
commit 1e827a8e81

View File

@@ -123,6 +123,11 @@ int ssh_getpass(const char *prompt,
DWORD mode = 0;
int ok;
/* fgets needs at least len - 1 */
if (prompt == NULL || buf == NULL || len < 2) {
return -1;
}
/* get stdin and mode */
h = GetStdHandle(STD_INPUT_HANDLE);
if (!GetConsoleMode(h, &mode)) {
@@ -207,6 +212,11 @@ int ssh_getpass(const char *prompt,
int ok = 0;
int fd = -1;
/* fgets needs at least len - 1 */
if (prompt == NULL || buf == NULL || len < 2) {
return -1;
}
ZERO_STRUCT(attr);
ZERO_STRUCT(old_attr);