aboutsummaryrefslogtreecommitdiff
path: root/examples/sample.c
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cryptomilk.org>2012-10-08 20:07:09 +0200
committerAndreas Schneider <asn@cryptomilk.org>2012-10-09 11:09:34 +0200
commit87036839f93dc7211acee98033f15bdbc20631da (patch)
tree954faffff63c0d340f1750337a1013d8e13b6ee2 /examples/sample.c
parent131a0de32e8e41c9152aee07a010342bf073c389 (diff)
downloadlibssh-87036839f93dc7211acee98033f15bdbc20631da.tar.gz
libssh-87036839f93dc7211acee98033f15bdbc20631da.tar.xz
libssh-87036839f93dc7211acee98033f15bdbc20631da.zip
example: Simplify auth_callback of the client.
Found by Coverity.
Diffstat (limited to 'examples/sample.c')
-rw-r--r--examples/sample.c27
1 files changed, 3 insertions, 24 deletions
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 = {