Curl_safefree(*password);
*password = passphrase;
}
- cleanarg(nextarg);
}
/* Get a size parameter for '--limit-rate' or '--max-filesize'.
return PARAM_OK;
}
+static void cleanarg(char *str)
+{
+#ifdef HAVE_WRITABLE_ARGV
+ /* now that GetStr has copied the contents of nextarg, wipe the next
+ * argument out so that the username:password isn't displayed in the
+ * system process list */
+ if(str) {
+ size_t len = strlen(str);
+ memset(str, ' ', len);
+ }
+#else
+ (void)str;
+#endif
+}
+
ParameterError getparameter(const char *flag, /* f or -long-flag */
char *nextarg, /* NULL if unset */
+ char *clearthis,
bool *usedarg, /* set to TRUE if the arg
has been used */
struct GlobalConfig *global,
break;
case 'B': /* OAuth 2.0 bearer token */
GetStr(&config->oauth_bearer, nextarg);
- cleanarg(nextarg);
+ cleanarg(clearthis);
config->authtype |= CURLAUTH_BEARER;
break;
case 'c': /* connect-timeout */
case 'E':
switch(subletter) {
case '\0': /* certificate file */
+ cleanarg(clearthis);
GetFileAndPassword(nextarg, &config->cert, &config->key_passwd);
break;
case 'a': /* CA info PEM file */
break;
case 'e': /* private key passphrase */
GetStr(&config->key_passwd, nextarg);
- cleanarg(nextarg);
+ cleanarg(clearthis);
break;
case 'f': /* crypto engine */
GetStr(&config->engine, nextarg);
break;
case 'k': /* TLS username */
if(!(curlinfo->features & CURL_VERSION_TLSAUTH_SRP)) {
- cleanarg(nextarg);
+ cleanarg(clearthis);
return PARAM_LIBCURL_DOESNT_SUPPORT;
}
GetStr(&config->tls_username, nextarg);
- cleanarg(nextarg);
+ cleanarg(clearthis);
break;
case 'l': /* TLS password */
if(!(curlinfo->features & CURL_VERSION_TLSAUTH_SRP)) {
- cleanarg(nextarg);
+ cleanarg(clearthis);
return PARAM_LIBCURL_DOESNT_SUPPORT;
}
GetStr(&config->tls_password, nextarg);
- cleanarg(nextarg);
+ cleanarg(clearthis);
break;
case 'm': /* TLS authentication type */
if(curlinfo->features & CURL_VERSION_TLSAUTH_SRP) {
break;
case 'u': /* TLS username for proxy */
+ cleanarg(clearthis);
if(!(curlinfo->features & CURL_VERSION_TLSAUTH_SRP)) {
- cleanarg(nextarg);
return PARAM_LIBCURL_DOESNT_SUPPORT;
}
GetStr(&config->proxy_tls_username, nextarg);
- cleanarg(nextarg);
break;
case 'v': /* TLS password for proxy */
+ cleanarg(clearthis);
if(!(curlinfo->features & CURL_VERSION_TLSAUTH_SRP)) {
- cleanarg(nextarg);
return PARAM_LIBCURL_DOESNT_SUPPORT;
}
GetStr(&config->proxy_tls_password, nextarg);
- cleanarg(nextarg);
break;
case 'w': /* TLS authentication type for proxy */
break;
case 'x': /* certificate file for proxy */
+ cleanarg(clearthis);
GetFileAndPassword(nextarg, &config->proxy_cert,
&config->proxy_key_passwd);
break;
case '1': /* private key passphrase for proxy */
GetStr(&config->proxy_key_passwd, nextarg);
- cleanarg(nextarg);
+ cleanarg(clearthis);
break;
case '2': /* ciphers for proxy */
case 'u':
/* user:password */
GetStr(&config->userpwd, nextarg);
- cleanarg(nextarg);
+ cleanarg(clearthis);
break;
case 'U':
/* Proxy user:password */
GetStr(&config->proxyuserpwd, nextarg);
- cleanarg(nextarg);
+ cleanarg(clearthis);
break;
case 'v':
if(toggle) {
following (URL) argument to start with -. */
stillflags = FALSE;
else {
- char *nextarg = (i < (argc - 1))
- ? curlx_convert_tchar_to_UTF8(argv[i + 1])
- : NULL;
+ char *nextarg = NULL;
+ char *clear = NULL;
+ if(i < (argc - 1)) {
+ nextarg = curlx_convert_tchar_to_UTF8(argv[i + 1]);
+ if(!nextarg) {
+ curlx_unicodefree(orig_opt);
+ return PARAM_NO_MEM;
+ }
+ clear = argv[i + 1];
+ }
- result = getparameter(orig_opt, nextarg, &passarg, global, config);
+ result = getparameter(orig_opt, nextarg, clear, &passarg,
+ global, config);
curlx_unicodefree(nextarg);
config = global->last;
bool used;
/* Just add the URL please */
- result = getparameter("--url", orig_opt, &used, global,
+ result = getparameter("--url", orig_opt, NULL, &used, global,
config);
}