~ubuntu-branches/ubuntu/natty/curl/natty-security

« back to all changes in this revision

Viewing changes to lib/escape.c

  • Committer: Bazaar Package Importer
  • Author(s): Bhavani Shankar
  • Date: 2010-06-20 13:56:28 UTC
  • mfrom: (3.4.7 sid)
  • Revision ID: james.westby@ubuntu.com-20100620135628-e30tp9jldq6hq985
Tags: 7.21.0-1ubuntu1
* Merge from debian unstable.  Remaining changes: LP: #596334
  - Keep build deps in main:
    - Drop build dependencies: stunnel, libssh2-1-dev
    - Add build-dependency on openssh-server
    - Drop libssh2-1-dev from libcurl4-openssl-dev's Depends.

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
 *                            | (__| |_| |  _ <| |___
6
6
 *                             \___|\___/|_| \_\_____|
7
7
 *
8
 
 * Copyright (C) 1998 - 2009, Daniel Stenberg, <daniel@haxx.se>, et al.
 
8
 * Copyright (C) 1998 - 2010, Daniel Stenberg, <daniel@haxx.se>, et al.
9
9
 *
10
10
 * This software is licensed as described in the file COPYING, which
11
11
 * you should have received as part of this distribution. The terms
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: escape.c,v 1.45 2009-04-21 11:46:16 yangtse Exp $
22
21
 ***************************************************************************/
23
22
 
24
23
/* Escape and unescape URL encoding in strings. The functions return a new
35
34
/* urldata.h and easyif.h are included for Curl_convert_... prototypes */
36
35
#include "urldata.h"
37
36
#include "easyif.h"
 
37
#include "warnless.h"
38
38
 
39
39
#define _MPRINTF_REPLACE /* use our functions only */
40
40
#include <curl/mprintf.h>
103
103
    if (Curl_isalnum(in)) {
104
104
      /* just copy this */
105
105
      ns[strindex++]=in;
106
 
    } else {
 
106
    }
 
107
    else {
107
108
      /* encode it */
108
109
      newlen += 2; /* the size grows with two, since this'll become a %XX */
109
110
      if(newlen > alloc) {
151
152
  char *ns = malloc(alloc);
152
153
  unsigned char in;
153
154
  int strindex=0;
154
 
  long hex;
 
155
  unsigned long hex;
155
156
 
156
157
#ifndef CURL_DOES_CONVERSIONS
157
158
  /* avoid compiler warnings */
170
171
      hexstr[1] = string[2];
171
172
      hexstr[2] = 0;
172
173
 
173
 
      hex = strtol(hexstr, &ptr, 16);
 
174
      hex = strtoul(hexstr, &ptr, 16);
174
175
 
175
 
      in = (unsigned char)hex; /* this long is never bigger than 255 anyway */
 
176
      in = curlx_ultouc(hex); /* this long is never bigger than 255 anyway */
176
177
 
177
178
#ifdef CURL_DOES_CONVERSIONS
178
179
/* escape sequences are always in ASCII so convert them on non-ASCII hosts */