~ubuntu-branches/ubuntu/lucid/curl/lucid-security

« back to all changes in this revision

Viewing changes to tests/server/getpart.c

  • Committer: Bazaar Package Importer
  • Author(s): Michael Vogt
  • Date: 2009-04-29 11:10:29 UTC
  • mfrom: (3.2.3 sid)
  • Revision ID: james.westby@ubuntu.com-20090429111029-2j5eiyokfw2bw049
Tags: 7.19.4-1ubuntu1
* Merge from debian unstable, remaining changes:
  - Drop build dependencies: stunnel, libdb4.6-dev, libssh2-1-dev
  - Add build-dependency on openssh-server
  - Drop libssh2-1-dev from libcurl4-openssl-dev's Depends.
  - Call automake-1.9 with --add-missing --copy --force
* drop debian/patches/security_CVE-2009-0037.patch 
  - this patch is part of 7.19.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19
19
 * KIND, either express or implied.
20
20
 *
21
 
 * $Id: getpart.c,v 1.24 2008-02-28 00:55:06 yangtse Exp $
 
21
 * $Id: getpart.c,v 1.28 2008-10-23 14:07:28 yangtse Exp $
22
22
 ***************************************************************************/
23
23
 
24
24
#include "setup.h"
33
33
  int fake;
34
34
};
35
35
 
36
 
#include "base64.h"
 
36
#include "curl_base64.h"
 
37
#include "memory.h"
37
38
 
38
39
/* include memdebug.h last */
39
40
#include "memdebug.h"
48
49
#define show(x)
49
50
#endif
50
51
 
 
52
#if defined(_MSC_VER) && defined(_DLL)
 
53
#  pragma warning(disable:4232) /* MSVC extension, dllimport identity */
 
54
#endif
 
55
 
51
56
curl_malloc_callback Curl_cmalloc = (curl_malloc_callback)malloc;
52
57
curl_free_callback Curl_cfree = (curl_free_callback)free;
53
58
curl_realloc_callback Curl_crealloc = (curl_realloc_callback)realloc;
54
59
curl_strdup_callback Curl_cstrdup = (curl_strdup_callback)strdup;
55
60
curl_calloc_callback Curl_ccalloc = (curl_calloc_callback)calloc;
56
61
 
 
62
#if defined(_MSC_VER) && defined(_DLL)
 
63
#  pragma warning(default:4232) /* MSVC extension, dllimport identity */
 
64
#endif
 
65
 
57
66
static
58
67
char *appendstring(char *string, /* original string */
59
68
                   char *buffer, /* to append */
61
70
                   size_t *stralloc,  /* allocated size */
62
71
                   char base64) /* 1 if base64 encoded */
63
72
{
 
73
  union {
 
74
    unsigned char * as_uchar;
 
75
             char * as_char;
 
76
  } buf64;
 
77
 
64
78
  size_t len = strlen(buffer);
65
79
  size_t needed_len = len + *stringlen + 1;
66
 
  char *buf64=NULL;
 
80
 
 
81
  buf64.as_char = NULL;
67
82
 
68
83
  if(base64) {
69
84
    /* decode the given buffer first */
70
 
    len = Curl_base64_decode(buffer, (unsigned char**)&buf64); /* updated len */
71
 
    buffer = buf64;
 
85
    len = Curl_base64_decode(buffer, &buf64.as_uchar); /* updated len */
 
86
    buffer = buf64.as_char;
72
87
    needed_len = len + *stringlen + 1; /* recalculate */
73
88
  }
74
89
 
82
97
      *stralloc = newsize;
83
98
    }
84
99
    else {
85
 
      if(buf64)
86
 
        free(buf64);
 
100
      if(buf64.as_char)
 
101
        free(buf64.as_char);
87
102
      return NULL;
88
103
    }
89
104
  }
92
107
  *stringlen += len;
93
108
  string[*stringlen]=0;
94
109
 
95
 
  if(buf64)
96
 
    free(buf64);
 
110
  if(buf64.as_char)
 
111
    free(buf64.as_char);
97
112
 
98
113
  return string;
99
114
}
122
137
    STATE_ILLEGAL
123
138
  } state = STATE_OUTSIDE;
124
139
 
125
 
  string = (char *)malloc(stralloc);
 
140
  string = malloc(stralloc);
126
141
  if(!string)
127
142
    return NULL;
128
143