Blame SOURCES/0045-curl-7.29.0-865d4138.patch

a2d4e1
From e0a1f91d29349d2ce45960f14ebe8e0fa043364e Mon Sep 17 00:00:00 2001
a2d4e1
From: Jared Jennings <jjenning@fastmail.fm>
a2d4e1
Date: Fri, 5 Apr 2013 16:01:31 +0200
a2d4e1
Subject: [PATCH 01/10] curl -E: allow to escape ':' in cert nickname
a2d4e1
a2d4e1
Upstream-commit: 865d4138a08daff460f116c2494adb9c889f5304
a2d4e1
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
a2d4e1
---
a2d4e1
 src/tool_getparam.c | 123 ++++++++++++++++++++++++++++++++++++++++++----------
a2d4e1
 1 file changed, 100 insertions(+), 23 deletions(-)
a2d4e1
a2d4e1
diff --git a/src/tool_getparam.c b/src/tool_getparam.c
a2d4e1
index 57cf97d..db29c0d 100644
a2d4e1
--- a/src/tool_getparam.c
a2d4e1
+++ b/src/tool_getparam.c
a2d4e1
@@ -290,6 +290,99 @@ static const struct feat feats[] = {
a2d4e1
   {"unix-sockets",   CURL_VERSION_UNIX_SOCKETS}
a2d4e1
 };
a2d4e1
 
