Commit bb93ccc0 authored by Omer Katz's avatar Omer Katz

Upgraded c-ares to 1.10.0

parent 59440100
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -24,8 +24,6 @@ You'll find all c-ares details and news here:
NOTES FOR C-ARES HACKERS
The following notes apply to c-ares version 1.7.0 and later.
* The distributed ares_build.h file is only intended to be used on systems
which can not run the also distributed configure script.
......
c-ares version 1.9.1
c-ares version 1.10.0
Fixed:
Changes:
o Added ares_create_query(), to be used instead of ares_mkquery()
o ares_inet_ntop() and ares_inet_pton() are now recognized c-ares functions
Bug fixes:
o include the ares_parse_soa_reply.* files in the tarball
o read_udp_packets: bail out loop on bad sockets
o get_DNS_AdaptersAddresses: fix IPv6 parsing
o adig: perror() doesn't work for socket errors on windows
o ares_parse_aaaa_reply: fix memory leak
o setup_once.h: HP-UX <sys/socket.h> issue workaround
o configure: several fixes
o config-dos.h: define strerror() to strerror_s_() for High-C
o config-dos.h: define HAVE_CLOSE_S for MSDOS/Watt-32
o ares_build.h.dist: enhance non-configure GCC ABI detection logic
o ares.h: stricter CARES_EXTERN linkage decorations logic
o ares_cancel(): cancel requests safely
o protocol parsing: check input data stricter
o library init: be recursive, reference count inits/cleanups
o ares_parse_txt_reply: return a ares_txt_reply node for each sub-string
o ares_set_servers_csv: fixed IPv6 address parsing
o build: fix build on msvc11
Thanks go to these friendly people for their efforts and contributions:
Eugeny Gladkih
Eugeny Gladkih, Yang Tse, Gisle Vanem, Guenter Knauf, Horatiu Popescu,
Alexander Klauer, Patrick Valsecchi, Paul Saab, Keith Shaw,
Alex Loukissas
Have fun!
/* Copyright 1998, 2009 by the Massachusetts Institute of Technology.
* Copyright (C) 2007-2011 by Daniel Stenberg
/* Copyright 1998 by the Massachusetts Institute of Technology.
* Copyright (C) 2007-2013 by Daniel Stenberg
*
* Permission to use, copy, modify, and distribute this
* software and its documentation for any purpose and without
......@@ -75,22 +75,18 @@ extern "C" {
** c-ares external API function linkage decorations.
*/
#if !defined(CARES_STATICLIB) && \
(defined(WIN32) || defined(_WIN32) || defined(__SYMBIAN32__))
/* __declspec function decoration for Win32 and Symbian DLL's */
#ifdef CARES_STATICLIB
# define CARES_EXTERN
#elif defined(WIN32) || defined(_WIN32) || defined(__SYMBIAN32__)
# if defined(CARES_BUILDING_LIBRARY)
# define CARES_EXTERN __declspec(dllexport)
# else
# define CARES_EXTERN __declspec(dllimport)
# endif
#elif defined(CARES_BUILDING_LIBRARY) && defined(CARES_SYMBOL_HIDING)
# define CARES_EXTERN CARES_SYMBOL_SCOPE_EXTERN
#else
/* visibility function decoration for other cases */
# if !defined(CARES_SYMBOL_HIDING) || \
defined(WIN32) || defined(_WIN32) || defined(__SYMBIAN32__)
# define CARES_EXTERN
# else
# define CARES_EXTERN CARES_SYMBOL_SCOPE_EXTERN
# endif
# define CARES_EXTERN
#endif
......@@ -553,8 +549,6 @@ CARES_EXTERN void ares_free_string(void *str);
CARES_EXTERN void ares_free_hostent(struct hostent *host);
CARES_EXTERN void ares_free_soa(struct ares_soa_reply *soa);
CARES_EXTERN void ares_free_data(void *dataptr);
CARES_EXTERN const char *ares_strerror(int code);
......@@ -579,6 +573,12 @@ CARES_EXTERN int ares_set_servers_csv(ares_channel channel,
CARES_EXTERN int ares_get_servers(ares_channel channel,
struct ares_addr_node **servers);
CARES_EXTERN const char *ares_inet_ntop(int af, const void *src, char *dst,
ares_socklen_t size);
CARES_EXTERN int ares_inet_pton(int af, const char *src, void *dst);
#ifdef __cplusplus
}
#endif
......
......@@ -16,11 +16,6 @@
#include "ares_setup.h"
#include <stdlib.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include "ares.h"
#include "ares_private.h"
......
......@@ -16,9 +16,6 @@
#include "ares_setup.h"
#ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h>
#endif
#ifdef HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
......@@ -30,7 +27,7 @@
#endif
#include "ares.h"
#include "inet_net_pton.h"
#include "ares_inet_net_pton.h"
#include "ares_nowarn.h"
#include "ares_private.h"
......
......@@ -15,9 +15,7 @@
*/
#include "ares_setup.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "ares.h"
#include "ares_nowarn.h"
#include "ares_private.h"
......
#ifndef __CARES_BUILD_H
#define __CARES_BUILD_H
/* Copyright (C) 2009 - 2013 by Daniel Stenberg et al
*
* Permission to use, copy, modify, and distribute this software and its
* documentation for any purpose and without fee is hereby granted, provided
* that the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of M.I.T. not be used in advertising or
* publicity pertaining to distribution of the software without specific,
* written prior permission. M.I.T. makes no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
*/
/* ================================================================ */
/* NOTES FOR CONFIGURE CAPABLE SYSTEMS */
/* ================================================================ */
/*
* NOTE 1:
* -------
*
* See file ares_build.h.in, run configure, and forget that this file
* exists it is only used for non-configure systems.
* But you can keep reading if you want ;-)
*
*/
/* ================================================================ */
/* NOTES FOR NON-CONFIGURE SYSTEMS */
/* ================================================================ */
/*
* NOTE 1:
* -------
*
* Nothing in this file is intended to be modified or adjusted by the
* c-ares library user nor by the c-ares library builder.
*
* If you think that something actually needs to be changed, adjusted
* or fixed in this file, then, report it on the c-ares development
* mailing list: http://cool.haxx.se/mailman/listinfo/c-ares/
*
* Try to keep one section per platform, compiler and architecture,
* otherwise, if an existing section is reused for a different one and
* later on the original is adjusted, probably the piggybacking one can
* be adversely changed.
*
* In order to differentiate between platforms/compilers/architectures
* use only compiler built in predefined preprocessor symbols.
*
* This header file shall only export symbols which are 'cares' or 'CARES'
* prefixed, otherwise public name space would be polluted.
*
* NOTE 2:
* -------
*
* Right now you might be staring at file ares_build.h.dist or ares_build.h,
* this is due to the following reason: file ares_build.h.dist is renamed
* to ares_build.h when the c-ares source code distribution archive file is
* created.
*
* File ares_build.h.dist is not included in the distribution archive.
* File ares_build.h is not present in the git tree.
*
* The distributed ares_build.h file is only intended to be used on systems
* which can not run the also distributed configure script.
*
* On systems capable of running the configure script, the configure process
* will overwrite the distributed ares_build.h file with one that is suitable
* and specific to the library being configured and built, which is generated
* from the ares_build.h.in template file.
*
* If you check out from git on a non-configure platform, you must run the
* appropriate buildconf* script to set up ares_build.h and other local files.
*
*/
/* ================================================================ */
/* DEFINITION OF THESE SYMBOLS SHALL NOT TAKE PLACE ANYWHERE ELSE */
/* ================================================================ */
#ifdef CARES_SIZEOF_LONG
# error "CARES_SIZEOF_LONG shall not be defined except in ares_build.h"
Error Compilation_aborted_CARES_SIZEOF_LONG_already_defined
#endif
#ifdef CARES_TYPEOF_ARES_SOCKLEN_T
# error "CARES_TYPEOF_ARES_SOCKLEN_T shall not be defined except in ares_build.h"
Error Compilation_aborted_CARES_TYPEOF_ARES_SOCKLEN_T_already_defined
#endif
#ifdef CARES_SIZEOF_ARES_SOCKLEN_T
# error "CARES_SIZEOF_ARES_SOCKLEN_T shall not be defined except in ares_build.h"
Error Compilation_aborted_CARES_SIZEOF_ARES_SOCKLEN_T_already_defined
#endif
/* ================================================================ */
/* EXTERNAL INTERFACE SETTINGS FOR NON-CONFIGURE SYSTEMS ONLY */
/* ================================================================ */
#if defined(__DJGPP__) || defined(__GO32__)
# define CARES_SIZEOF_LONG 4
# define CARES_TYPEOF_ARES_SOCKLEN_T int
# define CARES_SIZEOF_ARES_SOCKLEN_T 4
#elif defined(__SALFORDC__)
# define CARES_SIZEOF_LONG 4
# define CARES_TYPEOF_ARES_SOCKLEN_T int
# define CARES_SIZEOF_ARES_SOCKLEN_T 4
#elif defined(__BORLANDC__)
# define CARES_SIZEOF_LONG 4
# define CARES_TYPEOF_ARES_SOCKLEN_T int
# define CARES_SIZEOF_ARES_SOCKLEN_T 4
#elif defined(__TURBOC__)
# define CARES_SIZEOF_LONG 4
# define CARES_TYPEOF_ARES_SOCKLEN_T int
# define CARES_SIZEOF_ARES_SOCKLEN_T 4
#elif defined(__WATCOMC__)
# define CARES_SIZEOF_LONG 4
# define CARES_TYPEOF_ARES_SOCKLEN_T int
# define CARES_SIZEOF_ARES_SOCKLEN_T 4
#elif defined(__POCC__)
# define CARES_SIZEOF_LONG 4
# define CARES_TYPEOF_ARES_SOCKLEN_T int
# define CARES_SIZEOF_ARES_SOCKLEN_T 4
#elif defined(__LCC__)
# define CARES_SIZEOF_LONG 4
# define CARES_TYPEOF_ARES_SOCKLEN_T int
# define CARES_SIZEOF_ARES_SOCKLEN_T 4
#elif defined(__SYMBIAN32__)
# define CARES_SIZEOF_LONG 4
# define CARES_TYPEOF_ARES_SOCKLEN_T unsigned int
# define CARES_SIZEOF_ARES_SOCKLEN_T 4
#elif defined(__MWERKS__)
# define CARES_SIZEOF_LONG 4
# define CARES_TYPEOF_ARES_SOCKLEN_T int
# define CARES_SIZEOF_ARES_SOCKLEN_T 4
#elif defined(_WIN32_WCE)
# define CARES_SIZEOF_LONG 4
# define CARES_TYPEOF_ARES_SOCKLEN_T int
# define CARES_SIZEOF_ARES_SOCKLEN_T 4
#elif defined(__MINGW32__)
# define CARES_SIZEOF_LONG 4
# define CARES_TYPEOF_ARES_SOCKLEN_T int
# define CARES_SIZEOF_ARES_SOCKLEN_T 4
#elif defined(__VMS)
# define CARES_SIZEOF_LONG 4
# define CARES_TYPEOF_ARES_SOCKLEN_T unsigned int
# define CARES_SIZEOF_ARES_SOCKLEN_T 4
#elif defined(__OS400__)
# if defined(__ILEC400__)
# define CARES_SIZEOF_LONG 4
# define CARES_TYPEOF_ARES_SOCKLEN_T socklen_t
# define CARES_SIZEOF_ARES_SOCKLEN_T 4
# define CARES_PULL_SYS_TYPES_H 1
# define CARES_PULL_SYS_SOCKET_H 1
# endif
#elif defined(__MVS__)
# if defined(__IBMC__) || defined(__IBMCPP__)
# if defined(_ILP32)
# define CARES_SIZEOF_LONG 4
# elif defined(_LP64)
# define CARES_SIZEOF_LONG 8
# endif
# define CARES_TYPEOF_ARES_SOCKLEN_T socklen_t
# define CARES_SIZEOF_ARES_SOCKLEN_T 4
# define CARES_PULL_SYS_TYPES_H 1
# define CARES_PULL_SYS_SOCKET_H 1
# endif
#elif defined(__370__)
# if defined(__IBMC__) || defined(__IBMCPP__)
# if defined(_ILP32)
# define CARES_SIZEOF_LONG 4
# elif defined(_LP64)
# define CARES_SIZEOF_LONG 8
# endif
# define CARES_TYPEOF_ARES_SOCKLEN_T socklen_t
# define CARES_SIZEOF_ARES_SOCKLEN_T 4
# define CARES_PULL_SYS_TYPES_H 1
# define CARES_PULL_SYS_SOCKET_H 1
# endif
#elif defined(TPF)
# define CARES_SIZEOF_LONG 8
# define CARES_TYPEOF_ARES_SOCKLEN_T int
# define CARES_SIZEOF_ARES_SOCKLEN_T 4
/* ===================================== */
/* KEEP MSVC THE PENULTIMATE ENTRY */
/* ===================================== */
#elif defined(_MSC_VER)
# define CARES_SIZEOF_LONG 4
# define CARES_TYPEOF_ARES_SOCKLEN_T int
# define CARES_SIZEOF_ARES_SOCKLEN_T 4
/* ===================================== */
/* KEEP GENERIC GCC THE LAST ENTRY */
/* ===================================== */
#elif defined(__GNUC__)
# if defined(__ILP32__) || \
defined(__i386__) || defined(__ppc__) || defined(__arm__)
# define CARES_SIZEOF_LONG 4
# elif defined(__LP64__) || \
defined(__x86_64__) || defined(__ppc64__)
# define CARES_SIZEOF_LONG 8
# endif
# define CARES_TYPEOF_ARES_SOCKLEN_T socklen_t
# define CARES_SIZEOF_ARES_SOCKLEN_T 4
# define CARES_PULL_SYS_TYPES_H 1
# define CARES_PULL_SYS_SOCKET_H 1
#else
# error "Unknown non-configure build target!"
Error Compilation_aborted_Unknown_non_configure_build_target
#endif
/* CARES_PULL_SYS_TYPES_H is defined above when inclusion of header file */
/* sys/types.h is required here to properly make type definitions below. */
#ifdef CARES_PULL_SYS_TYPES_H
# include <sys/types.h>
#endif
/* CARES_PULL_SYS_SOCKET_H is defined above when inclusion of header file */
/* sys/socket.h is required here to properly make type definitions below. */
#ifdef CARES_PULL_SYS_SOCKET_H
# include <sys/socket.h>
#endif
/* Data type definition of ares_socklen_t. */
#ifdef CARES_TYPEOF_ARES_SOCKLEN_T
typedef CARES_TYPEOF_ARES_SOCKLEN_T ares_socklen_t;
#endif
#endif /* __CARES_BUILD_H */
......@@ -14,7 +14,7 @@
#include "ares_setup.h"
#include <assert.h>
#include <stdlib.h>
#include "ares.h"
#include "ares_private.h"
......@@ -26,33 +26,33 @@
void ares_cancel(ares_channel channel)
{
struct query *query;
struct list_node list_head_copy;
struct list_node* list_head;
struct list_node* list_node;
int i;
list_head = &(channel->all_queries);
for (list_node = list_head->next; list_node != list_head; )
if (!ares__is_list_empty(&(channel->all_queries)))
{
query = list_node->data;
list_node = list_node->next; /* since we're deleting the query */
query->callback(query->arg, ARES_ECANCELLED, 0, NULL, 0);
ares__free_query(query);
}
#ifndef NDEBUG
/* Freeing the query should remove it from all the lists in which it sits,
* so all query lists should be empty now.
*/
assert(ares__is_list_empty(&(channel->all_queries)));
for (i = 0; i < ARES_QID_TABLE_SIZE; i++)
/* Swap list heads, so that only those queries which were present on entry
* into this function are cancelled. New queries added by callbacks of
* queries being cancelled will not be cancelled themselves.
*/
list_head = &(channel->all_queries);
list_head_copy.prev = list_head->prev;
list_head_copy.next = list_head->next;
list_head_copy.prev->next = &list_head_copy;
list_head_copy.next->prev = &list_head_copy;
list_head->prev = list_head;
list_head->next = list_head;
for (list_node = list_head_copy.next; list_node != &list_head_copy; )
{
assert(ares__is_list_empty(&(channel->queries_by_qid[i])));
query = list_node->data;
list_node = list_node->next; /* since we're deleting the query */
query->callback(query->arg, ARES_ECANCELLED, 0, NULL, 0);
ares__free_query(query);
}
for (i = 0; i < ARES_TIMEOUT_TABLE_SIZE; i++)
{
assert(ares__is_list_empty(&(channel->queries_by_timeout[i])));
}
#endif
if (!(channel->flags & ARES_FLAG_STAYOPEN))
}
if (!(channel->flags & ARES_FLAG_STAYOPEN) && ares__is_list_empty(&(channel->all_queries)))
{
if (channel->servers)
{
......
......@@ -15,6 +15,9 @@
/* if a /etc/inet dir is being used */
#undef ETC_INET
/* Define to the type of arg 2 for gethostname. */
#undef GETHOSTNAME_TYPE_ARG2
/* Define to the type qualifier of arg 1 for getnameinfo. */
#undef GETNAMEINFO_QUAL_ARG1
......@@ -487,6 +490,11 @@
# undef _ALL_SOURCE
#endif
/* Enable large inode numbers on Mac OS X 10.5. */
#ifndef _DARWIN_USE_64_BIT_INODE
# define _DARWIN_USE_64_BIT_INODE 1
#endif
/* Number of bits in a file offset, on hosts where this is settable. */
#undef _FILE_OFFSET_BITS
......
......@@ -16,9 +16,6 @@
#include "ares_setup.h"
#ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h>
#endif
#ifdef HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
......@@ -31,12 +28,14 @@
# include <arpa/nameser_compat.h>
#endif
#include <stdlib.h>
#include <string.h>
#include "ares.h"
#include "ares_dns.h"
#include "ares_private.h"
#ifndef T_OPT
# define T_OPT 41 /* EDNS0 option (meta-RR) */
#endif
/* Header format, from RFC 1035:
* 1 1 1 1 1 1
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
......@@ -201,7 +200,7 @@ int ares_create_query(const char *name, int dnsclass, int type,
q += QFIXEDSZ;
memset(q, 0, EDNSFIXEDSZ);
q++;
DNS_RR_SET_TYPE(q, ns_t_opt);
DNS_RR_SET_TYPE(q, T_OPT);
DNS_RR_SET_CLASS(q, max_udp_size);
}
......
/* Copyright (C) 2009-2012 by Daniel Stenberg
/* Copyright (C) 2009-2013 by Daniel Stenberg
*
* Permission to use, copy, modify, and distribute this
* software and its documentation for any purpose and without
......@@ -199,33 +199,3 @@ void *ares_malloc_data(ares_datatype type)
return &ptr->data;
}
/*
** ares_get_datatype() - c-ares internal helper function.
**
** This function returns the ares_datatype of the data stored in a
** private ares_data struct when given the public API pointer.
*/
ares_datatype ares_get_datatype(void * dataptr)
{
struct ares_data *ptr;
#ifdef __INTEL_COMPILER
# pragma warning(push)
# pragma warning(disable:1684)
/* 1684: conversion from pointer to same-sized integral type */
#endif
ptr = (void *)((char *)dataptr - offsetof(struct ares_data, data));
#ifdef __INTEL_COMPILER
# pragma warning(pop)
#endif
if (ptr->mark == ARES_DATATYPE_MARK)
return ptr->type;
return ARES_DATATYPE_UNKNOWN;
}
/* Copyright (C) 2009-2012 by Daniel Stenberg
/* Copyright (C) 2009-2013 by Daniel Stenberg
*
* Permission to use, copy, modify, and distribute this
* software and its documentation for any purpose and without
......@@ -66,4 +66,3 @@ struct ares_data {
void *ares_malloc_data(ares_datatype type);
ares_datatype ares_get_datatype(void * dataptr);
......@@ -16,8 +16,9 @@
*/
#include "ares_setup.h"
#include <assert.h>
#include <stdlib.h>
#include "ares.h"
#include "ares_private.h"
......
......@@ -16,9 +16,6 @@
#include "ares_setup.h"
#ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h>
#endif
#ifdef HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
......@@ -31,7 +28,6 @@
# include <arpa/nameser_compat.h>
#endif
#include <stdlib.h>
#include "ares.h"
#include "ares_nowarn.h"
#include "ares_private.h" /* for the memdebug */
......@@ -147,7 +143,7 @@ static int name_length(const unsigned char *encoded, const unsigned char *abuf,
int n = 0, offset, indir = 0;
/* Allow the caller to pass us abuf + alen and have us check for it. */
if (encoded == abuf + alen)
if (encoded >= abuf + alen)
return -1;
while (*encoded)
......
......@@ -16,9 +16,6 @@
#include "ares_setup.h"
#ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h>
#endif
#ifdef HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
......@@ -28,8 +25,6 @@
# include "nameser.h"
#endif
#include <string.h>
#include <stdlib.h>
#include "ares.h"
#include "ares_private.h" /* for the memdebug */
......
......@@ -16,10 +16,6 @@
#include "ares_setup.h"
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
#include "ares.h"
#include "ares_nowarn.h"
#include "ares_private.h"
......
......@@ -15,7 +15,6 @@
*/
#include "ares_setup.h"
#include <stdlib.h>
#ifdef HAVE_NETDB_H
#include <netdb.h>
......
......@@ -15,7 +15,7 @@
*/
#include "ares_setup.h"
#include <stdlib.h>
#include "ares.h"
#include "ares_private.h"
......
......@@ -15,9 +15,6 @@
*/
#include "ares_setup.h"
#ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h>
#endif
#ifdef HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
......@@ -36,12 +33,8 @@
# include <arpa/nameser_compat.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "ares.h"
#include "inet_net_pton.h"
#include "ares_inet_net_pton.h"
#include "ares_platform.h"
#include "ares_private.h"
......
/* Copyright 1998, 2011 by the Massachusetts Institute of Technology.
/* Copyright 1998, 2011, 2013 by the Massachusetts Institute of Technology.
*
* Permission to use, copy, modify, and distribute this
* software and its documentation for any purpose and without
......@@ -16,9 +16,6 @@
#include "ares_setup.h"
#ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h>
#endif
#ifdef HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
......@@ -37,16 +34,12 @@
# include <arpa/nameser_compat.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#ifdef HAVE_STRINGS_H
#include <strings.h>
#endif
#include "ares.h"
#include "inet_net_pton.h"
#include "ares_inet_net_pton.h"
#include "bitncmp.h"
#include "ares_platform.h"
#include "ares_nowarn.h"
......@@ -467,8 +460,8 @@ static int get_address_index(const struct in_addr *addr,
}
else
{
if (!ares_bitncmp(&addr->s_addr, &sortlist[i].addrV4.s_addr,
sortlist[i].mask.bits))
if (!ares__bitncmp(&addr->s_addr, &sortlist[i].addrV4.s_addr,
sortlist[i].mask.bits))
break;
}
}
......@@ -515,10 +508,8 @@ static int get6_address_index(const struct ares_in6_addr *addr,
{
if (sortlist[i].family != AF_INET6)
continue;
if (!ares_bitncmp(addr,
&sortlist[i].addrV6,
sortlist[i].mask.bits))
break;
if (!ares__bitncmp(addr, &sortlist[i].addrV6, sortlist[i].mask.bits))
break;
}
return i;
}
......@@ -22,9 +22,6 @@
# endif
#endif
#ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h>
#endif
#ifdef HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
......@@ -47,17 +44,8 @@
#include <net/if.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "ares.h"
#include "ares_ipv6.h"
#include "inet_ntop.h"
#include "ares_nowarn.h"
#include "ares_private.h"
......
......@@ -14,10 +14,6 @@
#include "ares_setup.h"
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
#include "ares.h"
#include "ares_private.h"
......
#ifndef HEADER_CARES_INET_NET_PTON_H
#define HEADER_CARES_INET_NET_PTON_H
/* Copyright (C) 2005-2013 by Daniel Stenberg et al
*
* Permission to use, copy, modify, and distribute this
* software and its documentation for any purpose and without
* fee is hereby granted, provided that the above copyright
* notice appear in all copies and that both that copyright
* notice and this permission notice appear in supporting
* documentation, and that the name of M.I.T. not be used in
* advertising or publicity pertaining to distribution of the
* software without specific, written prior permission.
* M.I.T. makes no representations about the suitability of
* this software for any purpose. It is provided "as is"
* without express or implied warranty.
*/
#ifdef HAVE_INET_NET_PTON
#define ares_inet_net_pton(w,x,y,z) inet_net_pton(w,x,y,z)
#else
int ares_inet_net_pton(int af, const char *src, void *dst, size_t size);
#endif
#endif /* HEADER_CARES_INET_NET_PTON_H */
/* Copyright 1998 by the Massachusetts Institute of Technology.
* Copyright (C) 2007-2012 by Daniel Stenberg
* Copyright (C) 2007-2013 by Daniel Stenberg
*
* Permission to use, copy, modify, and distribute this
* software and its documentation for any purpose and without
......@@ -21,14 +21,6 @@
#include <sys/param.h>
#endif
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
......@@ -50,16 +42,6 @@
# include <arpa/nameser_compat.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <time.h>
#if defined(ANDROID) || defined(__ANDROID__)
#include <sys/system_properties.h>
/* From the Bionic sources */
......@@ -68,8 +50,7 @@
#endif
#include "ares.h"
#include "inet_ntop.h"
#include "inet_net_pton.h"
#include "ares_inet_net_pton.h"
#include "ares_library_init.h"
#include "ares_nowarn.h"
#include "ares_platform.h"
......@@ -1962,13 +1943,6 @@ static int init_id_key(rc4_key* key,int key_data_len)
return ARES_SUCCESS;
}
unsigned short ares__generate_new_id(rc4_key* key)
{
unsigned short r=0;
ares__rc4(key, (unsigned char *)&r, sizeof(r));
return r;
}
void ares_set_local_ip4(ares_channel channel, unsigned int local_ip)
{
channel->local_ip4 = local_ip;
......
......@@ -101,7 +101,10 @@ int ares_library_init(int flags)
int res;
if (ares_initialized)
return ARES_SUCCESS;
{
ares_initialized++;
return ARES_SUCCESS;
}
ares_initialized++;
if (flags & ARES_LIB_INIT_WIN32)
......@@ -122,6 +125,8 @@ void ares_library_cleanup(void)
if (!ares_initialized)
return;
ares_initialized--;
if (ares_initialized)
return;
if (ares_init_flags & ARES_LIB_INIT_WIN32)
ares_win32_cleanup();
......
......@@ -61,26 +61,3 @@ void ares__remove_from_list(struct list_node* node) {
}
}
/* Swap the contents of two lists */
void ares__swap_lists(struct list_node* head_a,
struct list_node* head_b) {
int is_a_empty = ares__is_list_empty(head_a);
int is_b_empty = ares__is_list_empty(head_b);
struct list_node old_a = *head_a;
struct list_node old_b = *head_b;
if (is_a_empty) {
ares__init_list_head(head_b);
} else {
*head_b = old_a;
old_a.next->prev = head_b;
old_a.prev->next = head_b;
}
if (is_b_empty) {
ares__init_list_head(head_a);
} else {
*head_a = old_b;
old_b.next->prev = head_a;
old_b.prev->next = head_a;
}
}
......@@ -36,7 +36,4 @@ void ares__insert_in_list(struct list_node* new_node,
void ares__remove_from_list(struct list_node* node);
void ares__swap_lists(struct list_node* head_a,
struct list_node* head_b);
#endif /* __ARES_LLIST_H */
......@@ -23,9 +23,6 @@
#if defined(__INTEL_COMPILER) && defined(__unix__)
#ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h>
#endif
#ifdef HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
......
/* Copyright 1998 by the Massachusetts Institute of Technology.
* Copyright (C) 2008-2011 by Daniel Stenberg
* Copyright (C) 2008-2013 by Daniel Stenberg
*
* Permission to use, copy, modify, and distribute this
* software and its documentation for any purpose and without
......@@ -24,7 +24,7 @@
#include "ares.h"
#include "ares_data.h"
#include "inet_net_pton.h"
#include "ares_inet_net_pton.h"
#include "ares_private.h"
......@@ -132,6 +132,7 @@ int ares_set_servers(ares_channel channel,
}
/* Incomming string format: host[:port][,host[:port]]... */
/* IPv6 addresses with ports require square brackets [fe80::1%lo0]:53 */
int ares_set_servers_csv(ares_channel channel,
const char* _csv)
{
......@@ -139,6 +140,7 @@ int ares_set_servers_csv(ares_channel channel,
char* csv = NULL;
char* ptr;
char* start_host;
int cc = 0;
int rv = ARES_SUCCESS;
struct ares_addr_node *servers = NULL;
struct ares_addr_node *last = NULL;
......@@ -164,28 +166,53 @@ int ares_set_servers_csv(ares_channel channel,
start_host = csv;
for (ptr = csv; *ptr; ptr++) {
if (*ptr == ',') {
if (*ptr == ':') {
/* count colons to determine if we have an IPv6 number or IPv4 with
port */
cc++;
}
else if (*ptr == '[') {
/* move start_host if an open square bracket is found wrapping an IPv6
address */
start_host = ptr + 1;
}
else if (*ptr == ',') {
char* pp = ptr - 1;
char* p = ptr;
struct in_addr in4;
struct ares_in6_addr in6;
struct ares_addr_node *s = NULL;
*ptr = 0; /* null terminate host:port string */
/* Got an entry..see if port was specified. */
while (pp > start_host) {
if (*pp == ':')
break; /* yes */
if (!ISDIGIT(*pp)) {
/* Found end of digits before we found :, so wasn't a port */
pp = ptr;
break;
/* Got an entry..see if the port was specified. */
if (cc > 0) {
while (pp > start_host) {
/* a single close square bracket followed by a colon, ']:' indicates
an IPv6 address with port */
if ((*pp == ']') && (*p == ':'))
break; /* found port */
/* a single colon, ':' indicates an IPv4 address with port */
if ((*pp == ':') && (cc == 1))
break; /* found port */
if (!(ISDIGIT(*pp) || (*pp == ':'))) {
/* Found end of digits before we found :, so wasn't a port */
/* must allow ':' for IPv6 case of ']:' indicates we found a port */
pp = p = ptr;
break;
}
pp--;
p--;
}
if ((pp != start_host) && ((pp + 1) < ptr)) {
/* Found it. Parse over the port number */
/* when an IPv6 address is wrapped with square brackets the port
starts at pp + 2 */
if (*pp == ']')
p++; /* move p before ':' */
/* p will point to the start of the port */
(void)strtol(p, NULL, 10);
*pp = 0; /* null terminate host */
}
pp--;
}
if ((pp != start_host) && ((pp + 1) < ptr)) {
/* Found it. Parse over the port number */
(void)strtol(pp + 1, NULL, 10);
*pp = 0; /* null terminate host */
}
/* resolve host, try ipv4 first, rslt is in network byte order */
rv = ares_inet_pton(AF_INET, start_host, &in4);
......@@ -221,6 +248,8 @@ int ares_set_servers_csv(ares_channel channel,
s->next = NULL;
if (last) {
last->next = s;
/* need to move last to maintain the linked list */
last = last->next;
}
else {
servers = s;
......@@ -230,6 +259,7 @@ int ares_set_servers_csv(ares_channel channel,
/* Set up for next one */
start_host = ptr + 1;
cc = 0;
}
}
......
......@@ -16,9 +16,6 @@
#include "ares_setup.h"
#ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h>
#endif
#ifdef HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
......@@ -41,8 +38,6 @@
# include <strings.h>
#endif
#include <stdlib.h>
#include <string.h>
#ifdef HAVE_LIMITS_H
# include <limits.h>
#endif
......@@ -141,6 +136,12 @@ int ares_parse_a_reply(const unsigned char *abuf, int alen,
rr_len = DNS_RR_LEN(aptr);
rr_ttl = DNS_RR_TTL(aptr);
aptr += RRFIXEDSZ;
if (aptr + rr_len > abuf + alen)
{
free(rr_name);
status = ARES_EBADRESP;
break;
}
if (rr_class == C_IN && rr_type == T_A
&& rr_len == sizeof(struct in_addr)
......
......@@ -17,9 +17,6 @@
#include "ares_setup.h"
#ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h>
#endif
#ifdef HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
......@@ -42,15 +39,13 @@
# include <strings.h>
#endif
#include <stdlib.h>
#include <string.h>
#ifdef HAVE_LIMITS_H
# include <limits.h>
#endif
#include "ares.h"
#include "ares_dns.h"
#include "inet_net_pton.h"
#include "ares_inet_net_pton.h"
#include "ares_private.h"
int ares_parse_aaaa_reply(const unsigned char *abuf, int alen,
......@@ -141,6 +136,12 @@ int ares_parse_aaaa_reply(const unsigned char *abuf, int alen,
rr_len = DNS_RR_LEN(aptr);
rr_ttl = DNS_RR_TTL(aptr);
aptr += RRFIXEDSZ;
if (aptr + rr_len > abuf + alen)
{
free(rr_name);
status = ARES_EBADRESP;
break;
}
if (rr_class == C_IN && rr_type == T_AAAA
&& rr_len == sizeof(struct ares_in6_addr)
......@@ -241,6 +242,8 @@ int ares_parse_aaaa_reply(const unsigned char *abuf, int alen,
for (i = 0; i < naddrs; i++)
hostent->h_addr_list[i] = (char *) &addrs[i];
hostent->h_addr_list[naddrs] = NULL;
if (!naddrs && addrs)
free(addrs);
*host = hostent;
return ARES_SUCCESS;
}
......
......@@ -17,9 +17,6 @@
#include "ares_setup.h"
#ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h>
#endif
#ifdef HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
......@@ -38,8 +35,6 @@
# include <arpa/nameser_compat.h>
#endif
#include <stdlib.h>
#include <string.h>
#include "ares.h"
#include "ares_dns.h"
#include "ares_data.h"
......@@ -105,6 +100,11 @@ ares_parse_mx_reply (const unsigned char *abuf, int alen,
rr_class = DNS_RR_CLASS (aptr);
rr_len = DNS_RR_LEN (aptr);
aptr += RRFIXEDSZ;
if (aptr + rr_len > abuf + alen)
{
status = ARES_EBADRESP;
break;
}
/* Check if we are really looking at a MX record */
if (rr_class == C_IN && rr_type == T_MX)
......
......@@ -17,9 +17,6 @@
#include "ares_setup.h"
#ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h>
#endif
#ifdef HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
......@@ -38,8 +35,6 @@
# include <arpa/nameser_compat.h>
#endif
#include <stdlib.h>
#include <string.h>
#include "ares.h"
#include "ares_dns.h"
#include "ares_data.h"
......@@ -110,6 +105,11 @@ ares_parse_naptr_reply (const unsigned char *abuf, int alen,
rr_class = DNS_RR_CLASS (aptr);
rr_len = DNS_RR_LEN (aptr);
aptr += RRFIXEDSZ;
if (aptr + rr_len > abuf + alen)
{
status = ARES_EBADRESP;
break;
}
/* Check if we are really looking at a NAPTR record */
if (rr_class == C_IN && rr_type == T_NAPTR)
......
......@@ -20,9 +20,6 @@
#include "ares_setup.h"
#ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h>
#endif
#ifdef HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
......@@ -41,8 +38,6 @@
# include <arpa/nameser_compat.h>
#endif
#include <stdlib.h>
#include <string.h>
#include "ares.h"
#include "ares_dns.h"
#include "ares_private.h"
......@@ -110,6 +105,12 @@ int ares_parse_ns_reply( const unsigned char* abuf, int alen,
rr_class = DNS_RR_CLASS( aptr );
rr_len = DNS_RR_LEN( aptr );
aptr += RRFIXEDSZ;
if (aptr + rr_len > abuf + alen)
{
free(rr_name);
status = ARES_EBADRESP;
break;
}
if ( rr_class == C_IN && rr_type == T_NS )
{
......
......@@ -16,9 +16,6 @@
#include "ares_setup.h"
#ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h>
#endif
#ifdef HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
......@@ -38,8 +35,6 @@
# include <strings.h>
#endif
#include <stdlib.h>
#include <string.h>
#include "ares.h"
#include "ares_dns.h"
#include "ares_nowarn.h"
......@@ -108,6 +103,12 @@ int ares_parse_ptr_reply(const unsigned char *abuf, int alen, const void *addr,
rr_class = DNS_RR_CLASS(aptr);
rr_len = DNS_RR_LEN(aptr);
aptr += RRFIXEDSZ;
if (aptr + rr_len > abuf + alen)
{
free(rr_name);
status = ARES_EBADRESP;
break;
}
if (rr_class == C_IN && rr_type == T_PTR
&& strcasecmp(rr_name, ptrname) == 0)
......@@ -208,7 +209,7 @@ int ares_parse_ptr_reply(const unsigned char *abuf, int alen, const void *addr,
status = ARES_ENOMEM;
}
for (i=0 ; i<aliascnt ; i++)
if (aliases[i])
if (aliases[i])
free(aliases[i]);
free(aliases);
if (hostname)
......
......@@ -17,9 +17,6 @@
#include "ares_setup.h"
#ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h>
#endif
#ifdef HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
......@@ -38,8 +35,6 @@
# include <arpa/nameser_compat.h>
#endif
#include <stdlib.h>
#include <string.h>
#include "ares.h"
#include "ares_dns.h"
#include "ares_data.h"
......
......@@ -17,9 +17,6 @@
#include "ares_setup.h"
#ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h>
#endif
#ifdef HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
......@@ -38,8 +35,6 @@
# include <arpa/nameser_compat.h>
#endif
#include <stdlib.h>
#include <string.h>
#include "ares.h"
#include "ares_dns.h"
#include "ares_data.h"
......@@ -110,6 +105,11 @@ ares_parse_srv_reply (const unsigned char *abuf, int alen,
rr_class = DNS_RR_CLASS (aptr);
rr_len = DNS_RR_LEN (aptr);
aptr += RRFIXEDSZ;
if (aptr + rr_len > abuf + alen)
{
status = ARES_EBADRESP;
break;
}
/* Check if we are really looking at a SRV record */
if (rr_class == C_IN && rr_type == T_SRV)
......
......@@ -17,9 +17,6 @@
#include "ares_setup.h"
#ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h>
#endif
#ifdef HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
......@@ -42,9 +39,6 @@
# include <strings.h>
#endif
#include <stdlib.h>
#include <string.h>
#include "ares.h"
#include "ares_dns.h"
#include "ares_data.h"
......@@ -54,7 +48,7 @@ int
ares_parse_txt_reply (const unsigned char *abuf, int alen,
struct ares_txt_reply **txt_out)
{
size_t substr_len, str_len;
size_t substr_len;
unsigned int qdcount, ancount, i;
const unsigned char *aptr;
const unsigned char *strptr;
......@@ -112,27 +106,15 @@ ares_parse_txt_reply (const unsigned char *abuf, int alen,
rr_class = DNS_RR_CLASS (aptr);
rr_len = DNS_RR_LEN (aptr);
aptr += RRFIXEDSZ;
if (aptr + rr_len > abuf + alen)
{
status = ARES_EBADRESP;
break;
}
/* Check if we are really looking at a TXT record */
if (rr_class == C_IN && rr_type == T_TXT)
{
/* Allocate storage for this TXT answer appending it to the list */
txt_curr = ares_malloc_data(ARES_DATATYPE_TXT_REPLY);
if (!txt_curr)
{
status = ARES_ENOMEM;
break;
}
if (txt_last)
{
txt_last->next = txt_curr;
}
else
{
txt_head = txt_curr;
}
txt_last = txt_curr;
/*
* There may be multiple substrings in a single TXT record. Each
* substring may be up to 255 characters in length, with a
......@@ -141,36 +123,49 @@ ares_parse_txt_reply (const unsigned char *abuf, int alen,
* substrings contained therein.
*/
/* Compute total length to allow a single memory allocation */
strptr = aptr;
while (strptr < (aptr + rr_len))
{
substr_len = (unsigned char)*strptr;
txt_curr->length += substr_len;
strptr += substr_len + 1;
}
/* Including null byte */
txt_curr->txt = malloc (txt_curr->length + 1);
if (txt_curr->txt == NULL)
{
status = ARES_ENOMEM;
break;
}
if (strptr + substr_len + 1 > aptr + rr_len)
{
status = ARES_EBADRESP;
break;
}
++strptr;
/* Allocate storage for this TXT answer appending it to the list */
txt_curr = ares_malloc_data(ARES_DATATYPE_TXT_REPLY);
if (!txt_curr)
{
status = ARES_ENOMEM;
break;
}
if (txt_last)
{
txt_last->next = txt_curr;
}
else
{
txt_head = txt_curr;
}
txt_last = txt_curr;
txt_curr->length = substr_len;
txt_curr->txt = malloc (substr_len + 1/* Including null byte */);
if (txt_curr->txt == NULL)
{
status = ARES_ENOMEM;
break;
}
memcpy ((char *) txt_curr->txt, strptr, substr_len);
/* Make sure we NULL-terminate */
txt_curr->txt[substr_len] = 0;
/* Step through the list of substrings, concatenating them */
str_len = 0;
strptr = aptr;
while (strptr < (aptr + rr_len))
{
substr_len = (unsigned char)*strptr;
strptr++;
memcpy ((char *) txt_curr->txt + str_len, strptr, substr_len);
str_len += substr_len;
strptr += substr_len;
}
/* Make sure we NULL-terminate */
*((char *) txt_curr->txt + txt_curr->length) = '\0';
}
/* Don't lose memory in the next iteration */
......
......@@ -26,9 +26,6 @@
#define WIN32
#endif
#include <stdio.h>
#include <sys/types.h>
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
......@@ -40,10 +37,6 @@
#define HAVE_WRITEV 1
#endif
#ifdef NETWARE
#include <time.h>
#endif
#define DEFAULT_TIMEOUT 5000 /* milliseconds */
#define DEFAULT_TRIES 4
#ifndef INADDR_NONE
......@@ -325,7 +318,6 @@ long ares__timeoffset(struct timeval *now,
struct timeval *check);
/* returns ARES_SUCCESS if library has been initialized */
int ares_library_initialized(void);
void ares__rc4(rc4_key* key,unsigned char *buffer_ptr, int buffer_len);
void ares__send_query(ares_channel channel, struct query *query,
struct timeval *now);
void ares__close_sockets(ares_channel channel, struct server_state *server);
......@@ -357,6 +349,7 @@ long ares__tvdiff(struct timeval t1, struct timeval t2);
libcurl lowlevel code from within library is ugly and only works when
c-ares is built and linked with a similarly curldebug-enabled libcurl,
but we do this anyway for convenience. */
#define HEADER_CURL_SETUP_ONCE_H
#include "../lib/memdebug.h"
#endif
......
/* Copyright 1998 by the Massachusetts Institute of Technology.
* Copyright (C) 2004-2012 by Daniel Stenberg
* Copyright (C) 2004-2013 by Daniel Stenberg
*
* Permission to use, copy, modify, and distribute this
* software and its documentation for any purpose and without
......@@ -17,9 +17,6 @@
#include "ares_setup.h"
#ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h>
#endif
#ifdef HAVE_SYS_UIO_H
# include <sys/uio.h>
#endif
......@@ -41,16 +38,9 @@
# include <arpa/nameser_compat.h>
#endif
#ifdef HAVE_SYS_TIME_H
# include <sys/time.h>
#endif
#ifdef HAVE_STRINGS_H
# include <strings.h>
#endif
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
#ifdef HAVE_SYS_IOCTL_H
# include <sys/ioctl.h>
#endif
......@@ -59,10 +49,7 @@
#endif
#include <assert.h>
#include <string.h>
#include <stdlib.h>
#include <fcntl.h>
#include <time.h>
#include "ares.h"
#include "ares_dns.h"
......@@ -653,6 +640,31 @@ static void process_broken_connections(ares_channel channel,
}
}
/* Swap the contents of two lists */
static void swap_lists(struct list_node* head_a,
struct list_node* head_b)
{
int is_a_empty = ares__is_list_empty(head_a);
int is_b_empty = ares__is_list_empty(head_b);
struct list_node old_a = *head_a;
struct list_node old_b = *head_b;
if (is_a_empty) {
ares__init_list_head(head_b);
} else {
*head_b = old_a;
old_a.next->prev = head_b;
old_a.prev->next = head_b;
}
if (is_b_empty) {
ares__init_list_head(head_a);
} else {
*head_a = old_b;
old_b.next->prev = head_a;
old_b.prev->next = head_a;
}
}
static void handle_error(ares_channel channel, int whichserver,
struct timeval *now)
{
......@@ -673,7 +685,7 @@ static void handle_error(ares_channel channel, int whichserver,
* same server->queries_to_server list.
*/
ares__init_list_head(&list_head);
ares__swap_lists(&list_head, &(server->queries_to_server));
swap_lists(&list_head, &(server->queries_to_server));
for (list_node = list_head.next; list_node != &list_head; )
{
query = list_node->data;
......
......@@ -16,9 +16,6 @@
#include "ares_setup.h"
#ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h>
#endif
#ifdef HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
......@@ -31,7 +28,6 @@
# include <arpa/nameser_compat.h>
#endif
#include <stdlib.h>
#include "ares.h"
#include "ares_dns.h"
#include "ares_private.h"
......@@ -43,7 +39,7 @@ struct qquery {
static void qcallback(void *arg, int status, int timeouts, unsigned char *abuf, int alen);
void ares__rc4(rc4_key* key, unsigned char *buffer_ptr, int buffer_len)
static void rc4(rc4_key* key, unsigned char *buffer_ptr, int buffer_len)
{
unsigned char x;
unsigned char y;
......@@ -105,6 +101,13 @@ static unsigned short generate_unique_id(ares_channel channel)
return (unsigned short)id;
}
unsigned short ares__generate_new_id(rc4_key* key)
{
unsigned short r=0;
rc4(key, (unsigned char *)&r, sizeof(r));
return r;
}
void ares_query(ares_channel channel, const char *name, int dnsclass,
int type, ares_callback callback, void *arg)
{
......
......@@ -16,11 +16,6 @@
#include "ares_setup.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#ifdef HAVE_STRINGS_H
# include <strings.h>
#endif
......
......@@ -16,9 +16,6 @@
#include "ares_setup.h"
#ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h>
#endif
#ifdef HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
......@@ -31,9 +28,6 @@
# include <arpa/nameser_compat.h>
#endif
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "ares.h"
#include "ares_dns.h"
#include "ares_private.h"
......
......@@ -16,12 +16,10 @@
#include "ares_setup.h"
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#ifdef HAVE_LIMITS_H
#include <limits.h>
#endif
#include <time.h>
#include "ares.h"
#include "ares_private.h"
......@@ -67,8 +65,10 @@ struct timeval *ares_timeout(ares_channel channel, struct timeval *maxtv,
*/
if (min_offset != -1)
{
nextstop.tv_sec = min_offset/1000;
nextstop.tv_usec = (min_offset%1000)*1000;
int ioffset = (min_offset > (long)INT_MAX) ? INT_MAX : (int)min_offset;
nextstop.tv_sec = ioffset/1000;
nextstop.tv_usec = (ioffset%1000)*1000;
if (!maxtv || ares__timedout(maxtv, &nextstop))
{
......
......@@ -3,7 +3,7 @@
#define ARES__VERSION_H
/* This is the global package copyright */
#define ARES_COPYRIGHT "2004 - 2012 Daniel Stenberg, <daniel@haxx.se>."
#define ARES_COPYRIGHT "2004 - 2013 Daniel Stenberg, <daniel@haxx.se>."
#define ARES_VERSION_MAJOR 1
#define ARES_VERSION_MINOR 10
......@@ -11,7 +11,7 @@
#define ARES_VERSION ((ARES_VERSION_MAJOR<<16)|\
(ARES_VERSION_MINOR<<8)|\
(ARES_VERSION_PATCH))
#define ARES_VERSION_STR "1.10.0-DEV"
#define ARES_VERSION_STR "1.10.0"
#if (ARES_VERSION >= 0x010700)
# define CARES_HAVE_ARES_LIBRARY_INIT 1
......
......@@ -33,27 +33,27 @@
* author:
* Paul Vixie (ISC), June 1996
*/
int
ares_bitncmp(const void *l, const void *r, int n) {
unsigned int lb, rb;
int x, b;
int ares__bitncmp(const void *l, const void *r, int n)
{
unsigned int lb, rb;
int x, b;
b = n / 8;
x = memcmp(l, r, b);
if (x || (n % 8) == 0)
return (x);
b = n / 8;
x = memcmp(l, r, b);
if (x || (n % 8) == 0)
return (x);
lb = ((const unsigned char *)l)[b];
rb = ((const unsigned char *)r)[b];
for (b = n % 8; b > 0; b--) {
if ((lb & 0x80) != (rb & 0x80)) {
if (lb & 0x80)
return (1);
return (-1);
}
lb <<= 1;
rb <<= 1;
}
return (0);
lb = ((const unsigned char *)l)[b];
rb = ((const unsigned char *)r)[b];
for (b = n % 8; b > 0; b--) {
if ((lb & 0x80) != (rb & 0x80)) {
if (lb & 0x80)
return (1);
return (-1);
}
lb <<= 1;
rb <<= 1;
}
return (0);
}
#endif
......@@ -2,7 +2,7 @@
#define __ARES_BITNCMP_H
/* Copyright (C) 2005 by Dominick Meglio
/* Copyright (C) 2005, 2013 by Dominick Meglio
*
* Permission to use, copy, modify, and distribute this
* software and its documentation for any purpose and without
......@@ -18,9 +18,9 @@
*/
#ifndef HAVE_BITNCMP
int ares_bitncmp(const void *l, const void *r, int n);
int ares__bitncmp(const void *l, const void *r, int n);
#else
#define ares_bitncmp(x,y,z) bitncmp(x,y,z)
#define ares__bitncmp(x,y,z) bitncmp(x,y,z)
#endif
#endif /* __ARES_BITNCMP_H */
#ifndef HEADER_CONFIG_DOS_H
#define HEADER_CONFIG_DOS_H
/* ================================================================ */
/* ares/config-dos.h - Hand crafted config file for DOS */
/* ================================================================ */
#define PACKAGE "c-ares"
#define HAVE_ERRNO_H 1
#define HAVE_GETENV 1
#define HAVE_GETTIMEOFDAY 1
#define HAVE_IOCTLSOCKET 1
#define HAVE_IOCTLSOCKET_FIONBIO 1
#define HAVE_LIMITS_H 1
#define HAVE_NET_IF_H 1
#define HAVE_RECV 1
#define HAVE_RECVFROM 1
#define HAVE_SEND 1
#define HAVE_STRDUP 1
#define HAVE_STRICMP 1
#define HAVE_STRUCT_IN6_ADDR 1
#define HAVE_STRUCT_TIMEVAL 1
#define HAVE_SYS_IOCTL_H 1
#define HAVE_SYS_SOCKET_H 1
#define HAVE_SYS_STAT_H 1
#define HAVE_SYS_TYPES_H 1
#define HAVE_TIME_H 1
#define HAVE_UNISTD_H 1
#define NEED_MALLOC_H 1
#define RETSIGTYPE void
#define SIZEOF_INT 4
#define SIZEOF_SHORT 2
#define SIZEOF_SIZE_T 4
#define TIME_WITH_SYS_TIME 1
/* Qualifiers for send(), recv(), recvfrom() and getnameinfo(). */
#define SEND_TYPE_ARG1 int
#define SEND_QUAL_ARG2 const
#define SEND_TYPE_ARG2 void *
#define SEND_TYPE_ARG3 int
#define SEND_TYPE_ARG4 int
#define SEND_TYPE_RETV int
#define RECV_TYPE_ARG1 int
#define RECV_TYPE_ARG2 void *
#define RECV_TYPE_ARG3 int
#define RECV_TYPE_ARG4 int
#define RECV_TYPE_RETV int
#define RECVFROM_TYPE_ARG1 int
#define RECVFROM_TYPE_ARG2 void
#define RECVFROM_TYPE_ARG3 int
#define RECVFROM_TYPE_ARG4 int
#define RECVFROM_TYPE_ARG5 struct sockaddr
#define RECVFROM_TYPE_ARG6 int
#define RECVFROM_TYPE_RETV int
#define RECVFROM_TYPE_ARG2_IS_VOID 1
#define BSD
#if defined(__HIGHC__) || \
(defined(__GNUC__) && (__GNUC__ < 4))
#define ssize_t int
#endif
/* Target HAVE_x section */
#if defined(DJGPP)
#define HAVE_STRCASECMP 1
#define HAVE_STRNCASECMP 1
#define HAVE_SYS_TIME_H 1
#define HAVE_VARIADIC_MACROS_GCC 1
/* Because djgpp <= 2.03 doesn't have snprintf() etc. */
#if (DJGPP_MINOR < 4)
#define _MPRINTF_REPLACE
#endif
#elif defined(__WATCOMC__)
#define HAVE_STRCASECMP 1
#elif defined(__HIGHC__)
#define HAVE_SYS_TIME_H 1
#define strerror(e) strerror_s_((e))
#endif
#ifdef WATT32
#define HAVE_AF_INET6 1
#define HAVE_ARPA_INET_H 1
#define HAVE_ARPA_NAMESER_H 1
#define HAVE_CLOSE_S 1
#define HAVE_GETHOSTNAME 1
#define HAVE_NETDB_H 1
#define HAVE_NETINET_IN_H 1
#define HAVE_NETINET_TCP_H 1
#define HAVE_PF_INET6 1
#define HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID 1
#define HAVE_STRUCT_ADDRINFO 1
#define HAVE_STRUCT_IN6_ADDR 1
#define HAVE_STRUCT_SOCKADDR_IN6 1
#define HAVE_SYS_SOCKET_H 1
#define HAVE_SYS_UIO_H 1
#define NS_INADDRSZ 4
#define HAVE_STRUCT_SOCKADDR_IN6 1
#endif
#undef word
#undef byte
#endif /* HEADER_CONFIG_DOS_H */
......@@ -4,7 +4,7 @@
# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
# 2011, 2012 Free Software Foundation, Inc.
timestamp='2012-02-10'
timestamp='2012-04-18'
# This file is (in principle) common to ALL GNU software.
# The presence of a machine in this file suggests that SOME GNU software
......@@ -225,6 +225,12 @@ case $os in
-isc*)
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
;;
-lynx*178)
os=-lynxos178
;;
-lynx*5)
os=-lynxos5
;;
-lynx*)
os=-lynxos
;;
......@@ -1537,6 +1543,9 @@ case $basic_machine in
c4x-* | tic4x-*)
os=-coff
;;
hexagon-*)
os=-elf
;;
tic54x-*)
os=-coff
;;
......
This diff is collapsed.
......@@ -18,9 +18,6 @@
#include "ares_setup.h"
#ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h>
#endif
#ifdef HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
......@@ -36,15 +33,10 @@
# include <arpa/nameser_compat.h>
#endif
#include <ctype.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "ares.h"
#include "ares_ipv6.h"
#include "ares_nowarn.h"
#include "inet_net_pton.h"
#include "ares_inet_net_pton.h"
const struct ares_in6_addr ares_in6addr_any = { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } } };
......@@ -448,4 +440,11 @@ int ares_inet_pton(int af, const char *src, void *dst)
return 0;
return (result > -1 ? 1 : -1);
}
#else /* HAVE_INET_PTON */
int ares_inet_pton(int af, const char *src, void *dst)
{
/* just relay this to the underlying function */
return inet_pton(af, src, dst);
}
#endif
......@@ -17,9 +17,6 @@
#include "ares_setup.h"
#ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h>
#endif
#ifdef HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
......@@ -35,15 +32,8 @@
# include <arpa/nameser_compat.h>
#endif
#include <ctype.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "ares.h"
#include "ares_ipv6.h"
#include "inet_ntop.h"
#ifndef HAVE_INET_NTOP
......@@ -69,13 +59,13 @@ static const char *inet_ntop6(const unsigned char *src, char *dst, size_t size);
* Paul Vixie, 1996.
*/
const char *
ares_inet_ntop(int af, const void *src, char *dst, size_t size)
ares_inet_ntop(int af, const void *src, char *dst, ares_socklen_t size)
{
switch (af) {
case AF_INET:
return (inet_ntop4(src, dst, size));
return (inet_ntop4(src, dst, (size_t)size));
case AF_INET6:
return (inet_ntop6(src, dst, size));
return (inet_ntop6(src, dst, (size_t)size));
default:
SET_ERRNO(EAFNOSUPPORT);
return (NULL);
......@@ -205,4 +195,14 @@ inet_ntop6(const unsigned char *src, char *dst, size_t size)
strcpy(dst, tmp);
return (dst);
}
#endif
#else /* HAVE_INET_NTOP */
const char *
ares_inet_ntop(int af, const void *src, char *dst, ares_socklen_t size)
{
/* just relay this to the underlying function */
return inet_ntop(af, src, dst, size);
}
#endif /* HAVE_INET_NTOP */
......@@ -186,11 +186,19 @@ typedef enum __ns_rcode {
#define T_SRV ns_t_srv
#define T_ATMA ns_t_atma
#define T_NAPTR ns_t_naptr
#define T_KX ns_t_kx
#define T_CERT ns_t_cert
#define T_A6 ns_t_a6
#define T_DNAME ns_t_dname
#define T_SINK ns_t_sink
#define T_OPT ns_t_opt
#define T_APL ns_t_apl
#define T_DS ns_t_ds
#define T_SSHFP ns_t_sshfp
#define T_RRSIG ns_t_rrsig
#define T_NSEC ns_t_nsec
#define T_DNSKEY ns_t_dnskey
#define T_TKEY ns_t_tkey
#define T_TSIG ns_t_tsig
#define T_IXFR ns_t_ixfr
#define T_AXFR ns_t_axfr
......
......@@ -2,7 +2,7 @@
#define __SETUP_ONCE_H
/* Copyright (C) 2004 - 2012 by Daniel Stenberg et al
/* Copyright (C) 2004 - 2013 by Daniel Stenberg et al
*
* Permission to use, copy, modify, and distribute this software and its
* documentation for any purpose and without fee is hereby granted, provided
......@@ -76,6 +76,34 @@
#include <stdbool.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef __hpux
# if !defined(_XOPEN_SOURCE_EXTENDED) || defined(_KERNEL)
# ifdef _APP32_64BIT_OFF_T
# define OLD_APP32_64BIT_OFF_T _APP32_64BIT_OFF_T
# undef _APP32_64BIT_OFF_T
# else
# undef OLD_APP32_64BIT_OFF_T
# endif
# endif
#endif
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#ifdef __hpux
# if !defined(_XOPEN_SOURCE_EXTENDED) || defined(_KERNEL)
# ifdef OLD_APP32_64BIT_OFF_T
# define _APP32_64BIT_OFF_T OLD_APP32_64BIT_OFF_T
# undef OLD_APP32_64BIT_OFF_T
# endif
# endif
#endif
/*
* Definition of timeval struct for platforms that don't have it.
......@@ -232,6 +260,8 @@ struct timeval {
# define sclose(x) closesocket((x))
#elif defined(HAVE_CLOSESOCKET_CAMEL)
# define sclose(x) CloseSocket((x))
#elif defined(HAVE_CLOSE_S)
# define sclose(x) close_s((x))
#else
# define sclose(x) close((x))
#endif
......@@ -259,6 +289,18 @@ struct timeval {
#define TOLOWER(x) (tolower((int) ((unsigned char)x)))
/*
* 'bool' stuff compatible with HP-UX headers.
*/
#if defined(__hpux) && !defined(HAVE_BOOL_T)
typedef int bool;
# define false 0
# define true 1
# define HAVE_BOOL_T
#endif
/*
* 'bool' exists on platforms with <stdbool.h>, i.e. C99 platforms.
* On non-C99 platforms there's no bool, so define an enum for that.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment