components/curl/patches/017-CVE-2014-3707.patch
author saurabh.vyas@oracle.com
Mon, 01 Jun 2015 09:37:56 -0700
branchs11u2-sru
changeset 4443 19990f188a99
parent 3478 8406a8565edc
permissions -rw-r--r--
21148645 problem in SERVICE/HORIZON
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3478
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
     1
(This is based on the curl patch at:
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
     2
 http://curl.haxx.se/CVE-2014-3707.patch
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
     3
 but adjusted for curl version 7.21.2).
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
     4
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
     5
From 3696fc1ba79d9b34660c44150be5e93ecf87dd9e Mon Sep 17 00:00:00 2001
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
     6
From: Daniel Stenberg <[email protected]>
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
     7
Date: Fri, 17 Oct 2014 12:59:32 +0200
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
     8
Subject: [PATCH] curl_easy_duphandle: CURLOPT_COPYPOSTFIELDS read out of
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
     9
 bounds
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    10
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    11
When duplicating a handle, the data to post was duplicated using
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    12
strdup() when it could be binary and contain zeroes and it was not even
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    13
zero terminated! This caused read out of bounds crashes/segfaults.
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    14
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    15
Since the lib/strdup.c file no longer is easily shared with the curl
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    16
tool with this change, it now uses its own version instead.
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    17
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    18
Bug: http://curl.haxx.se/docs/adv_20141105.html
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    19
CVE: CVE-2014-3707
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    20
Reported-By: Symeon Paraschoudis
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    21
---
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    22
 lib/formdata.c    | 52 +++++++++-------------------------------------------
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    23
 lib/strdup.c      | 32 +++++++++++++++++++++++++++-----
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    24
 lib/strdup.h      |  3 ++-
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    25
 lib/url.c         | 22 +++++++++++++++++-----
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    26
 lib/urldata.h     | 11 +++++++++--
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    27
 src/Makefile.inc  |  4 ++--
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    28
 src/tool_setup.h  |  5 ++---
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    29
 src/tool_strdup.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    30
 src/tool_strdup.h | 30 ++++++++++++++++++++++++++++++
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    31
 9 files changed, 145 insertions(+), 61 deletions(-)
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    32
 create mode 100644 src/tool_strdup.c
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    33
 create mode 100644 src/tool_strdup.h
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    34
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    35
--- lib/formdata.c.orig	2014-11-18 03:29:06.861398190 -0800
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    36
+++ lib/formdata.c	2014-11-18 03:33:25.634942129 -0800
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    37
@@ -123,6 +123,7 @@
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    38
 #include "curl_rand.h"
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    39
 #include "strequal.h"
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    40
 #include "curl_memory.h"
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    41
+#include "strdup.h"
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    42
 
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    43
 #define _MPRINTF_REPLACE /* use our functions only */
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    44
 #include <curl/mprintf.h>
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    45
@@ -302,46 +303,6 @@
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    46
 
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    47
 /***************************************************************************
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    48
  *
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    49
- * memdup()
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    50
- *
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    51
- * Copies the 'source' data to a newly allocated buffer buffer (that is
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    52
- * returned). Uses buffer_length if not null, else uses strlen to determine
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    53
- * the length of the buffer to be copied
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    54
- *
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    55
- * Returns the new pointer or NULL on failure.
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    56
- *
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    57
- ***************************************************************************/
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    58
-static char *memdup(const char *src, size_t buffer_length)
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    59
-{
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    60
-  size_t length;
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    61
-  bool add = FALSE;
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    62
-  char *buffer;
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    63
-
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    64
-  if(buffer_length)
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    65
-    length = buffer_length;
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    66
-  else if(src) {
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    67
-    length = strlen(src);
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    68
-    add = TRUE;
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    69
-  }
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    70
-  else
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    71
-    /* no length and a NULL src pointer! */
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    72
-    return strdup("");
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    73
-
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    74
-  buffer = malloc(length+add);
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    75
-  if(!buffer)
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    76
-    return NULL; /* fail */
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    77
-
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    78
-  memcpy(buffer, src, length);
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    79
-
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    80
-  /* if length unknown do null termination */
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    81
-  if(add)
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    82
-    buffer[length] = '\0';
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    83
-
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    84
-  return buffer;
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    85
-}
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    86
-
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    87
-/***************************************************************************
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    88
- *
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    89
  * FormAdd()
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    90
  *
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    91
  * Stores a formpost parameter and builds the appropriate linked list.
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    92
@@ -745,9 +706,12 @@
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    93
              (form == first_form) ) {
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    94
           /* Note that there's small risk that form->name is NULL here if the
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    95
              app passed in a bad combo, so we better check for that first. */
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    96
-          if(form->name)
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    97
+          if(form->name) {
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    98
             /* copy name (without strdup; possibly contains null characters) */
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    99
-            form->name = memdup(form->name, form->namelength);
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   100
+            form->name = Curl_memdup(form->name, form->namelength?
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   101
+                                     form->namelength:
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   102
+                                     strlen(form->name)+1);
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   103
+          }
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   104
           if(!form->name) {
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   105
             return_value = CURL_FORMADD_MEMORY;
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   106
             break;
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   107
@@ -758,7 +722,9 @@
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   108
                              HTTPPOST_PTRCONTENTS | HTTPPOST_PTRBUFFER |
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   109
                              HTTPPOST_CALLBACK)) ) {
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   110
           /* copy value (without strdup; possibly contains null characters) */
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   111
-          form->value = memdup(form->value, form->contentslength);
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   112
+          form->value = Curl_memdup(form->value, form->contentslength?
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   113
+                                    form->contentslength:
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   114
+                                    strlen(form->value)+1);
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   115
           if(!form->value) {
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   116
             return_value = CURL_FORMADD_MEMORY;
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   117
             break;
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   118
--- lib/strdup.c.orig	2014-11-18 03:34:47.615106130 -0800
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   119
+++ lib/strdup.c	2014-11-18 03:36:24.540240128 -0800
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   120
@@ -5,7 +5,7 @@
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   121
  *                            | (__| |_| |  _ <| |___
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   122
  *                             \___|\___/|_| \_\_____|
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   123
  *
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   124
- * Copyright (C) 1998 - 2008, Daniel Stenberg, <[email protected]>, et al.
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   125
+ * Copyright (C) 1998 - 2014, Daniel Stenberg, <[email protected]>, et al.
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   126
  *
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   127
  * This software is licensed as described in the file COPYING, which
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   128
  * you should have received as part of this distribution. The terms
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   129
@@ -22,6 +22,10 @@
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   130
 
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   131
 #include "setup.h"
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   132
 #include "strdup.h"
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   133
+#include "curl_memory.h"
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   134
+
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   135
+/* The last #include file should be: */
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   136
+#include "memdebug.h"
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   137
 
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   138
 #ifndef HAVE_STRDUP
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   139
 char *curlx_strdup(const char *str)
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   140
@@ -47,3 +51,25 @@
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   141
 
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   142
 }
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   143
 #endif
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   144
+
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   145
+/***************************************************************************
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   146
+ *
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   147
+ * Curl_memdup(source, length)
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   148
+ *
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   149
+ * Copies the 'source' data to a newly allocated buffer (that is
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   150
+ * returned). Copies 'length' bytes.
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   151
+ *
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   152
+ * Returns the new pointer or NULL on failure.
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   153
+ *
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   154
+ ***************************************************************************/
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   155
+char *Curl_memdup(const char *src, size_t length)
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   156
+{
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   157
+  char *buffer = malloc(length);
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   158
+  if(!buffer)
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   159
+    return NULL; /* fail */
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   160
+
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   161
+  memcpy(buffer, src, length);
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   162
+
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   163
+  /* if length unknown do null termination */
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   164
+  return buffer;
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   165
+}
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   166
--- lib/strdup.h.orig	2014-11-18 03:37:29.169630451 -0800
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   167
+++ lib/strdup.h	2014-11-18 03:37:58.420841595 -0800
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   168
@@ -7,7 +7,7 @@
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   169
  *                            | (__| |_| |  _ <| |___
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   170
  *                             \___|\___/|_| \_\_____|
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   171
  *
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   172
- * Copyright (C) 1998 - 2010, Daniel Stenberg, <[email protected]>, et al.
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   173
+ * Copyright (C) 1998 - 2014, Daniel Stenberg, <[email protected]>, et al.
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   174
  *
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   175
  * This software is licensed as described in the file COPYING, which
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   176
  * you should have received as part of this distribution. The terms
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   177
@@ -26,5 +26,6 @@
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   178
 #ifndef HAVE_STRDUP
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   179
 extern char *curlx_strdup(const char *str);
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   180
 #endif
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   181
+char *Curl_memdup(const char *src, size_t buffer_length);
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   182
 
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   183
 #endif /* HEADER_CURL_STRDUP_H */
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   184
--- lib/url.c.orig	2014-11-18 03:38:54.137970835 -0800
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   185
+++ lib/url.c	2014-11-18 03:43:13.569265802 -0800
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   186
@@ -139,6 +139,7 @@
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   187
 #include "rtsp.h"
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   188
 #include "curl_rtmp.h"
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   189
 #include "gopher.h"
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   190
+#include "strdup.h"
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   191
 
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   192
 #define _MPRINTF_REPLACE /* use our functions only */
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   193
 #include <curl/mprintf.h>
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   194
@@ -284,8 +285,9 @@
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   195
 {
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   196
   /* Free all dynamic strings stored in the data->set substructure. */
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   197
   enum dupstring i;
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   198
-  for(i=(enum dupstring)0; i < STRING_LAST; i++)
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   199
+  for(i=(enum dupstring)0; i < STRING_LAST; i++) {
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   200
     Curl_safefree(data->set.str[i]);
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   201
+  }
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   202
 }
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   203
 
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   204
 static CURLcode setstropt(char **charp, char * s)
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   205
@@ -365,14 +367,24 @@
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   206
   memset(dst->set.str, 0, STRING_LAST * sizeof(char *));
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   207
 
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   208
   /* duplicate all strings */
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   209
-  for(i=(enum dupstring)0; i< STRING_LAST; i++) {
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   210
+  for(i=(enum dupstring)0; i< STRING_LASTZEROTERMINATED; i++) {
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   211
     r = setstropt(&dst->set.str[i], src->set.str[i]);
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   212
     if(r != CURLE_OK)
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   213
-      break;
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   214
+      return r;
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   215
   }
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   216
 
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   217
-  /* If a failure occurred, freeing has to be performed externally. */
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   218
-  return r;
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   219
+  /* duplicate memory areas pointed to */
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   220
+  i = STRING_COPYPOSTFIELDS;
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   221
+  if(src->set.postfieldsize && src->set.str[i]) {
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   222
+    /* postfieldsize is curl_off_t, Curl_memdup() takes a size_t ... */
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   223
+    dst->set.str[i] = Curl_memdup(src->set.str[i], src->set.postfieldsize);
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   224
+    if(!dst->set.str[i])
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   225
+      return CURLE_OUT_OF_MEMORY;
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   226
+    /* point to the new copy */
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   227
+    dst->set.postfields = dst->set.str[i];
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   228
+  }
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   229
+
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   230
+  return CURLE_OK;
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   231
 }
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   232
 
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   233
 #if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_COOKIES)
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   234
--- lib/urldata.h.orig	2014-11-18 03:44:28.965134703 -0800
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   235
+++ lib/urldata.h	2014-11-18 03:46:24.706226763 -0800
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   236
@@ -1216,7 +1216,6 @@
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   237
   STRING_KRB_LEVEL,       /* krb security level */
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   238
   STRING_NETRC_FILE,      /* if not NULL, use this instead of trying to find
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   239
                              $HOME/.netrc */
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   240
-  STRING_COPYPOSTFIELDS,  /* if POST, set the fields' values here */
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   241
   STRING_PROXY,           /* proxy to use */
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   242
   STRING_SET_RANGE,       /* range, if used */
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   243
   STRING_SET_REFERER,     /* custom string for the HTTP referer field */
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   244
@@ -1249,7 +1248,15 @@
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   245
 #endif
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   246
   STRING_MAIL_FROM,
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   247
 
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   248
-  /* -- end of strings -- */
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   249
+  /* -- end of zero-terminated strings -- */
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   250
+
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   251
+  STRING_LASTZEROTERMINATED,
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   252
+
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   253
+  /* -- below this are pointers to binary data that cannot be strdup'ed.
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   254
+     Each such pointer must be added manually to Curl_dupset() --- */
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   255
+
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   256
+  STRING_COPYPOSTFIELDS,  /* if POST, set the fields' values here */
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   257
+
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   258
   STRING_LAST /* not used, just an end-of-list marker */
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   259
 };
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   260
 
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   261
--- src/Makefile.inc.orig	2014-11-18 03:47:49.286734214 -0800
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   262
+++ src/Makefile.inc	2014-11-18 03:52:27.133161024 -0800
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   263
@@ -10,15 +10,16 @@
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   264
 # libcurl has sources that provide functions named curlx_* that aren't part of
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   265
 # the official API, but we re-use the code here to avoid duplication.
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   266
 CURLX_ONES = $(top_srcdir)/lib/strtoofft.c \
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   267
-	$(top_srcdir)/lib/strdup.c \
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   268
 	$(top_srcdir)/lib/rawstr.c \
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   269
 	$(top_srcdir)/lib/nonblock.c
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   270
 
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   271
 CURL_CFILES = main.c hugehelp.c urlglob.c writeout.c writeenv.c \
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   272
-	getpass.c homedir.c curlutil.c os-specific.c
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   273
+	getpass.c homedir.c curlutil.c os-specific.c \
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   274
+	tool_strdup.c
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   275
 
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   276
 CURL_HFILES = hugehelp.h setup.h config-win32.h config-mac.h \
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   277
 	config-riscos.h urlglob.h version.h os-specific.h \
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   278
+	tool_strdup.h \
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   279
 	writeout.h writeenv.h getpass.h homedir.h curlutil.h
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   280
 
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   281
 curl_SOURCES = $(CURL_CFILES) $(CURLX_ONES) $(CURL_HFILES)
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   282
--- src/setup.h.orig	2014-11-18 03:54:19.162704002 -0800
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   283
+++ src/setup.h	2014-11-18 03:55:05.389517301 -0800
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   284
@@ -7,7 +7,7 @@
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   285
  *                            | (__| |_| |  _ <| |___
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   286
  *                             \___|\___/|_| \_\_____|
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   287
  *
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   288
- * Copyright (C) 1998 - 2010, Daniel Stenberg, <[email protected]>, et al.
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   289
+ * Copyright (C) 1998 - 2014, Daniel Stenberg, <[email protected]>, et al.
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   290
  *
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   291
  * This software is licensed as described in the file COPYING, which
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   292
  * you should have received as part of this distribution. The terms
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   293
@@ -203,8 +203,7 @@
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   294
 #endif
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   295
 
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   296
 #ifndef HAVE_STRDUP
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   297
-#include "strdup.h"
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   298
-#define strdup(ptr) curlx_strdup(ptr)
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   299
+#  include "tool_strdup.h"
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   300
 #endif
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   301
 
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   302
 /* Define S_ISREG if not defined by system headers, f.e. MSVC */
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   303
--- src/tool_strdup.c.orig	2014-11-18 03:56:00.122473188 -0800
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   304
+++ src/tool_strdup.c	2014-11-18 03:57:10.023119420 -0800
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   305
@@ -0,0 +1,47 @@
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   306
+/***************************************************************************
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   307
+ *                                  _   _ ____  _
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   308
+ *  Project                     ___| | | |  _ \| |
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   309
+ *                             / __| | | | |_) | |
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   310
+ *                            | (__| |_| |  _ <| |___
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   311
+ *                             \___|\___/|_| \_\_____|
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   312
+ *
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   313
+ * Copyright (C) 1998 - 2014, Daniel Stenberg, <[email protected]>, et al.
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   314
+ *
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   315
+ * This software is licensed as described in the file COPYING, which
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   316
+ * you should have received as part of this distribution. The terms
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   317
+ * are also available at http://curl.haxx.se/docs/copyright.html.
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   318
+ *
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   319
+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   320
+ * copies of the Software, and permit persons to whom the Software is
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   321
+ * furnished to do so, under the terms of the COPYING file.
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   322
+ *
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   323
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   324
+ * KIND, either express or implied.
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   325
+ *
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   326
+ ***************************************************************************/
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   327
+#include "strdup.h"
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   328
+
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   329
+#ifndef HAVE_STRDUP
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   330
+char *strdup(const char *str)
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   331
+{
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   332
+  size_t len;
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   333
+  char *newstr;
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   334
+
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   335
+  if(!str)
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   336
+    return (char *)NULL;
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   337
+
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   338
+  len = strlen(str);
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   339
+
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   340
+  if(len >= ((size_t)-1) / sizeof(char))
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   341
+    return (char *)NULL;
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   342
+
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   343
+  newstr = malloc((len+1)*sizeof(char));
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   344
+  if(!newstr)
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   345
+    return (char *)NULL;
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   346
+
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   347
+  memcpy(newstr,str,(len+1)*sizeof(char));
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   348
+
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   349
+  return newstr;
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   350
+
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   351
+}
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   352
+#endif
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   353
--- src/tool_strdup.h.orig	2014-11-18 03:57:45.315222626 -0800
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   354
+++ src/tool_strdup.h	2014-11-18 03:58:13.983815925 -0800
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   355
@@ -0,0 +1,30 @@
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   356
+#ifndef HEADER_TOOL_STRDUP_H
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   357
+#define HEADER_TOOL_STRDUP_H
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   358
+/***************************************************************************
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   359
+ *                                  _   _ ____  _
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   360
+ *  Project                     ___| | | |  _ \| |
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   361
+ *                             / __| | | | |_) | |
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   362
+ *                            | (__| |_| |  _ <| |___
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   363
+ *                             \___|\___/|_| \_\_____|
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   364
+ *
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   365
+ * Copyright (C) 1998 - 2014, Daniel Stenberg, <[email protected]>, et al.
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   366
+ *
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   367
+ * This software is licensed as described in the file COPYING, which
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   368
+ * you should have received as part of this distribution. The terms
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   369
+ * are also available at http://curl.haxx.se/docs/copyright.html.
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   370
+ *
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   371
+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   372
+ * copies of the Software, and permit persons to whom the Software is
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   373
+ * furnished to do so, under the terms of the COPYING file.
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   374
+ *
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   375
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   376
+ * KIND, either express or implied.
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   377
+ *
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   378
+ ***************************************************************************/
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   379
+#include "tool_setup.h"
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   380
+
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   381
+#ifndef HAVE_STRDUP
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   382
+extern char *strdup(const char *str);
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   383
+#endif
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   384
+
8406a8565edc 20047275 problem in LIBRARY/CURL
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
   385
+#endif /* HEADER_TOOL_STRDUP_H */