From 87036839f93dc7211acee98033f15bdbc20631da Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Mon, 8 Oct 2012 20:07:09 +0200 Subject: example: Simplify auth_callback of the client. Found by Coverity. --- examples/sample.c | 27 +++------------------------ 1 file changed, 3 insertions(+), 24 deletions(-) (limited to 'examples') diff --git a/examples/sample.c b/examples/sample.c index 6b07d9f6..cfe4b3a6 100644 --- a/examples/sample.c +++ b/examples/sample.c @@ -47,31 +47,10 @@ static char *proxycommand; static int auth_callback(const char *prompt, char *buf, size_t len, int echo, int verify, void *userdata) { - char *answer = NULL; - char *ptr; + (void) verify; + (void) userdata; - (void) verify; - (void) userdata; - - if (echo) { - 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; + return ssh_getpass(prompt, buf, len, echo, verify); } struct ssh_callbacks_struct cb = { -- cgit v1.2.3