Skip to content
This repository has been archived by the owner on May 4, 2018. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
c-ares: upgrade to 1.7.5
  • Loading branch information
bnoordhuis committed Sep 24, 2011
1 parent 8f617b9 commit 94dbbee
Show file tree
Hide file tree
Showing 45 changed files with 854 additions and 325 deletions.
13 changes: 11 additions & 2 deletions include/ares.h
@@ -1,6 +1,6 @@

/* Copyright 1998, 2009 by the Massachusetts Institute of Technology.
* Copyright (C) 2007-2010 by Daniel Stenberg
* Copyright (C) 2007-2011 by Daniel Stenberg
*
* Permission to use, copy, modify, and distribute this
* software and its documentation for any purpose and without
Expand Down Expand Up @@ -96,10 +96,19 @@ typedef int ares_socklen_t;
# include <netinet/in.h>
# include <sys/socket.h>
# include <tcp.h>
#elif defined(_WIN32_WCE)
# ifndef WIN32_LEAN_AND_MEAN
# define WIN32_LEAN_AND_MEAN
# endif
# include <windows.h>
# include <winsock.h>
#elif defined(WIN32)
# ifndef WIN32_LEAN_AND_MEAN
# define WIN32_LEAN_AND_MEAN
# endif
# include <windows.h>
# include <winsock2.h>
# include <ws2tcpip.h>
# include <windows.h>
#else
# include <sys/socket.h>
# include <netinet/in.h>
Expand Down
4 changes: 2 additions & 2 deletions include/ares_version.h
Expand Up @@ -7,11 +7,11 @@

#define ARES_VERSION_MAJOR 1
#define ARES_VERSION_MINOR 7
#define ARES_VERSION_PATCH 4
#define ARES_VERSION_PATCH 5
#define ARES_VERSION ((ARES_VERSION_MAJOR<<16)|\
(ARES_VERSION_MINOR<<8)|\
(ARES_VERSION_PATCH))
#define ARES_VERSION_STR "1.7.4"
#define ARES_VERSION_STR "1.7.5-DEV"

#if (ARES_VERSION >= 0x010700)
# define CARES_HAVE_ARES_LIBRARY_INIT 1
Expand Down
20 changes: 20 additions & 0 deletions src/ares/CHANGES
@@ -1,5 +1,25 @@
Changelog for the c-ares project

Version 1.7.5 (August 16, 2011)

Fixed:

o detection of semicolon comments in resolv.conf
o avoid using system's inet_net_pton affected by the WLB-2008080064 advisory
o replacement ares_inet_net_pton affected by the WLB-2008080064 advisory
o replacement ares_inet_ntop affected by potential out of bounds write
o added install target to Makefile.msvc
o only fall back to AF_INET searches when looking for AF_UNSPEC addresses
o fixed ares_parse_*_reply memory leaks
o Use correct sizeof in ares_getnameinfo()
o IPv6-on-windows: find DNS servers correctly
o man pages: docs for the c-ares utility programs
o getservbyport replacement for Win CE
o config_sortlist: (win32) missing else
o advance_tcp_send_queue: avoid NULL ptr dereference
o configure: fix a bashism
o ares_expand_name: Fix encoded length for indirect root

Version 1.7.4 (December 9, 2010)

Changed:
Expand Down
24 changes: 24 additions & 0 deletions src/ares/README.msvc
Expand Up @@ -40,6 +40,30 @@
library version it is using.


How to install using MSVC from the command line
-----------------------------------------------

In order to allow easy usage of c-ares libraries it may be convenient to
install c-ares libraries and header files to a common subdirectory tree.

Once that c-ares libraries have been built using procedure described above,
use same command prompt window to define environment variable INSTALL_DIR
to designate the top subdirectory where installation of c-ares libraries and
header files will be done.

> set INSTALL_DIR=c:\c-ares

Afterwards, run following command to actually perform the installation:

> nmake -f Makefile.msvc install

Installation procedure will copy c-ares libraries to subdirectory 'lib' and
c-ares header files to subdirectory 'include' below the INSTALL_DIR subdir.

When environment variable INSTALL_DIR is not defined, installation is done
to c-ares source folder where Makefile.msvc file is located.


How to build using Visual Studio 6 IDE
--------------------------------------

Expand Down
35 changes: 18 additions & 17 deletions src/ares/RELEASE-NOTES
@@ -1,25 +1,26 @@
c-ares version 1.7.4

Changed:

o local-bind: Support binding to local interface/IPs, see
ares_set_local_ip4, ares_set_local_ip6, ares_set_local_dev
c-ares version 1.7.5

Fixed:

o memory leak in ares_getnameinfo
o add missing break that caused get_ares_servers to fail
o ares_parse_a_reply: fix CNAME response parsing
o init_by_options: don't copy an empty sortlist
o Replaced uint32_t with unsigned int to fix broken builds
on a couple of platforms
o Fix lookup with HOSTALIASES set
o adig: fix NAPTR parsing
o compiler warning cleanups
o detection of semicolon comments in resolv.conf
o avoid using system's inet_net_pton affected by the WLB-2008080064 advisory
o replacement ares_inet_net_pton affected by the WLB-2008080064 advisory
o replacement ares_inet_ntop affected by potential out of bounds write
o added install target to Makefile.msvc
o only fall back to AF_INET searches when looking for AF_UNSPEC addresses
o fixed ares_parse_*_reply memory leaks
o Use correct sizeof in ares_getnameinfo()
o IPv6-on-windows: find DNS servers correctly
o man pages: docs for the c-ares utility programs
o getservbyport replacement for Win CE
o config_sortlist: (win32) missing else
o advance_tcp_send_queue: avoid NULL ptr dereference
o configure: fix a bashism
o ares_expand_name: Fix encoded length for indirect root

Thanks go to these friendly people for their efforts and contributions:

Andrew C. Morrow, Ben Greear, Ben Noordhuis, Daniel Stenberg,
Guenter Knauf, Mike Crowe, Patrik Thunstrom, Yang Tse
Yang Tse, Jakub Hrozek, Gisle Vanem, Tom Hughes, David Stuart, Dima Tisnek,
Peter Pentchev, Stefan Buhler

Have fun!
9 changes: 8 additions & 1 deletion src/ares/ares_expand_name.c
Expand Up @@ -87,7 +87,14 @@ int ares_expand_name(const unsigned char *encoded, const unsigned char *abuf,
* Since this function strips trailing dots though, it becomes ""
*/
q[0] = '\0';
*enclen = 1; /* the caller should move one byte to get past this */