a2d4e1
+/* https://sourceforge.net/p/curl/bugs/1196/ */
a2d4e1
+static void parse_cert_parameter(const char *cert_parameter,
a2d4e1
+                                 char **certname,
a2d4e1
+                                 char **passphrase)
a2d4e1
+{
a2d4e1
+  size_t param_length = strlen(cert_parameter);
a2d4e1
+  size_t parsed_chars = 0;
a2d4e1
+  size_t span;
a2d4e1
+  const char *param_place = NULL;
a2d4e1
+  char *certname_place = NULL;
a2d4e1
+  /* most trivial assumption: cert_parameter is empty */
a2d4e1
+  if(param_length == 0) {
a2d4e1
+    *certname = NULL;
a2d4e1
+    *passphrase = NULL;
a2d4e1
+    return;
a2d4e1
+  }
a2d4e1
+  /* next less trivial: cert_parameter contains no colon nor backslash; this
a2d4e1
+   * means no passphrase was given and no characters escaped */
a2d4e1
+  if(!strpbrk(cert_parameter, ":\\")) {
a2d4e1
+    *certname = strdup(cert_parameter);
a2d4e1
+    *passphrase = NULL;
a2d4e1
+    return;
a2d4e1
+  }
a2d4e1
+  /* deal with escaped chars; find unescaped colon if it exists */
a2d4e1
+  *certname = (char *) malloc(param_length + 1);
a2d4e1
+  *passphrase = NULL;
a2d4e1
+  param_place = cert_parameter;
a2d4e1
+  certname_place = *certname;
a2d4e1
+  param_place = cert_parameter;
a2d4e1
+  while(*param_place) {
a2d4e1
+    span = strcspn(param_place, ":\\");
a2d4e1
+    strncpy(certname_place, param_place, span);
a2d4e1
+    param_place += span;
a2d4e1
+    certname_place += span;
a2d4e1
+    *certname_place = '\0';
a2d4e1
+    /* we just ate all the non-special chars. now we're on either a special
a2d4e1
+     * char or the end of the string. */
a2d4e1
+    switch(*param_place) {
a2d4e1
+    case '\0':
a2d4e1
+      break;
a2d4e1
+    case '\\':
a2d4e1
+      param_place++;
a2d4e1
+      switch(*param_place) {
a2d4e1
+        case '\0':
a2d4e1
+          *certname_place++ = '\\';
a2d4e1
+          break;
a2d4e1
+        case '\\':
a2d4e1
+          *certname_place++ = '\\';
a2d4e1
+          param_place++;
a2d4e1
+          break;
a2d4e1
+        case ':':
a2d4e1
+          *certname_place++ = ':';
a2d4e1
+          param_place++;
a2d4e1
+          break;
a2d4e1
+        default:
a2d4e1
+          *certname_place++ = '\\';
a2d4e1
+          *certname_place++ = *param_place;
a2d4e1
+          param_place++;
a2d4e1
+          break;
a2d4e1
+      }
a2d4e1
+      break;
a2d4e1
+    case ':':
a2d4e1
+      /* Since we live in a world of weirdness and confusion, the win32
a2d4e1
+         dudes can use : when using drive letters and thus c:\file:password
a2d4e1
+         needs to work. In order not to break compatibility, we still use : as
a2d4e1
+         separator, but we try to detect when it is used for a file name! On
a2d4e1
+         windows. */
a2d4e1
+#ifdef WIN32
a2d4e1
+      if(param_place &&
a2d4e1
+          (param_place == &cert_parameter[1]) &&
a2d4e1
+          (cert_parameter[2] == '\\' || cert_parameter[2] == '/') &&
a2d4e1
+          (ISALPHA(cert_parameter[0])) ) {
a2d4e1
+        /* colon in the second column, followed by a backslash, and the
a2d4e1
+           first character is an alphabetic letter:
a2d4e1
+
a2d4e1
+           this is a drive letter colon */
a2d4e1
+        *certname_place++ = ':';
a2d4e1
+        param_place++;
a2d4e1
+        break;
a2d4e1
+      }
a2d4e1
+#endif
a2d4e1
+      /* escaped colons and Windows drive letter colons were handled
a2d4e1
+       * above; if we're still here, this is a separating colon */
a2d4e1
+      param_place++;
a2d4e1
+      if(strlen(param_place) > 0) {
a2d4e1
+        *passphrase = strdup(param_place);
a2d4e1
+      }
a2d4e1
+      return;
a2d4e1
+      break;
a2d4e1
+    }
a2d4e1
+  }
a2d4e1
+}
a2d4e1
+
a2d4e1
 ParameterError getparameter(char *flag,    /* f or -long-flag */
a2d4e1
                             char *nextarg, /* NULL if unset */
a2d4e1
                             bool *usedarg, /* set to TRUE if the arg
a2d4e1
@@ -1227,30 +1320,14 @@ ParameterError getparameter(char *flag,    /* f or -long-flag */
a2d4e1
         break;
a2d4e1
       default: /* certificate file */
a2d4e1
       {
a2d4e1
-        char *ptr = strchr(nextarg, ':');
a2d4e1
-        /* Since we live in a world of weirdness and confusion, the win32
a2d4e1
-           dudes can use : when using drive letters and thus
a2d4e1
-           c:\file:password needs to work. In order not to break
a2d4e1
-           compatibility, we still use : as separator, but we try to detect
a2d4e1
-           when it is used for a file name! On windows. */
a2d4e1
-#ifdef WIN32
a2d4e1
-        if(ptr &&
a2d4e1
-           (ptr == &nextarg[1]) &&
a2d4e1
-           (nextarg[2] == '\\' || nextarg[2] == '/') &&
a2d4e1
-           (ISALPHA(nextarg[0])) )
a2d4e1
-          /* colon in the second column, followed by a backslash, and the
a2d4e1
-             first character is an alphabetic letter:
a2d4e1
-
a2d4e1
-             this is a drive letter colon */
a2d4e1
-          ptr = strchr(&nextarg[3], ':'); /* find the next one instead */
a2d4e1
-#endif
a2d4e1
-        if(ptr) {
a2d4e1
-          /* we have a password too */
a2d4e1
-          *ptr = '\0';
a2d4e1
-          ptr++;
a2d4e1
-          GetStr(&config->key_passwd, ptr);
a2d4e1
+        char *certname, *passphrase;
a2d4e1
+        parse_cert_parameter(nextarg, &certname, &passphrase);
a2d4e1
+        if(certname) {
a2d4e1
+          GetStr(&config->cert, certname);
a2d4e1
+        }
a2d4e1
+        if(passphrase) {
a2d4e1
+          GetStr(&config->key_passwd, passphrase);
a2d4e1
         }
a2d4e1
-        GetStr(&config->cert, nextarg);
a2d4e1
         cleanarg(nextarg);
a2d4e1
       }
a2d4e1
       }
a2d4e1
-- 
a2d4e1
2.7.4
a2d4e1
a2d4e1
a2d4e1
From 9a5f8a20402e549211d9df1d9ef0cb0b00e5ed8f Mon Sep 17 00:00:00 2001
a2d4e1
From: Kamil Dudka <kdudka@redhat.com>
a2d4e1
Date: Fri, 3 May 2013 23:12:00 +0200
a2d4e1
Subject: [PATCH 02/10] curl.1: document escape sequences recognized by -E
a2d4e1
a2d4e1
Upstream-commit: 42e01cff9af12441eb60694af9c0c86817e8f7e0
a2d4e1
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
a2d4e1
---
a2d4e1
 docs/curl.1 | 5 ++++-
a2d4e1
 1 file changed, 4 insertions(+), 1 deletion(-)
a2d4e1
a2d4e1
diff --git a/docs/curl.1 b/docs/curl.1
a2d4e1
index ad26007..c9bb336 100644
a2d4e1
--- a/docs/curl.1
a2d4e1
+++ b/docs/curl.1
a2d4e1
@@ -397,7 +397,10 @@ curl the nickname of the certificate to use within the NSS database defined
a2d4e1
 by the environment variable SSL_DIR (or by default /etc/pki/nssdb). If the
a2d4e1
 NSS PEM PKCS#11 module (libnsspem.so) is available then PEM files may be
a2d4e1
 loaded. If you want to use a file from the current directory, please precede
a2d4e1
-it with "./" prefix, in order to avoid confusion with a nickname.
a2d4e1
+it with "./" prefix, in order to avoid confusion with a nickname.  If the
a2d4e1
+nickname contains ":", it needs to be preceded by "\\" so that it is not
a2d4e1
+recognized as password delimiter.  If the nickname contains "\\", it needs to
a2d4e1
+be escaped as "\\\\" so that it is not recognized as an escape character.
a2d4e1
 
a2d4e1
 If this option is used several times, the last one will be used.
a2d4e1
 .IP "--engine <name>"
a2d4e1
-- 
a2d4e1
2.7.4
a2d4e1
a2d4e1
a2d4e1
From fcfd1f85946ed0784365c55cf6c7a196c328308a Mon Sep 17 00:00:00 2001
a2d4e1
From: Kamil Dudka <kdudka@redhat.com>
a2d4e1
Date: Fri, 5 Apr 2013 16:10:46 +0200
a2d4e1
Subject: [PATCH 03/10] tool_getparam: describe what parse_cert_parameter()
a2d4e1
 does
a2d4e1
a2d4e1
... and de-duplicate the code initializing *passphrase
a2d4e1
a2d4e1
Upstream-commit: a15b2b6c6204766ef391c1831fb4506635bab0a6
a2d4e1
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
a2d4e1
---
a2d4e1
 src/tool_getparam.c | 12 ++++++------
a2d4e1
 1 file changed, 6 insertions(+), 6 deletions(-)
a2d4e1
a2d4e1
diff --git a/src/tool_getparam.c b/src/tool_getparam.c
a2d4e1
index db29c0d..77d44c4 100644
a2d4e1
--- a/src/tool_getparam.c
a2d4e1
+++ b/src/tool_getparam.c
a2d4e1
@@ -290,32 +290,33 @@ static const struct feat feats[] = {
a2d4e1
   {"unix-sockets",   CURL_VERSION_UNIX_SOCKETS}
a2d4e1
 };
a2d4e1
 
a2d4e1
-/* https://sourceforge.net/p/curl/bugs/1196/ */
a2d4e1
+/* Split the argument of -E to 'certname' and 'passphrase' separated by colon.
a2d4e1
+ * We allow ':' and '\' to be escaped by '\' so that we can use certificate
a2d4e1
+ * nicknames containing ':'.  See <https://sourceforge.net/p/curl/bugs/1196/>
a2d4e1
+ * for details. */
a2d4e1
 static void parse_cert_parameter(const char *cert_parameter,
a2d4e1
                                  char **certname,
a2d4e1
                                  char **passphrase)
a2d4e1
 {
a2d4e1
   size_t param_length = strlen(cert_parameter);
a2d4e1
-  size_t parsed_chars = 0;
a2d4e1
   size_t span;
a2d4e1
   const char *param_place = NULL;
a2d4e1
   char *certname_place = NULL;
a2d4e1
+  *passphrase = NULL;
a2d4e1
+
a2d4e1
   /* most trivial assumption: cert_parameter is empty */
a2d4e1
   if(param_length == 0) {
a2d4e1
     *certname = NULL;
a2d4e1
-    *passphrase = NULL;
a2d4e1
     return;
a2d4e1
   }
a2d4e1
   /* next less trivial: cert_parameter contains no colon nor backslash; this
a2d4e1
    * means no passphrase was given and no characters escaped */
a2d4e1
   if(!strpbrk(cert_parameter, ":\\")) {
a2d4e1
     *certname = strdup(cert_parameter);
a2d4e1
-    *passphrase = NULL;
a2d4e1
     return;
a2d4e1
   }
a2d4e1
   /* deal with escaped chars; find unescaped colon if it exists */
a2d4e1
   *certname = (char *) malloc(param_length + 1);
a2d4e1
-  *passphrase = NULL;
a2d4e1
   param_place = cert_parameter;
a2d4e1
   certname_place = *certname;
a2d4e1
   param_place = cert_parameter;
a2d4e1
@@ -378,7 +379,6 @@ static void parse_cert_parameter(const char *cert_parameter,
a2d4e1
         *passphrase = strdup(param_place);
a2d4e1
       }
a2d4e1
       return;
a2d4e1
-      break;
a2d4e1
     }
a2d4e1
   }
