curl-library
[PATCH 3/8] tool_getparam.c: describe what parse_cert_parameter() does
From: Kamil Dudka <kdudka_at_redhat.com>
Date: Fri, 3 May 2013 23:32:49 +0200
Date: Fri, 3 May 2013 23:32:49 +0200
... and de-duplicate the code initializing *passphrase
--- src/tool_getparam.c | 11 ++++++----- 1 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/tool_getparam.c b/src/tool_getparam.c index 55750c9..2b7fa4e 100644 --- a/src/tool_getparam.c +++ b/src/tool_getparam.c @@ -286,7 +286,10 @@ 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) @@ -296,22 +299,21 @@ static void parse_cert_parameter(const char *cert_parameter, 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 +376,6 @@ static void parse_cert_parameter(const char *cert_parameter, *passphrase = strdup(param_place); } return; - break; } } } -- 1.7.1 ------------------------------------------------------------------- List admin: http://cool.haxx.se/list/listinfo/curl-library Etiquette: http://curl.haxx.se/mail/etiquette.htmlReceived on 2013-05-03