aboutsummaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2003-01-29 13:16:03 +0000
committerDaniel Stenberg <daniel@haxx.se>2003-01-29 13:16:03 +0000
commit7f67a28c2a2ee81b0998e57a10bccbdfe9078fd7 (patch)
tree874cccbecb0245e356b868ca3059bb813f51b6c7 /src/main.c
parent30a46e1135f4d2cfc8d322a0ec3bf9557d93f124 (diff)
HAVE_WRITABLE_ARGV is set if argv[] is writable on the system, and then
we attempt to hide some of the more sensitive command line arguments
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/main.c b/src/main.c
index d2eaedb59..efc43f86e 100644
--- a/src/main.c
+++ b/src/main.c
@@ -970,6 +970,21 @@ typedef enum {
PARAM_LAST
} ParameterError;
+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
+}
+
static ParameterError getparameter(char *flag, /* f or -long-flag */
char *nextarg, /* NULL if unset */
bool *usedarg, /* set to TRUE if the arg
@@ -1398,6 +1413,7 @@ static ParameterError getparameter(char *flag, /* f or -long-flag */
break;
case 'e': /* private key passphrase */
GetStr(&config->key_passwd, nextarg);
+ cleanarg(nextarg);
break;
case 'f': /* crypto engine */
GetStr(&config->engine, nextarg);
@@ -1432,6 +1448,7 @@ static ParameterError getparameter(char *flag, /* f or -long-flag */
GetStr(&config->key_passwd, ptr);
}
GetStr(&config->cert, nextarg);
+ cleanarg(nextarg);
}
}
break;
@@ -1627,10 +1644,12 @@ static ParameterError getparameter(char *flag, /* f or -long-flag */
case 'u':
/* user:password */
GetStr(&config->userpwd, nextarg);
+ cleanarg(nextarg);
break;
case 'U':
/* Proxy user:password */
GetStr(&config->proxyuserpwd, nextarg);
+ cleanarg(nextarg);
break;
case 'v':
config->conf ^= CONF_VERBOSE; /* talk a lot */