a2d4e1
 }
a2d4e1
-- 
a2d4e1
2.7.4
a2d4e1
a2d4e1
a2d4e1
From d9bbc65a4624ba78576e2a7d98dbbeccd4b8a3b3 Mon Sep 17 00:00:00 2001
a2d4e1
From: Kamil Dudka <kdudka@redhat.com>
a2d4e1
Date: Fri, 3 May 2013 22:16:46 +0200
a2d4e1
Subject: [PATCH 04/10] tool_getparam: fix memleak in handling the -E option
a2d4e1
a2d4e1
Upstream-commit: b47cf4f688297d9cf87a39c8aa328d9d07540e66
a2d4e1
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
a2d4e1
---
a2d4e1
 src/tool_getparam.c | 8 ++++----
a2d4e1
 1 file changed, 4 insertions(+), 4 deletions(-)
a2d4e1
a2d4e1
diff --git a/src/tool_getparam.c b/src/tool_getparam.c
a2d4e1
index 77d44c4..02d95a7 100644
a2d4e1
--- a/src/tool_getparam.c
a2d4e1
+++ b/src/tool_getparam.c
a2d4e1
@@ -1322,11 +1322,11 @@ ParameterError getparameter(char *flag,    /* f or -long-flag */
a2d4e1
       {
a2d4e1
         char *certname, *passphrase;
a2d4e1
         parse_cert_parameter(nextarg, &certname, &passphrase);
a2d4e1
-        if(certname) {
a2d4e1
-          GetStr(&config->cert, certname);
a2d4e1
-        }
a2d4e1
+        Curl_safefree(config->cert);
a2d4e1
+        config->cert = certname;
a2d4e1
         if(passphrase) {
a2d4e1
-          GetStr(&config->key_passwd, passphrase);
a2d4e1
+          Curl_safefree(config->key_passwd);
a2d4e1
+          config->key_passwd = passphrase;
a2d4e1
         }
a2d4e1
         cleanarg(nextarg);
a2d4e1
       }
a2d4e1
-- 
a2d4e1
2.7.4
a2d4e1
a2d4e1
a2d4e1
From 0cadf08557da47b826e8f3b3973be2fc80e50068 Mon Sep 17 00:00:00 2001
a2d4e1
From: Kamil Dudka <kdudka@redhat.com>
a2d4e1
Date: Fri, 3 May 2013 22:57:18 +0200
a2d4e1
Subject: [PATCH 05/10] tool_getparam: ensure string termination in
a2d4e1
 parse_cert_parameter()
a2d4e1
a2d4e1
Upstream-commit: 2de20dd9a1c6ad4d576c60ab704c30abfc826b1a
a2d4e1
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
a2d4e1
---
a2d4e1
 src/tool_getparam.c | 19 +++++++++++--------
a2d4e1
 1 file changed, 11 insertions(+), 8 deletions(-)
a2d4e1
a2d4e1
diff --git a/src/tool_getparam.c b/src/tool_getparam.c
a2d4e1
index 02d95a7..dd04f5f 100644
a2d4e1
--- a/src/tool_getparam.c
a2d4e1
+++ b/src/tool_getparam.c
a2d4e1
@@ -302,13 +302,13 @@ static void parse_cert_parameter(const char *cert_parameter,
a2d4e1
   size_t span;
a2d4e1
   const char *param_place = NULL;
a2d4e1
   char *certname_place = NULL;
a2d4e1
+  *certname = NULL;
a2d4e1
   *passphrase = NULL;
a2d4e1
 
a2d4e1
   /* most trivial assumption: cert_parameter is empty */
a2d4e1
-  if(param_length == 0) {
a2d4e1
-    *certname = NULL;
a2d4e1
+  if(param_length == 0)
a2d4e1
     return;
a2d4e1
-  }
a2d4e1
+
a2d4e1
   /* next less trivial: cert_parameter contains no colon nor backslash; this
a2d4e1
    * means no passphrase was given and no characters escaped */
a2d4e1
   if(!strpbrk(cert_parameter, ":\\")) {
a2d4e1
@@ -316,16 +316,17 @@ static void parse_cert_parameter(const char *cert_parameter,
a2d4e1
     return;
a2d4e1
   }
a2d4e1
   /* deal with escaped chars; find unescaped colon if it exists */
a2d4e1
-  *certname = (char *) malloc(param_length + 1);
a2d4e1
-  param_place = cert_parameter;
a2d4e1
-  certname_place = *certname;
a2d4e1
+  certname_place = malloc(param_length + 1);
a2d4e1
+  if(!certname_place)
a2d4e1
+    return;
a2d4e1
+
a2d4e1
+  *certname = certname_place;
a2d4e1
   param_place = cert_parameter;
a2d4e1
   while(*param_place) {
a2d4e1
     span = strcspn(param_place, ":\\");
a2d4e1
     strncpy(certname_place, param_place, span);
a2d4e1
     param_place += span;
a2d4e1
     certname_place += span;
a2d4e1
-    *certname_place = '\0';
a2d4e1
     /* we just ate all the non-special chars. now we're on either a special
a2d4e1
      * char or the end of the string. */
a2d4e1
     switch(*param_place) {
a2d4e1
@@ -378,9 +379,11 @@ static void parse_cert_parameter(const char *cert_parameter,
a2d4e1
       if(strlen(param_place) > 0) {
a2d4e1
         *passphrase = strdup(param_place);
a2d4e1
       }
a2d4e1
-      return;
a2d4e1
+      goto done;
a2d4e1
     }
a2d4e1
   }
a2d4e1
+done:
a2d4e1
+  *certname_place = '\0';
a2d4e1
 }
a2d4e1
 
a2d4e1
 ParameterError getparameter(char *flag,    /* f or -long-flag */
a2d4e1
-- 
a2d4e1
2.7.4
a2d4e1
a2d4e1
a2d4e1
From 47447c9e89e7f9b5acd60ca565996428d90b9e0e Mon Sep 17 00:00:00 2001
a2d4e1
From: Kamil Dudka <kdudka@redhat.com>
a2d4e1
Date: Fri, 3 May 2013 23:03:58 +0200
a2d4e1
Subject: [PATCH 06/10] src/Makefile.am: build static lib for unit tests if
a2d4e1
 enabled
a2d4e1
a2d4e1
Upstream-commit: 683f2b832388d08999620ee45cb619a7afd42aaf
a2d4e1
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
a2d4e1
---
a2d4e1
 src/Makefile.am        |  8 ++++++++
a2d4e1
 src/tool_main.c        |  4 ++++
a2d4e1
 tests/unit/Makefile.am | 11 +++++++++--
a2d4e1
 3 files changed, 21 insertions(+), 2 deletions(-)
a2d4e1
a2d4e1
diff --git a/src/Makefile.am b/src/Makefile.am
a2d4e1
index 6863078..751beda 100644
a2d4e1
--- a/src/Makefile.am
a2d4e1
+++ b/src/Makefile.am
a2d4e1
@@ -67,6 +67,14 @@ curl_LDFLAGS = @LIBMETALINK_LDFLAGS@
a2d4e1
 curl_CPPFLAGS = $(AM_CPPFLAGS) $(LIBMETALINK_CPPFLAGS)
a2d4e1
 curl_DEPENDENCIES = $(top_builddir)/lib/libcurl.la
a2d4e1
 
a2d4e1
+# if unit tests are enabled, build a static library to link them with
a2d4e1
+if BUILD_UNITTESTS
a2d4e1
+noinst_LTLIBRARIES = libcurltool.la
a2d4e1
+libcurltool_la_CFLAGS = -DUNITTESTS
a2d4e1
+libcurltool_la_LDFLAGS = -static $(LINKFLAGS)
a2d4e1
+libcurltool_la_SOURCES = $(curl_SOURCES)
a2d4e1
+endif
a2d4e1
+
a2d4e1
 BUILT_SOURCES = tool_hugehelp.c
a2d4e1
 CLEANFILES = tool_hugehelp.c
a2d4e1
 # Use the C locale to ensure that only ASCII characters appear in the
a2d4e1
diff --git a/src/tool_main.c b/src/tool_main.c
a2d4e1
index 6a1ed6c..00d8411 100644
a2d4e1
--- a/src/tool_main.c
a2d4e1
+++ b/src/tool_main.c
a2d4e1
@@ -59,6 +59,9 @@
a2d4e1
 static int vms_show = 0;
a2d4e1
 #endif
a2d4e1
 
a2d4e1
+/* if we build a static library for unit tests, there is no main() function */
a2d4e1
+#ifndef UNITTESTS
a2d4e1
+
a2d4e1
 /*
a2d4e1
  * Ensure that file descriptors 0, 1 and 2 (stdin, stdout, stderr) are
a2d4e1
  * open before starting to run.  Otherwise, the first three network
a2d4e1
@@ -128,3 +131,4 @@ int main(int argc, char *argv[])
a2d4e1
 #endif
a2d4e1
 }
a2d4e1
 
a2d4e1
+#endif /* ndef UNITTESTS */
a2d4e1
diff --git a/tests/unit/Makefile.am b/tests/unit/Makefile.am
a2d4e1
index 12d5fe3..ce6af6f 100644
a2d4e1
--- a/tests/unit/Makefile.am
a2d4e1
+++ b/tests/unit/Makefile.am
a2d4e1
@@ -40,6 +40,7 @@ AM_CPPFLAGS = -I$(top_builddir)/include/curl \
a2d4e1
               -I$(top_srcdir)/include        \
a2d4e1
               -I$(top_builddir)/lib          \
a2d4e1
               -I$(top_srcdir)/lib            \
a2d4e1
+              -I$(top_srcdir)/src            \
a2d4e1
               -I$(top_srcdir)/tests/libtest  \
a2d4e1
               -I$(top_builddir)/ares         \
a2d4e1
               -I$(top_srcdir)/ares
a2d4e1
@@ -49,6 +50,7 @@ AM_CPPFLAGS = -I$(top_builddir)/include/curl \
a2d4e1
               -I$(top_srcdir)/include        \
a2d4e1
               -I$(top_builddir)/lib          \
a2d4e1
               -I$(top_srcdir)/lib            \
a2d4e1
+              -I$(top_srcdir)/src            \
a2d4e1
               -I$(top_srcdir)/tests/libtest
a2d4e1
 endif
a2d4e1
 
a2d4e1
@@ -57,8 +59,13 @@ EXTRA_DIST = Makefile.inc
a2d4e1
 # Prevent LIBS from being used for all link targets
a2d4e1
 LIBS = $(BLANK_AT_MAKETIME)
a2d4e1
 
a2d4e1
-LDADD = $(top_builddir)/lib/libcurlu.la @LDFLAGS@ @LIBCURL_LIBS@
a2d4e1
-DEPENDENCIES = $(top_builddir)/lib/libcurlu.la
a2d4e1
+LDADD = $(top_builddir)/src/libcurltool.la   \
a2d4e1
+        $(top_builddir)/lib/libcurlu.la      \
a2d4e1
+        @LDFLAGS@ @LIBCURL_LIBS@
a2d4e1
+
a2d4e1
+DEPENDENCIES = $(top_builddir)/src/libcurltool.la \
a2d4e1
+               $(top_builddir)/lib/libcurlu.la
a2d4e1
+
a2d4e1
 AM_CPPFLAGS += -DUNITTESTS
a2d4e1
 
a2d4e1
 # Mostly for Windows build targets, when using static libcurl
a2d4e1
-- 
a2d4e1
2.7.4
a2d4e1
a2d4e1
a2d4e1
From fb3618a22db456813a3064118e80a55ac2abb8c1 Mon Sep 17 00:00:00 2001
a2d4e1
From: Jared Jennings <jjenning@fastmail.fm>
a2d4e1
Date: Fri, 5 Apr 2013 16:01:31 +0200
a2d4e1
Subject: [PATCH 07/10] unit1394.c: basis of a unit test for
a2d4e1
 parse_cert_parameter()
a2d4e1
a2d4e1
Upstream-commit: b045d079f8bf9e85b2aef94bc94928f444b3a711
a2d4e1
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
a2d4e1
---
a2d4e1
 tests/unit/unit1394.c | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++
a2d4e1
 1 file changed, 75 insertions(+)
a2d4e1
 create mode 100644 tests/unit/unit1394.c
a2d4e1
a2d4e1
diff --git a/tests/unit/unit1394.c b/tests/unit/unit1394.c
a2d4e1
new file mode 100644
a2d4e1
index 0000000..11a47b9
a2d4e1
--- /dev/null
a2d4e1
+++ b/tests/unit/unit1394.c
a2d4e1
@@ -0,0 +1,75 @@
a2d4e1
+#include <stdio.h>
a2d4e1
+#include <stdlib.h>
a2d4e1
+#include <string.h>
a2d4e1
+
a2d4e1
+int main(int argc, char **argv) {
a2d4e1
+  char *values[] = {
a2d4e1
+    /* -E parameter */        /* exp. cert name */  /* exp. passphrase */
a2d4e1
+    "foo:bar:baz",            "foo",                "bar:baz",
a2d4e1
+    "foo\\:bar:baz",          "foo:bar",            "baz",
a2d4e1
+    "foo\\\\:bar:baz",        "foo\\",              "bar:baz",
a2d4e1
+    "foo:bar\\:baz",          "foo",                "bar\\:baz",
a2d4e1
+    "foo:bar\\\\:baz",        "foo",                "bar\\\\:baz",
a2d4e1
+    "foo\\bar\\baz",          "foo\\bar\\baz",      NULL,
a2d4e1
+    "foo\\\\bar\\\\baz",      "foo\\bar\\baz",      NULL,
a2d4e1
+    "foo\\",                  "foo\\",              NULL,
a2d4e1
+    "foo\\\\",                "foo\\",              NULL,
a2d4e1
+    "foo:bar\\",              "foo",                "bar\\",
a2d4e1
+    "foo:bar\\\\",            "foo",                "bar\\\\",
a2d4e1
+    "foo:bar:",               "foo",                "bar:",
a2d4e1
+    "foo\\::bar\\:",          "foo:",               "bar\\:",
a2d4e1
+    "c:\\foo:bar:baz",        "c:\\foo",            "bar:baz",
a2d4e1
+    "c:\\foo\\:bar:baz",      "c:\\foo:bar",        "baz",
a2d4e1
+    "c:\\foo\\\\:bar:baz",    "c:\\foo\\",          "bar:baz",
a2d4e1
+    "c:\\foo:bar\\:baz",      "c:\\foo",            "bar\\:baz",
a2d4e1
+    "c:\\foo:bar\\\\:baz",    "c:\\foo",            "bar\\\\:baz",
a2d4e1
+    "c:\\foo\\bar\\baz",      "c:\\foo\\bar\\baz",  NULL,
a2d4e1
+    "c:\\foo\\\\bar\\\\baz",  "c:\\foo\\bar\\baz",  NULL,
a2d4e1
+    "c:\\foo\\",              "c:\\foo\\",          NULL,
a2d4e1
+    "c:\\foo\\\\",            "c:\\foo\\",          NULL,
a2d4e1
+    "c:\\foo:bar\\",          "c:\\foo",            "bar\\",
a2d4e1
+    "c:\\foo:bar\\\\",        "c:\\foo",            "bar\\\\",
a2d4e1
+    "c:\\foo:bar:",           "c:\\foo",            "bar:",
a2d4e1
+    "c:\\foo\\::bar\\:",      "c:\\foo:",           "bar\\:",
a2d4e1
+    NULL,                     NULL,                 NULL,
a2d4e1
+  };
a2d4e1
+  char **p;
a2d4e1
+  char *certname, *passphrase;
a2d4e1
+  for(p = values; *p; p += 3) {
a2d4e1
+    parse_cert_parameter(p[0], &certname, &passphrase);
a2d4e1
+    if(p[1]) {
a2d4e1
+      if(certname) {
a2d4e1
+        if(strcmp(p[1], certname)) {
a2d4e1
+          printf("expected certname '%s' but got '%s' "
a2d4e1
+              "for -E param '%s'\n", p[1], certname, p[0]);
a2d4e1
+        }
a2d4e1
+      } else {
a2d4e1
+        printf("expected certname '%s' but got NULL "
a2d4e1
+            "for -E param '%s'\n", p[1], p[0]);
a2d4e1
+      }
a2d4e1
+    } else {
a2d4e1
+      if(certname) {
a2d4e1
+        printf("expected certname NULL but got '%s' "
a2d4e1
+            "for -E param '%s'\n", certname, p[0]);
a2d4e1
+      }
a2d4e1
+    }
a2d4e1
+    if(p[2]) {
a2d4e1
+      if(passphrase) {
a2d4e1
+        if(strcmp(p[2], passphrase)) {
a2d4e1
+          printf("expected passphrase '%s' but got '%s'"
a2d4e1
+              "for -E param '%s'\n", p[2], passphrase, p[0]);
a2d4e1
+        }
a2d4e1
+      } else {
a2d4e1
+        printf("expected passphrase '%s' but got NULL "
a2d4e1
+            "for -E param '%s'\n", p[2], p[0]);
a2d4e1
+      }
a2d4e1
+    } else {
a2d4e1
+      if(passphrase) {
a2d4e1
+        printf("expected passphrase NULL but got '%s' "
a2d4e1
+            "for -E param '%s'\n", passphrase, p[0]);
a2d4e1
+      }
a2d4e1
+    }
a2d4e1
+    if(certname) free(certname);
a2d4e1
+    if(passphrase) free(passphrase);
a2d4e1
+  }
a2d4e1
+}
a2d4e1
-- 
a2d4e1
2.7.4
a2d4e1
a2d4e1
a2d4e1
From 2af1560a4b38c33089916cadfe7d8a8e8f44b7d3 Mon Sep 17 00:00:00 2001
a2d4e1
From: Kamil Dudka <kdudka@redhat.com>
a2d4e1
Date: Fri, 3 May 2013 13:26:25 +0200
a2d4e1
Subject: [PATCH 08/10] unit1394.c: plug the curl tool unit test in
a2d4e1
a2d4e1
Upstream-commit: bcf1b9dec13badd073518e1d63aab40a958d9245
a2d4e1
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
a2d4e1
---
a2d4e1
 src/tool_getparam.c     |  9 +++++---
a2d4e1
 src/tool_getparam.h     |  6 ++++++
a2d4e1
 tests/data/test1394     | 30 ++++++++++++++++++++++++++
a2d4e1
 tests/unit/Makefile.inc |  4 +++-
a2d4e1
 tests/unit/unit1394.c   | 56 +++++++++++++++++++++++++++++++++++++++++++++----
a2d4e1
 5 files changed, 97 insertions(+), 8 deletions(-)
a2d4e1
 create mode 100644 tests/data/test1394
a2d4e1
a2d4e1
diff --git a/src/tool_getparam.c b/src/tool_getparam.c
a2d4e1
index dd04f5f..33db742 100644
a2d4e1
--- a/src/tool_getparam.c
a2d4e1
+++ b/src/tool_getparam.c
a2d4e1
@@ -294,9 +294,12 @@ static const struct feat feats[] = {
a2d4e1
  * We allow ':' and '\' to be escaped by '\' so that we can use certificate
a2d4e1
  * nicknames containing ':'.  See <https://sourceforge.net/p/curl/bugs/1196/>
a2d4e1
  * for details. */
a2d4e1
-static void parse_cert_parameter(const char *cert_parameter,
a2d4e1
-                                 char **certname,
a2d4e1
-                                 char **passphrase)
a2d4e1
+#ifndef UNITTESTS
a2d4e1
+static
a2d4e1
+#endif
a2d4e1
+void parse_cert_parameter(const char *cert_parameter,
a2d4e1
+                          char **certname,
a2d4e1
+                          char **passphrase)
a2d4e1
 {
a2d4e1
   size_t param_length = strlen(cert_parameter);
a2d4e1
   size_t span;
a2d4e1
diff --git a/src/tool_getparam.h b/src/tool_getparam.h
a2d4e1
index 38f0674..a86bfce 100644
a2d4e1
--- a/src/tool_getparam.h
a2d4e1
+++ b/src/tool_getparam.h
a2d4e1
@@ -45,5 +45,11 @@ ParameterError getparameter(char *flag,
a2d4e1
                             bool *usedarg,
a2d4e1
                             struct Configurable *config);
a2d4e1
 
a2d4e1
+#ifdef UNITTESTS
a2d4e1
+void parse_cert_parameter(const char *cert_parameter,
a2d4e1
+                          char **certname,
a2d4e1
+                          char **passphrase);
a2d4e1
+#endif
a2d4e1
+
a2d4e1
 #endif /* HEADER_CURL_TOOL_GETPARAM_H */
a2d4e1
 
a2d4e1
diff --git a/tests/data/test1394 b/tests/data/test1394
a2d4e1
new file mode 100644
a2d4e1
index 0000000..34d4a0e
a2d4e1
--- /dev/null
a2d4e1
+++ b/tests/data/test1394
a2d4e1
@@ -0,0 +1,30 @@
a2d4e1
+<testcase>
a2d4e1
+<info>
a2d4e1
+<keywords>
a2d4e1
+unittest
a2d4e1
+</keywords>
a2d4e1
+</info>
a2d4e1
+
a2d4e1
+#
a2d4e1
+# Client-side
a2d4e1
+<client>
a2d4e1
+<server>
a2d4e1
+none
a2d4e1
+</server>
a2d4e1
+<features>
a2d4e1
+unittest
a2d4e1
+</features>
a2d4e1
+ <name>
a2d4e1
+unit test for parse_cert_parameter()
a2d4e1
+ </name>
a2d4e1
+<tool>
a2d4e1
+unit1394
a2d4e1
+</tool>
a2d4e1
+</client>
a2d4e1
+
a2d4e1
+<verify>
a2d4e1
+<stdout mode="text">
a2d4e1
+</stdout>
a2d4e1
+</verify>
a2d4e1
+
a2d4e1
+</testcase>
a2d4e1
diff --git a/tests/unit/Makefile.inc b/tests/unit/Makefile.inc
a2d4e1
index 20835d7..4490095 100644
a2d4e1
--- a/tests/unit/Makefile.inc
a2d4e1
+++ b/tests/unit/Makefile.inc
a2d4e1
@@ -6,7 +6,7 @@ UNITFILES = curlcheck.h \
a2d4e1
 
a2d4e1
 # These are all unit test programs
a2d4e1
 UNITPROGS = unit1300 unit1301 unit1302 unit1303 unit1304 unit1305 unit1307 \
a2d4e1
- unit1308 unit1309
a2d4e1
+ unit1308 unit1309 unit1394
a2d4e1
 
a2d4e1
 unit1300_SOURCES = unit1300.c $(UNITFILES)
a2d4e1
 unit1300_CPPFLAGS = $(AM_CPPFLAGS)
a2d4e1
@@ -35,3 +35,5 @@ unit1308_CPPFLAGS = $(AM_CPPFLAGS)
a2d4e1
 unit1309_SOURCES = unit1309.c $(UNITFILES)
a2d4e1
 unit1309_CPPFLAGS = $(AM_CPPFLAGS)
a2d4e1
 
a2d4e1
+unit1394_SOURCES = unit1394.c $(UNITFILES)
a2d4e1
+unit1394_CPPFLAGS = $(AM_CPPFLAGS)
a2d4e1
diff --git a/tests/unit/unit1394.c b/tests/unit/unit1394.c
a2d4e1
index 11a47b9..d25e4f5 100644
a2d4e1
--- a/tests/unit/unit1394.c
a2d4e1
+++ b/tests/unit/unit1394.c
a2d4e1
@@ -1,9 +1,48 @@
a2d4e1
+/***************************************************************************
a2d4e1
+ *                                  _   _ ____  _
a2d4e1
+ *  Project                     ___| | | |  _ \| |
a2d4e1
+ *                             / __| | | | |_) | |
a2d4e1
+ *                            | (__| |_| |  _ <| |___
a2d4e1
+ *                             \___|\___/|_| \_\_____|
a2d4e1
+ *
a2d4e1
+ * Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al.
a2d4e1
+ *
a2d4e1
+ * This software is licensed as described in the file COPYING, which
a2d4e1
+ * you should have received as part of this distribution. The terms
a2d4e1
+ * are also available at http://curl.haxx.se/docs/copyright.html.
a2d4e1
+ *
a2d4e1
+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
a2d4e1
+ * copies of the Software, and permit persons to whom the Software is
a2d4e1
+ * furnished to do so, under the terms of the COPYING file.
a2d4e1
+ *
a2d4e1
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
a2d4e1
+ * KIND, either express or implied.
a2d4e1
+ *
a2d4e1
+ ***************************************************************************/
a2d4e1
+#include "curlcheck.h"
a2d4e1
+
a2d4e1
+#include "tool_getparam.h"
a2d4e1
+
a2d4e1
 #include <stdio.h>
a2d4e1
 #include <stdlib.h>
a2d4e1
 #include <string.h>
a2d4e1
 
a2d4e1
-int main(int argc, char **argv) {
a2d4e1
-  char *values[] = {
a2d4e1
+#include "curl_memory.h"
a2d4e1
+#include "memdebug.h" /* LAST include file */
a2d4e1
+
a2d4e1
+static CURLcode unit_setup(void)
a2d4e1
+{
a2d4e1
+  return CURLE_OK;
a2d4e1
+}
a2d4e1
+
a2d4e1
+static void unit_stop(void)
a2d4e1
+{
a2d4e1
+
a2d4e1
+}
a2d4e1
+
a2d4e1
+UNITTEST_START
a2d4e1
+
a2d4e1
+  const char *values[] = {
a2d4e1
     /* -E parameter */        /* exp. cert name */  /* exp. passphrase */
a2d4e1
     "foo:bar:baz",            "foo",                "bar:baz",
a2d4e1
     "foo\\:bar:baz",          "foo:bar",            "baz",
a2d4e1
@@ -18,6 +57,7 @@ int main(int argc, char **argv) {
a2d4e1
     "foo:bar\\\\",            "foo",                "bar\\\\",
a2d4e1
     "foo:bar:",               "foo",                "bar:",
a2d4e1
     "foo\\::bar\\:",          "foo:",               "bar\\:",
a2d4e1
+#ifdef WIN32
a2d4e1
     "c:\\foo:bar:baz",        "c:\\foo",            "bar:baz",
a2d4e1
     "c:\\foo\\:bar:baz",      "c:\\foo:bar",        "baz",
a2d4e1
     "c:\\foo\\\\:bar:baz",    "c:\\foo\\",          "bar:baz",
a2d4e1
@@ -31,9 +71,10 @@ int main(int argc, char **argv) {
a2d4e1
     "c:\\foo:bar\\\\",        "c:\\foo",            "bar\\\\",
a2d4e1
     "c:\\foo:bar:",           "c:\\foo",            "bar:",
a2d4e1
     "c:\\foo\\::bar\\:",      "c:\\foo:",           "bar\\:",
a2d4e1
+#endif
a2d4e1
     NULL,                     NULL,                 NULL,
a2d4e1
   };
a2d4e1
-  char **p;
a2d4e1
+  const char **p;
a2d4e1
   char *certname, *passphrase;
a2d4e1
   for(p = values; *p; p += 3) {
a2d4e1
     parse_cert_parameter(p[0], &certname, &passphrase);
a2d4e1
@@ -42,15 +83,18 @@ int main(int argc, char **argv) {
a2d4e1
         if(strcmp(p[1], certname)) {
a2d4e1
           printf("expected certname '%s' but got '%s' "
a2d4e1
               "for -E param '%s'\n", p[1], certname, p[0]);
a2d4e1
+          fail("assertion failure");
a2d4e1
         }
a2d4e1
       } else {
a2d4e1
         printf("expected certname '%s' but got NULL "
a2d4e1
             "for -E param '%s'\n", p[1], p[0]);
a2d4e1
+        fail("assertion failure");
a2d4e1
       }
a2d4e1
     } else {
a2d4e1
       if(certname) {
a2d4e1
         printf("expected certname NULL but got '%s' "
a2d4e1
             "for -E param '%s'\n", certname, p[0]);
a2d4e1
+        fail("assertion failure");
a2d4e1
       }
a2d4e1
     }
a2d4e1
     if(p[2]) {
a2d4e1
@@ -58,18 +102,22 @@ int main(int argc, char **argv) {
a2d4e1
         if(strcmp(p[2], passphrase)) {
a2d4e1
           printf("expected passphrase '%s' but got '%s'"
a2d4e1
               "for -E param '%s'\n", p[2], passphrase, p[0]);
a2d4e1
+          fail("assertion failure");
a2d4e1
         }
a2d4e1
       } else {
a2d4e1
         printf("expected passphrase '%s' but got NULL "
a2d4e1
             "for -E param '%s'\n", p[2], p[0]);
a2d4e1
+        fail("assertion failure");
a2d4e1
       }
a2d4e1
     } else {
a2d4e1
       if(passphrase) {
a2d4e1
         printf("expected passphrase NULL but got '%s' "
a2d4e1
             "for -E param '%s'\n", passphrase, p[0]);
a2d4e1
+        fail("assertion failure");
a2d4e1
       }
a2d4e1
     }
a2d4e1
     if(certname) free(certname);
a2d4e1
     if(passphrase) free(passphrase);
a2d4e1
   }
a2d4e1
-}
a2d4e1
+
a2d4e1
+UNITTEST_STOP
a2d4e1
-- 
a2d4e1
2.7.4
a2d4e1
a2d4e1
a2d4e1
From fc2acbf743634f400efb8ec84748eed7267ead15 Mon Sep 17 00:00:00 2001
a2d4e1
From: Daniel Stenberg <daniel@haxx.se>
a2d4e1
Date: Sun, 19 May 2013 12:44:44 +0200
a2d4e1
Subject: [PATCH 09/10] tests: add test1394 file to the tarball
a2d4e1
a2d4e1
Upstream-commit: fc4759af9d9cbc7635af0da68c28672a4bbf35ff
a2d4e1
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
a2d4e1
---
a2d4e1
 tests/data/Makefile.am | 2 +-
a2d4e1
 1 file changed, 1 insertion(+), 1 deletion(-)
a2d4e1
a2d4e1
diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am
a2d4e1
index 35bc6eb..3b31581 100644
a2d4e1
--- a/tests/data/Makefile.am
a2d4e1
+++ b/tests/data/Makefile.am
a2d4e1
@@ -90,7 +90,7 @@ test1355 test1356 test1357 test1358 test1359 test1360 test1361 test1362 \
a2d4e1
 test1363 test1364 test1365 test1366 test1367 test1368 test1369 test1370 \
a2d4e1
 test1371 test1372 test1373 test1374 test1375 test1376 test1377 test1378 \
a2d4e1
 test1379 test1380 test1381 test1382 test1383 test1384 test1385 test1386 \
a2d4e1
-test1387 test1388 test1389 test1390 test1391 test1392 test1393 \
a2d4e1
+test1387 test1388 test1389 test1390 test1391 test1392 test1393 test1394 \
a2d4e1
 test1400 test1401 test1402 test1403 test1404 test1405 test1406 test1407 \
a2d4e1
 test1408 test1409 test1410 test1411 test1412 test1413 test1415 \
a2d4e1
 test1435 test1436 \
a2d4e1
-- 
a2d4e1
2.7.4
a2d4e1
a2d4e1
a2d4e1
From c4fe8629b69e4d5d642d3833a0208b2f65258d31 Mon Sep 17 00:00:00 2001
a2d4e1
From: Daniel Stenberg <daniel@haxx.se>
a2d4e1
Date: Thu, 29 Aug 2013 12:50:15 +0200
a2d4e1
Subject: [PATCH 10/10] unit1304: include memdebug and free everything
a2d4e1
 correctly
a2d4e1
a2d4e1
Upstream-commit: d737aa19c89f12c1415637a60afc79a6ea9c649f
a2d4e1
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
a2d4e1
---
a2d4e1
 tests/unit/unit1304.c | 7 +++++--
a2d4e1
 1 file changed, 5 insertions(+), 2 deletions(-)
a2d4e1
a2d4e1
diff --git a/tests/unit/unit1304.c b/tests/unit/unit1304.c
a2d4e1
index 9242e80..dcd8fa7 100644
a2d4e1
--- a/tests/unit/unit1304.c
a2d4e1
+++ b/tests/unit/unit1304.c
a2d4e1
@@ -5,7 +5,7 @@
a2d4e1
  *                            | (__| |_| |  _ <| |___
a2d4e1
  *                             \___|\___/|_| \_\_____|
a2d4e1
  *
a2d4e1
- * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
a2d4e1
+ * Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al.
a2d4e1
  *
a2d4e1
  * This software is licensed as described in the file COPYING, which
a2d4e1
  * you should have received as part of this distribution. The terms
a2d4e1
@@ -20,8 +20,8 @@
a2d4e1
  *
a2d4e1
  ***************************************************************************/
a2d4e1
 #include "curlcheck.h"
a2d4e1
-
a2d4e1
 #include "netrc.h"
a2d4e1
+#include "memdebug.h" /* LAST include file */
a2d4e1
 
a2d4e1
 static char *login;
a2d4e1
 static char *password;
a2d4e1
@@ -144,6 +144,9 @@ UNITTEST_START
a2d4e1
               "password should be 'none'");
a2d4e1
   fail_unless(strncmp(login, "none", 4) == 0, "login should be 'none'");
a2d4e1
 
a2d4e1
+  free(login);
a2d4e1
+  free(password);
a2d4e1
+
a2d4e1
   /* TODO:
a2d4e1
    * Test over the size limit password / login!
a2d4e1
    * Test files with a bad format
a2d4e1
-- 
a2d4e1
2.7.4
a2d4e1