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:
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user