mirror of
https://git.libssh.org/projects/libssh.git
synced 2025-08-05 20:55:46 +03:00
example: Simplify auth_callback of the client.
Found by Coverity.
This commit is contained in:
@@ -47,31 +47,10 @@ static char *proxycommand;
|
|||||||
|
|
||||||
static int auth_callback(const char *prompt, char *buf, size_t len,
|
static int auth_callback(const char *prompt, char *buf, size_t len,
|
||||||
int echo, int verify, void *userdata) {
|
int echo, int verify, void *userdata) {
|
||||||
char *answer = NULL;
|
|
||||||
char *ptr;
|
|
||||||
|
|
||||||
(void) verify;
|
(void) verify;
|
||||||
(void) userdata;
|
(void) userdata;
|
||||||
|
|
||||||
if (echo) {
|
return ssh_getpass(prompt, buf, len, echo, verify);
|
||||||
while ((answer = fgets(buf, len, stdin)) == NULL);
|
|
||||||
if ((ptr = strchr(buf, '\n'))) {
|
|
||||||
*ptr = '\0';
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (ssh_getpass(prompt, buf, len, 0, 0) < 0) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (answer == NULL) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
strncpy(buf, answer, len);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ssh_callbacks_struct cb = {
|
struct ssh_callbacks_struct cb = {
|
||||||
|
Reference in New Issue
Block a user