aboutsummaryrefslogtreecommitdiff
path: root/src/tool_getparam.c
diff options
context:
space:
mode:
authorKamil Dudka <kdudka@redhat.com>2013-04-05 16:10:46 +0200
committerKamil Dudka <kdudka@redhat.com>2013-05-06 15:00:10 +0200
commita15b2b6c6204766ef391c1831fb4506635bab0a6 (patch)
tree4a1d0a35e8bba3a868040b839add59e688be5a64 /src/tool_getparam.c
parent42e01cff9af12441eb60694af9c0c86817e8f7e0 (diff)
tool_getparam: describe what parse_cert_parameter() does
... and de-duplicate the code initializing *passphrase
Diffstat (limited to 'src/tool_getparam.c')
-rw-r--r--src/tool_getparam.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/tool_getparam.c b/src/tool_getparam.c
index 55750c911..582956279 100644
--- a/src/tool_getparam.c
+++ b/src/tool_getparam.c
@@ -286,32 +286,33 @@ static const struct feat feats[] = {
{"TLS-SRP", CURL_VERSION_TLSAUTH_SRP}
};
-/* https://sourceforge.net/p/curl/bugs/1196/ */
+/* Split the argument of -E to 'certname' and 'passphrase' separated by colon.
+ * We allow ':' and '\' to be escaped by '\' so that we can use certificate
+ * nicknames containing ':'. See <https://sourceforge.net/p/curl/bugs/1196/>
+ * for details. */
static void parse_cert_parameter(const char *cert_parameter,
char **certname,
char **passphrase)
{
size_t param_length = strlen(cert_parameter);
- size_t parsed_chars = 0;
size_t span;
const char *param_place = NULL;
char *certname_place = NULL;
+ *passphrase = NULL;
+
/* most trivial assumption: cert_parameter is empty */
if(param_length == 0) {
*certname = NULL;
- *passphrase = NULL;
return;
}
/* next less trivial: cert_parameter contains no colon nor backslash; this
* means no passphrase was given and no characters escaped */
if(!strpbrk(cert_parameter, ":\\")) {
*certname = strdup(cert_parameter);
- *passphrase = NULL;
return;
}
/* deal with escaped chars; find unescaped colon if it exists */
*certname = (char *) malloc(param_length + 1);
- *passphrase = NULL;
param_place = cert_parameter;
certname_place = *certname;
param_place = cert_parameter;
@@ -374,7 +375,6 @@ static void parse_cert_parameter(const char *cert_parameter,
*passphrase = strdup(param_place);
}
return;
- break;
}
}
}