/* indirect root label (like 0xc0 0x0c) is 2 bytes long (stupid, but
valid) */
if ((*encoded & INDIR_MASK) == INDIR_MASK)
*enclen = 2;
else
*enclen = 1; /* the caller should move one byte to get past this */

return ARES_SUCCESS;
}

Expand Down
1 change: 1 addition & 0 deletions src/ares/ares_fds.c
Expand Up @@ -21,6 +21,7 @@
#endif

#include "ares.h"
#include "ares_nowarn.h"
#include "ares_private.h"

int ares_fds(ares_channel channel, fd_set *read_fds, fd_set *write_fds)
Expand Down
3 changes: 3 additions & 0 deletions src/ares/ares_free_hostent.c
Expand Up @@ -28,6 +28,9 @@ void ares_free_hostent(struct hostent *host)
{
char **p;

if (!host)
return;

free((char *)(host->h_name));
for (p = host->h_aliases; *p; p++)
free(*p);
Expand Down
30 changes: 30 additions & 0 deletions src/ares/ares_getenv.c
@@ -0,0 +1,30 @@


/* Copyright 1998 by the Massachusetts Institute of Technology.
*
* 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.
*/

#include "ares_setup.h"
#include "ares_getenv.h"

#ifndef HAVE_GETENV

char *ares_getenv(const char *name)
{
#ifdef _WIN32_WCE
return NULL;
#endif
}

#endif
26 changes: 26 additions & 0 deletions src/ares/ares_getenv.h
@@ -0,0 +1,26 @@
#ifndef HEADER_CARES_GETENV_H
#define HEADER_CARES_GETENV_H


/* Copyright 1998 by the Massachusetts Institute of Technology.
*
* 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.
*/

#include "ares_setup.h"

#ifndef HAVE_GETENV
extern char *ares_getenv(const char *name);
#endif

#endif /* HEADER_CARES_GETENV_H */
13 changes: 11 additions & 2 deletions src/ares/ares_gethostbyaddr.c
Expand Up @@ -42,6 +42,7 @@

#include "ares.h"
#include "inet_net_pton.h"
#include "ares_platform.h"
#include "ares_private.h"

#ifdef WATT32
Expand Down Expand Up @@ -186,7 +187,13 @@ static int file_lookup(struct ares_addr *addr, struct hostent **host)

#ifdef WIN32
char PATH_HOSTS[MAX_PATH];
if (IS_NT()) {
win_platform platform;

PATH_HOSTS[0] = '\0';

platform = ares__getplatform();

if (platform == WIN_NT) {
char tmp[MAX_PATH];
HKEY hkeyHosts;

Expand All @@ -200,8 +207,10 @@ static int file_lookup(struct ares_addr *addr, struct hostent **host)
RegCloseKey(hkeyHosts);
}
}
else
else if (platform == WIN_9X)
GetWindowsDirectory(PATH_HOSTS, MAX_PATH);
else
return ARES_ENOTFOUND;

strcat(PATH_HOSTS, WIN_PATH_HOSTS);

Expand Down
26 changes: 17 additions & 9 deletions src/ares/ares_gethostbyname.c
Expand Up @@ -48,6 +48,7 @@
#include "ares.h"
#include "inet_net_pton.h"
#include "bitncmp.h"
#include "ares_platform.h"
#include "ares_private.h"

#ifdef WATT32
Expand Down Expand Up @@ -193,11 +194,11 @@ static void host_callback(void *arg, int status, int timeouts,
else if (hquery->sent_family == AF_INET6)
{
status = ares_parse_aaaa_reply(abuf, alen, &host, NULL, NULL);
if (status == ARES_ENODATA || status == ARES_EBADRESP) {
if ((status == ARES_ENODATA || status == ARES_EBADRESP) &&
hquery->want_family == AF_UNSPEC) {
/* The query returned something but either there were no AAAA
records (e.g. just CNAME) or the response was malformed. Try
looking up A instead. We should possibly limit this
attempt-next logic to AF_UNSPEC lookups only. */
looking up A instead. */
hquery->sent_family = AF_INET;
ares_search(hquery->channel, hquery->name, C_IN, T_A,
host_callback, hquery);
Expand All @@ -209,11 +210,10 @@ static void host_callback(void *arg, int status, int timeouts,
end_hquery(hquery, status, host);
}
else if ((status == ARES_ENODATA || status == ARES_EBADRESP ||
status == ARES_ETIMEOUT) && hquery->sent_family == AF_INET6)
status == ARES_ETIMEOUT) && (hquery->sent_family == AF_INET6 &&
hquery->want_family == AF_UNSPEC))
{
/* The AAAA query yielded no useful result. Now look up an A instead.
We should possibly limit this attempt-next logic to AF_UNSPEC lookups
only. */
/* The AAAA query yielded no useful result. Now look up an A instead. */
hquery->sent_family = AF_INET;
ares_search(hquery->channel, hquery->name, C_IN, T_A, host_callback,
hquery);
Expand Down Expand Up @@ -344,7 +344,13 @@ static int file_lookup(const char *name, int family, struct hostent **host)

#ifdef WIN32
char PATH_HOSTS[MAX_PATH];
if (IS_NT()) {
win_platform platform;

PATH_HOSTS[0] = '\0';

platform = ares__getplatform();

if (platform == WIN_NT) {
char tmp[MAX_PATH];
HKEY hkeyHosts;

Expand All @@ -358,8 +364,10 @@ static int file_lookup(const char *name, int family, struct hostent **host)
RegCloseKey(hkeyHosts);
}
}
else
else if (platform == WIN_9X)
GetWindowsDirectory(PATH_HOSTS, MAX_PATH);
else
return ARES_ENOTFOUND;

strcat(PATH_HOSTS, WIN_PATH_HOSTS);

Expand Down
5 changes: 3 additions & 2 deletions src/ares/ares_getnameinfo.c
Expand Up @@ -58,6 +58,7 @@
#include "ares.h"
#include "ares_ipv6.h"
#include "inet_ntop.h"
#include "ares_nowarn.h"
#include "ares_private.h"

struct nameinfo_query {
Expand Down Expand Up @@ -187,15 +188,15 @@ void ares_getnameinfo(ares_channel channel, const struct sockaddr *sa,
if (sa->sa_family == AF_INET)
{
niquery->family = AF_INET;
memcpy(&niquery->addr.addr4, addr, sizeof(addr));
memcpy(&niquery->addr.addr4, addr, sizeof(struct in_addr));
ares_gethostbyaddr(channel, &addr->sin_addr,
sizeof(struct in_addr), AF_INET,
nameinfo_callback, niquery);
}
else
{
niquery->family = AF_INET6;
memcpy(&niquery->addr.addr6, addr6, sizeof(addr6));
memcpy(&niquery->addr.addr6, addr6, sizeof(struct ares_in6_addr));
ares_gethostbyaddr(channel, &addr6->sin6_addr,
sizeof(struct ares_in6_addr), AF_INET6,
nameinfo_callback, niquery);
Expand Down

0 comments on commit 94dbbee

Please sign in to comment.