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

« back to all changes in this revision

Viewing changes to lib/hostares.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:
5
5
 *                            | (__| |_| |  _ <| |___
6
6
 *                             \___|\___/|_| \_\_____|
7
7
 *
8
 
 * Copyright (C) 1998 - 2008, Daniel Stenberg, <daniel@haxx.se>, et al.
 
8
 * Copyright (C) 1998 - 2009, 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: hostares.c,v 1.37 2008-04-29 04:18:02 yangtse Exp $
 
21
 * $Id: hostares.c,v 1.46 2009-01-31 20:25:56 bagder Exp $
22
22
 ***************************************************************************/
23
23
 
24
24
#include "setup.h"
52
52
#include <stdlib.h>
53
53
#endif
54
54
 
55
 
#ifdef HAVE_SETJMP_H
56
 
#include <setjmp.h>
57
 
#endif
58
 
 
59
55
#ifdef HAVE_PROCESS_H
60
56
#include <process.h>
61
57
#endif
73
69
#include "strerror.h"
74
70
#include "url.h"
75
71
#include "multiif.h"
 
72
#include "inet_pton.h"
76
73
#include "connect.h"
77
74
#include "select.h"
78
75
 
79
76
#define _MPRINTF_REPLACE /* use our functions only */
80
77
#include <curl/mprintf.h>
81
78
 
82
 
#if defined(HAVE_INET_NTOA_R) && !defined(HAVE_INET_NTOA_R_DECL)
83
 
#include "inet_ntoa_r.h"
84
 
#endif
85
 
 
86
79
#include "memory.h"
87
 
 
88
80
/* The last #include file should be: */
89
81
#include "memdebug.h"
90
82
 
297
289
  return rc;
298
290
}
299
291
 
 
292
 
300
293
/*
301
294
 * Curl_getaddrinfo() - when using ares
302
295
 *
312
305
{
313
306
  char *bufp;
314
307
  struct SessionHandle *data = conn->data;
315
 
  in_addr_t in = inet_addr(hostname);
316
 
 
 
308
  struct in_addr in;
 
309
  int family = PF_INET;
 
310
#ifdef ENABLE_IPV6 /* CURLRES_IPV6 */
 
311
  struct in6_addr in6;
 
312
#endif /* CURLRES_IPV6 */
317
313
  *waitp = FALSE;
318
314
 
319
 
  if(in != CURL_INADDR_NONE) {
 
315
  /* First check if this is an IPv4 address string */
 
316
  if(Curl_inet_pton(AF_INET, hostname, &in) > 0) {
320
317
    /* This is a dotted IP address 123.123.123.123-style */
321
 
    return Curl_ip2addr(in, hostname, port);
322
 
  }
 
318
    return Curl_ip2addr(AF_INET, &in, hostname, port);
 
319
  }
 
320
 
 
321
#ifdef ENABLE_IPV6 /* CURLRES_IPV6 */
 
322
  /* Otherwise, check if this is an IPv6 address string */
 
323
  if (Curl_inet_pton (AF_INET6, hostname, &in6) > 0) {
 
324
    /* This must be an IPv6 address literal.  */
 
325
    return Curl_ip2addr(AF_INET6, &in6, hostname, port);
 
326
  }
 
327
 
 
328
  switch(data->set.ip_version) {
 
329
  default:
 
330
#if ARES_VERSION >= 0x010601
 
331
    family = PF_UNSPEC; /* supported by c-ares since 1.6.1, so for older
 
332
                           c-ares versions this just falls through and defaults
 
333
                           to PF_INET */
 
334
    break;
 
335
#endif
 
336
  case CURL_IPRESOLVE_V4:
 
337
    family = PF_INET;
 
338
    break;
 
339
  case CURL_IPRESOLVE_V6:
 
340
    family = PF_INET6;
 
341
    break;
 
342
  }
 
343
#endif /* CURLRES_IPV6 */
323
344
 
324
345
  bufp = strdup(hostname);
325
346
 
332
353
    conn->async.dns = NULL;   /* clear */
333
354
 
334
355
    /* areschannel is already setup in the Curl_open() function */
335
 
    ares_gethostbyname(data->state.areschannel, hostname, PF_INET,
 
356
    ares_gethostbyname(data->state.areschannel, hostname, family,
336
357
                       (ares_host_callback)Curl_addrinfo4_callback, conn);
337
358
 
338
359
    *waitp = TRUE; /* please wait for the response */