diff options
author | Andreas Schneider <asn@cryptomilk.org> | 2012-10-08 20:07:09 +0200 |
---|---|---|
committer | Andreas Schneider <asn@cryptomilk.org> | 2012-10-09 11:09:34 +0200 |
commit | 87036839f93dc7211acee98033f15bdbc20631da (patch) | |
tree | 954faffff63c0d340f1750337a1013d8e13b6ee2 /examples | |
parent | 131a0de32e8e41c9152aee07a010342bf073c389 (diff) | |
download | libssh-87036839f93dc7211acee98033f15bdbc20631da.tar.gz libssh-87036839f93dc7211acee98033f15bdbc20631da.tar.xz libssh-87036839f93dc7211acee98033f15bdbc20631da.zip |
example: Simplify auth_callback of the client.
Found by Coverity.
Diffstat (limited to 'examples')
-rw-r--r-- | examples/sample.c | 27 |
1 files changed, 3 insertions, 24 deletions
diff --git a/examples/sample.c b/examples/sample.c index 6b07d9f..cfe4b3a 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 = { |