diff options
Diffstat (limited to 'lib/ssluse.c')
-rw-r--r-- | lib/ssluse.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/lib/ssluse.c b/lib/ssluse.c index d31c2e07b..74563c7ee 100644 --- a/lib/ssluse.c +++ b/lib/ssluse.c @@ -145,7 +145,7 @@ static char global_passwd[64]; #endif -static int passwd_callback(char *buf, int num, int verify +static int passwd_callback(char *buf, int num, int encrypting #ifdef HAVE_USERDATA_IN_PWD_CALLBACK /* This was introduced in 0.9.4, we can set this using SSL_CTX_set_default_passwd_cb_userdata() @@ -154,12 +154,13 @@ static int passwd_callback(char *buf, int num, int verify #endif ) { - if(verify) - fprintf(stderr, "%s\n", buf); - else { - if(num > (int)strlen((char *)global_passwd)) { - strcpy(buf, global_passwd); - return (int)strlen(buf); + DEBUGASSERT(0 == encrypting); + + if(!encrypting) { + int klen = curlx_uztosi(strlen((char *)global_passwd)); + if(num > klen) { + memcpy(buf, global_passwd, klen+1); + return klen; } } return 0; @@ -339,6 +340,8 @@ int cert_stuff(struct connectdata *conn, size_t len = strlen(data->set.str[STRING_KEY_PASSWD]); if(len < sizeof(global_passwd)) memcpy(global_passwd, data->set.str[STRING_KEY_PASSWD], len+1); + else + global_passwd[0] = '\0'; #else /* * We set the password in the callback userdata |