Commit d5ea71d6 authored by Denis Bilenko's avatar Denis Bilenko

upgrade c-ares to 1.7.5

parent 13dae8ec
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:
o local-bind: Support binding to local interface/IPs, see
ares_set_local_ip4, ares_set_local_ip6, ares_set_local_dev
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
Version 1.7.3 (June 11, 2010)
Fixed:
o builds on Android
o now includes all files necessary to build it (1.7.2 lacked a file)
Version 1.7.2 (June 10, 2010)
Changed:
o Added ares_parse_mx_reply()
Fixed:
o ares_init: Last, not first instance of domain or search should win
o improve alternative definition of bool
o fix VS2010 compiler warnings
Version 1.7.1 (Mar 23, 2010)
* May 31, 2010 (Jakub Hrozek)
- Use the last instance of domain/search, not the first one
* March 23, 2010 (Daniel Stenberg)
- We switched from CVS to git. See http://github.com/bagder/c-ares
* March 5, 2010 (Daniel Stenberg)
- Daniel Johnson provided fixes for building with the clang compiler.
* March 5, 2010 (Yang Tse)
- Added IPv6 name servers support. Implementation has been based on code,
comments and feedback provided November and December of 2008 by Daniel
Stenberg, Gregor Jasny, Phil Blundell and myself, December 2009 by Cedric
Bail, and February 2010 by Jakub Hrozek on the c-ares mailing list. On
March I reviewed all that, selected the best of each, and adjusted or
extended parts of it to make the best fit.
The external and visible result of all this is that two new functions are
added to the external API, ares_get_servers() and ares_set_servers(), which
becomes now the preferred way of getting and setting name servers for any
ares channel as these support both IPv4 and IPv6 name servers.
In order to not break ABI compatibility, ares_init_options() with option
mask ARES_OPT_SERVERS and ares_save_options() may still be used in code
which is intended to run on IPv4-only stacks. But remember that these
functions do not support IPv6 name servers. This implies that if the user
is capable of defining or providing an IPv6 name server, and the app is
using ares_init_options() or ares_save_options() at some point to handle
the name servers, the app will likely lose IPv6 name servers.
* January 28, 2010 (Daniel Stenberg)
- Tommie Gannert pointed out a silly bug in ares_process_fd() since it didn't
check for broken connections like ares_process() did. Based on that, I
merged the two functions into a single generic one with two front-ends.
* December 29, 2009 (Yang Tse)
- Laszlo Tamas Szabo adjusted Makefile.msvc compiler options so that where
run-time error checks enabling compiler option /GZ was used it is replaced
with equivalent /RTCsu for Visual Studio 2003 and newer versions. Option
/GX is replaced with equivalent /EHsc for all versions. Also fixed socket
data type for internal configure_socket function.
* December 21, 2009 (Yang Tse)
- Ingmar Runge noticed that Windows config-win32.h configuration file
did not include a definition for HAVE_CLOSESOCKET which resulted in
function close() being inappropriately used to close sockets.
Version 1.7.0 (Nov 30, 2009)
* November 26, 2009 (Yang Tse)
- Larry Lansing fixed ares_parse_srv_reply to properly parse replies
which might contain non-SRV answers, skipping over potential non-SRV
ones such as CNAMEs.
* November 23, 2009 (Yang Tse)
- Changed naming convention for c-ares libraries built with MSVC, details
and build instructions provided in README.msvc file.
* November 22, 2009 (Yang Tse)
- Jakub Hrozek fixed more function prototypes in man pages to sync them
with the ones declared in ares.h
- Jakub Hrozek renamed addrttl and addr6ttl structs to ares_addrttl and
ares_addr6ttl in order to prevent name space pollution, along with
necessary changes to code base and man pages.This change does not break
ABI, there is no need to recompile existing applications. But existing
applications using these structs with the old name will need source code
adjustments when recompiled using c-ares 1.7.0.
* November 21, 2009 (Yang Tse)
- Added manifest stuff to Makefile.msvc.
* November 20, 2009 (Yang Tse)
- Fixed several function prototypes in man pages that were out of sync
with the ones declared in ares.h. Added ares_free_data() along with
man page. Updated ares_parse_srv_reply() and ares_parse_txt_reply()
with changes from Jakub Hrozek making these now return linked lists
instead of arrays, and merging the ares_free_data() adjustments.
* November 10, 2009 (Yang Tse)
- Updated MSVC 6.0 project files to match settings from Makefile.msvc.
* November 9, 2009 (Yang Tse)
- Makefile.msvc is now the reference method to build c-ares and sample
programs with any MSVC compiler or MS Visual Studio version. If no
option or target are specified it builds dynamic and static c-ares
libraries in debug and release flavours and also builds all sample
programs using each of the different c-ares libraries.
* November 2, 2009 (Yang Tse)
- Renamed c-ares setup.h to ares_setup.h
* October 31, 2009 (Yang Tse)
- Symbol hiding configure options are named now --enable-symbol-hiding
and --disable-symbol-hiding in an attempt to make them less ambiguous.
* October 30, 2009 (Yang Tse)
- Many fixes for ares_parse_txt_reply()
* October 29, 2009 (Daniel Stenberg)
- Jakub Hrozek added ares_parse_txt_reply() for TXT parsing
* October 29, 2009 (Yang Tse)
- Updated MSVC 6.0 workspace and project files that allows building
dynamic and static c-ares libraries in debug and release flavours.
Additionally each of the three sample programs is built against
each of the four possible c-ares libraries, generating all this
a total number of 12 executables and 4 libraries.
* October 28, 2009 (Yang Tse)
- Initial step towards the ability to reduce c-ares exported symbols
when built as a shared library based on the 'visibility' attribute
for GNUC and Intel compilers and based on __global for Sun compilers,
taking also in account __declspec function decoration for Win32 and
Symbian DLL's.
* October 27, 2009 (Yang Tse)
- Fixed Pelles C Win32 target compilation issues.
* October 23, 2009 (Yang Tse)
- John Engelhart noticed an unreleased problem relative to a duplicate
ARES_ECANCELLED error code value and missing error code description.
* October 7, 2009 (Yang Tse)
- Overhauled ares__get_hostent() Fixing out of bounds memory overwrite
triggered with malformed /etc/hosts file. Improving parsing of /etc/hosts
file. Validating requested address family. Ensuring that failures always
return a NULL pointer. Adjusting header inclusions.
* October 6, 2009 (Yang Tse)
- Fix ssize_t redefinition errors on WIN64 reported by Alexey Simak.
* September 29, 2009 (Yang Tse)
- Make configure script also check if _REENTRANT definition is required to
make errno available as a preprocessor macro.
* September 7, 2009 (Yang Tse)
- Add T_SRV portability check to ares_parse_srv_reply.c
* 4 Sep 2009 (Daniel Stenberg)
- Jakub Hrozek added ares_parse_srv_reply() for SRV parsing
* 3 Aug 2009 (Daniel Stenberg)
- Joshua Kwan fixed the init routine to fill in the defaults for stuff that
fails to get inited by other means. This fixes a case of when the c-ares
init fails when internet access is fone.
- Timo Teras changed the reason code used in the resolve callback done when
ares_cancel() is used, to be ARES_ECANCELLED instead of ARES_ETIMEOUT to
better allow the callback to know what's happening.
* 14 Jul 2009 (Guenter Knauf)
- renamed generated config.h to ares_config.h to avoid any future clashes
with config.h from other projects.
* June 20 2009 (Yang Tse)
- Refactor how libraries are checked for connect() function in configure
script and check for connect() as it is done for other functions.
* June 19 2009 (Yang Tse)
- Make sclose() function-like macro definition used to close a socket,
now solely based on HAVE_CLOSESOCKET and HAVE_CLOSESOCKET_CAMEL
config file preprocessor definitions
* June 18 2009 (Yang Tse)
- Add CloseSocket camel case function check for configure script.
* June 17 2009 (Yang Tse)
- Check for socket() and closesocket() as it is done for other functions
in configure script.
* June 11 2009 (Yang Tse)
- Modified buildconf so that when automake runs it copies missing files
instead of symlinking them.
* June 8 2009 (Yang Tse)
- Removed buildconf.bat from release and daily snapshot archives. This
file is only for CVS tree checkout builds.
* May 26 2009 (Yang Tse)
- Added --enable-curldebug configure option to enable and disable building
with the low-level curl debug memory tracking 'feature' to allow decoupled
setting from --enable-debug, allowing again to build c-ares independently
out of the CVS tree.
For the c-ares library option --enable-debug enables debug build features
which are _not_ related with memory tracking. For the c-ares library when
--enable-debug is given it does not enable the memory tracking feature. If
you wish to enable the curl debug memory tracking you must use configure
option --enable-curldebug explicitily to do so.
Internally, definition of preprocessor symbol DEBUGBUILD restricts code
which is only compiled for debug enabled builds. And symbol CURLDEBUG is
used to differentiate code which is _only_ used for memory tracking.
Make ares_init(), ares_dup() and ares_init_options() fail returning
ARES_ENOTINITIALIZED if library initialization has not been performed
calling ares_library_init().
* May 20 2009 (Yang Tse)
- Added ares_library_init() and ares_library_cleanup() man pages.
* May 19 2009 (Yang Tse)
- Introduced ares_library_init() and ares_library_cleanup() functions.
This is an API and ABI break for Win32/64 systems. Non-Win32/64 build targets
using c-ares 1.7.0 can still survive without calling these functions. Read all
the details on ares_library_init(3) and ares_library_cleanup(3) man pages that
are included.
curl/libcurl 7.19.5 is fully compatible with c-ares 1.7.0 on all systems.
In order to use c-ares 1.7.0 with curl/libcurl on Win32/64 systems it is
required that curl/libcurl is 7.19.5 or newer. In other words, it is not
possible on Win32/64 to use c-ares 1.7.0 with a curl/libcurl version less
than 7.19.5
* May 11 2009 (Daniel Stenberg)
- Gregor Jasny made c-ares link with libtool 's -export-symbols-regex option to
only expose functions starting with ares_.
* May 7 2009 (Yang Tse)
- Fix an m4 overquoting triggering a spurious 'AS_TR_CPP' symbol definition
attempt in generated config.h
* May 2 2009 (Yang Tse)
- Use a build-time configured ares_socklen_t data type instead of socklen_t.
* April 21 2009 (Yang Tse)
- Moved potential inclusion of system's malloc.h and memory.h header files to
setup_once.h. Inclusion of each header file is based on the definition of
NEED_MALLOC_H and NEED_MEMORY_H respectively.
* March 11 2009 (Yang Tse)
- Japheth Cleaver fixed acountry.c replacing u_long with unsigned long.
* February 20 2009 (Yang Tse)
- Do not halt compilation when using VS2008 to build a Windows 2000 target.
* February 3 2009 (Phil Blundell)
- If the server returns garbage or nothing at all in response to an AAAA query,
go on and ask for A records anyway.
* January 31 2009 (Daniel Stenberg)
- ares_gethostbyname() now accepts 'AF_UNSPEC' as a family for resolving
either AF_INET6 or AF_INET. It works by accepting any of the looksups in the
hosts file, and it resolves the AAAA field with a fallback to A.
* January 14 2009 (Daniel Stenberg)
- ares.h no longer uses the HAVE_STRUCT_IN6_ADDR define check, but instead it
now declares the private struct ares_in6_addr for all systems instead of
relying on one possibly not present in the system.
* January 13 2009 (Phil Blundell)
- ares__send_query() now varies the retry timeout pseudo-randomly to avoid
packet storms when several queries were started at the same time.
* January 11 2009 (Daniel Stenberg)
- Phil Blundell added the internal function ares__expand_name_for_response()
that is now used by the ares_parse_*_reply() functions instead of the
ares_expand_name() simply to easier return ARES_EBADRESP for the cases where
the name expansion fails as in responses that really isn't expected.
Version 1.6.0 (Dec 9, 2008)
* December 9 2008 (Gisle Vanem)
Fixes for Win32 targets using the Watt-32 tcp/ip stack.
* Dec 4 2008 (Daniel Stenberg)
Gregor Jasny provided the patch that introduces ares_set_socket_callback(),
and I edited it to also get duped by ares_dup().
* Dec 3 2008 (Daniel Stenberg)
API changes:
I made sure the public ares_config struct looks like before and yet it
supports the ROTATE option thanks to c-ares now storing the "optmask"
internally. Thus we should be ABI compatible with the past release(s)
now. My efforts mentioned below should not break backwards ABI compliance.
Here's how I suggest we proceed with the API:
ares_init() will be primary "channel creator" function.
ares_init_options() will continue to work exactly like now and before. For
starters, it will be the (only) way to set the existing options.
ares_save_options() will continue to work like today, but will ONLY save
options that you can set today (including ARES_OPT_ROTATE actually) but new
options that we add may not be saved with this.
Instead we introduce:
ares_dup() that instead can make a new channel and clone the config used
from an existing channel. It will then clone all config options, including
future new things we add.
ares_set_*() style functions that set (new) config options. As a start we
simply add these for new functionality, but over time we can also introduce
them for existing "struct ares_options" so that we can eventually deprecate
the two ares_*_options() functions.
ares_get_*() style functions for extracting info from a channel handle that
should be used instead of ares_save_options().
* Nov 26 2008 (Yang Tse)
- Brad Spencer provided changes to allow buildconf to work on OS X.
- Gerald Combs fixed a bug in ares_parse_ptr_reply() which would cause a
buffer to shrink instead of expand if a reply contained 8 or more records.
* Nov 25 2008 (Yang Tse)
- In preparation for the upcomming IPv6 nameservers patch, the internal
ares_addr union is now changed into an internal struct which also holds
the address family.
* Nov 19 2008 (Daniel Stenberg)
- Brad Spencer brought the new function ares_gethostbyname_file() which simply
resolves a host name from the given file, using the regular hosts syntax.
* Nov 1 2008 (Daniel Stenberg)
- Carlo Contavalli added support for the glibc "rotate" option, as documented
in man resolv.conf:
causes round robin selection of nameservers from among those listed. This
has the effect of spreading the query load among all listed servers, rather
than having all clients try the first listed server first every time.
You can enable it with ARES_OPT_ROTATE
* Oct 21 2008 (Yang Tse)
Charles Hardin added handling of EINPROGRESS for UDP connects.
* Oct 18 2008 (Daniel Stenberg)
Charles Hardin made adig support a regular numerical dotted IP address for the
-s option as well.
* Oct 7 2008 (Yang Tse)
- Added --enable-optimize configure option to enable and disable compiler
optimizations to allow decoupled setting from --enable-debug.
* Oct 2 2008 (Yang Tse)
- Added --enable-warnings configure option to enable and disable strict
compiler warnings to allow decoupled setting from --enable-debug.
* Sep 17 2008 (Yang Tse)
- Code reorganization to allow internal/private use of "nameser.h" to any
system that lacks arpa/nameser.h or arpa/nameser_compat.h header files.
* Sep 16 2008 (Yang Tse)
- Code reorganization to allow internal/private use of ares_writev to any
system that lacks the writev function.
* Sep 15 2008 (Yang Tse)
- Code reorganization to allow internal/private use of ares_strcasecmp to any
system that lacks the strcasecmp function.
- Improve configure detection of some string functions.
* Sep 11 2008 (Yang Tse)
- Code reorganization to allow internal/private use of ares_strdup to any
system that lacks the strdup function.
Version 1.5.3 (Aug 29, 2008)
* Aug 25 2008 (Yang Tse)
- Improvement by Brad House:
This patch addresses an issue in which a response could be sent back to the
source port of a client from a different address than the request was made to.
This is one form of a DNS cache poisoning attack.
The patch simply uses recvfrom() rather than recv() and validates that the
address returned from recvfrom() matches the address of the server we have
connected to. Only necessary on UDP sockets as they are connection-less, TCP
is unaffected.
- Fix by George Neill:
Fixed compilation of acountry sample application failure on some systems.
* Aug 4 2008 (Daniel Stenberg)
- Fix by Tofu Linden:
The symptom:
* Users (usually, but not always) on 2-Wire routers and the Comcast service
and a wired connection to their router would find that the second and
subsequent DNS lookups from fresh processes using c-ares to resolve the same
address would cause the process to never see a reply (it keeps polling for
around 1m15s before giving up).
The repro:
* On such a machine (and yeah, it took us a lot of QA to find the systems
that reproduce such a specific problem!), do 'ahost www.secondlife.com',
then do it again. The first process's lookup will work, subsequent lookups
will time-out and fail.
The cause:
* init_id_key() was calling randomize_key() *before* it initialized
key->state, meaning that the randomness generated by randomize_key() is
immediately overwritten with deterministic values. (/dev/urandom was also
being read incorrectly in the c-ares version we were using, but this was
fixed in a later version.)
* This makes the stream of generated query-IDs from any new c-ares process
be an identical and predictable sequence of IDs.
* This makes the 2-Wire's default built-in DNS server detect these queries
as probable-duplicates and (erroneously) not respond at all.
* Aug 4 2008 (Yang Tse)
- Autoconf 2.62 has changed the behaviour of the AC_AIX macro which we use.
Prior versions of autoconf defined _ALL_SOURCE if _AIX was defined. 2.62
version of AC_AIX defines _ALL_SOURCE and other four preprocessor symbols
no matter if the system is AIX or not. To keep the traditional behaviour,
and an uniform one across autoconf versions AC_AIX is replaced with our
own internal macro CARES_CHECK_AIX_ALL_SOURCE.
* Aug 1 2008 (Yang Tse)
- Configure process now checks if the preprocessor _REENTRANT symbol is already
defined. If it isn't currently defined a set of checks are performed to test
if its definition is required to make visible to the compiler a set of *_r
functions. Finally, if _REENTRANT is already defined or needed it takes care
of making adjustments necessary to ensure that it is defined equally for the
configure process tests and generated config file.
* Jul 20 2008 (Yang Tse)
- When recvfrom prototype uses a void pointer for arguments 2, 5 or 6 this will
now cause the definition, as appropriate, of RECVFROM_TYPE_ARG2_IS_VOID,
RECVFROM_TYPE_ARG5_IS_VOID or RECVFROM_TYPE_ARG6_IS_VOID.
* Jul 17 2008 (Yang Tse)
- RECVFROM_TYPE_ARG2, RECVFROM_TYPE_ARG5 and RECVFROM_TYPE_ARG6 are now defined
to the data type pointed by its respective argument and not the pointer type.
* Jul 16 2008 (Yang Tse)
- Improved configure detection of number of arguments for getservbyport_r.
Detection is now based on compilation checks instead of linker ones.
- Configure process now checks availability of recvfrom() socket function and
finds out its return type and the types of its arguments. Added definitions
for non-configure systems config files, and introduced macro sreadfrom which
will be used on udp sockets as a recvfrom() wrapper in the future.
* Jul 15 2008 (Yang Tse)
- Introduce definition of _REENTRANT symbol in setup.h to improve library
usability. Previously the configure process only used the AC_SYS_LARGEFILE
macro for debug builds, now it is also used for non-debug ones enabling the
use of configure options --enable-largefile and --disable-largefile which
might be needed for library compatibility. Remove checking the size of
curl_off_t, it is no longer needed.
* Jul 3 2008 (Daniel Stenberg)
- Phil Blundell: If you ask ares_gethostbyname() to do an AF_INET6 lookup and
the target host has only A records, it automatically falls back to an
AF_INET lookup and gives you the A results. However, if the target host has
a CNAME record, this behaviour is defeated since the original query does
return some data even though ares_parse_aaa_reply() doesn't consider it
relevant. Here's a small patch to make it behave the same with and without
the CNAME.
* Jul 2 2008 (Yang Tse)
- Fallback to gettimeofday when monotonic clock is unavailable at run-time.
* Jun 30 2008 (Daniel Stenberg)
- As was pointed out to me by Andreas Schuldei, the MAXHOSTNAMELEN define is
not posix or anything and thus c-ares failed to build on hurd (and possibly
elsewhere). The define was also somewhat artificially used in the windows
port. Now, I instead rewrote the use of gethostbyname to enlarge the host
name buffer in case of need and totally avoid the use of the MAXHOSTNAMELEN
define. I thus also removed the defien from the namser.h file where it was
once added for the windows build.
I also fixed init_by_defaults() function to not leak memory in case if
error.
* Jun 9 2008 (Yang Tse)
- Make libcares.pc generated file for pkg-config include information relative
to the libraries needed for the static linking of c-ares.
* May 30 2008 (Yang Tse)
- Brad House fixed a missing header file inclusion in adig sample program.
Version 1.5.2 (May 29, 2008)
* May 13 2008 (Daniel Stenberg)
- Introducing millisecond resolution support for the timeout option. See
ares_init_options()'s ARES_OPT_TIMEOUTMS.
* May 9 2008 (Yang Tse)
- Use monotonic time source if available, for private function ares__tvnow()
* May 7 2008 (Daniel Stenberg)
- Sebastian made c-ares able to return all PTR-records when doing reverse
lookups. It is not common practice to have multiple PTR-Records for a single
IP, but its perfectly legal and some sites have those.
- Doug Goldstein provided a configure patch: updates autoconf 2.13 usage to
autoconf 2.57 usage (which is the version you have specified as the minimum
version). It's a minor change but it does clean up some warnings with newer
autoconf (specifically 2.62).
* May 5 2008 (Yang Tse)
- Improved parsing of resolver configuration files.
* April 4 2008 (Daniel Stenberg)
- Eino Tuominen improved the code when a file is used to seed the randomizer.
- Alexey Simak made adig support NAPTR records
- Alexey Simak fixed the VC dsp file by adding the missing source file
ares_expand_string.c
* December 11 2007 (Gisle Vanem)
- Added another sample application; acountry.c which converts an
IPv4-address(es) and/or host-name(s) to country-name and country-code.
This uses the service of the DNSBL at countries.nerd.dk.
* December 3 2007 (Daniel Stenberg)
- Brad Spencer fixed the configure script to assume that there's no
/dev/urandom when built cross-compiled as then the script cannot check for
it.
- Erik Kline cleaned up ares_gethostbyaddr.c:next_lookup() somewhat
Version 1.5.1 (Nov 21, 2007)
* November 21 2007 (Daniel Stenberg)
- Robin Cornelius pointed out that ares_llist.h was missing in the release
archive for 1.5.0
Version 1.5.0 (Nov 21, 2007)
* October 2 2007 (Daniel Stenberg)
- ares_strerror() segfaulted if the input error number was out of the currently
supported range.
- Yang Tse: Avoid a segfault when generating a DNS "Transaction ID" in
internal function init_id_key() under low memory conditions.
* September 28 2007 (Daniel Stenberg)
- Bumped version to 1.5.0 for next release and soname bumped to 2 due to ABI
and API changes in the progress callback (and possibly more coming up from
Steinar)
* September 28 2007 (Steinar H. Gunderson)
- Don't skip a server if it's the only one. (Bugfix from the Google tree.)
- Made the query callbacks receive the number of timeouts that happened during
the execution of a query, and updated documentation accordingly. (Patch from
the Google tree.)
- Support a few more socket options: ARES_OPT_SOCK_SNDBUF and
ARES_OPT_SOCK_RCVBUF
- Always register for TCP events even if there are no outstanding queries, as
the other side could always close the connection, which is a valid event
which should be responded to.
* September 22 2007 (Daniel Stenberg)
- Steinar H. Gunderson fixed: Correctly clear sockets from the fd_set on in
several functions (write_tcp_data, read_tcp_data, read_udp_packets) so that
if it fails and the socket is closed the following code doesn't try to use
the file descriptor.
- Steinar H. Gunderson modified c-ares to now also do to DNS retries even when
TCP is used since there are several edge cases where it still makes sense.
- Brad House provided a fix for ares_save_options():
Apparently I overlooked something with the ares_save_options() where it
would try to do a malloc(0) when no options of that type needed to be saved.
On most platforms, this was fine because malloc(0) doesn't actually return
NULL, but on AIX it does, so ares_save_options would return ARES_ENOMEM.
* July 14 2007 (Daniel Stenberg)
- Vlad Dinulescu fixed two outstanding valgrind reports:
1. In ares_query.c , in find_query_by_id we compare q->qid (which is a short
int variable) with qid, which is declared as an int variable. Moreover,
DNS_HEADER_SET_QID is used to set the value of qid, but DNS_HEADER_SET_QID
sets only the first two bytes of qid. I think that qid should be declared as
"unsigned short" in this function.
2. The same problem occurs in ares_process.c, process_answer() . query->qid
(an unsigned short integer variable) is compared with id, which is an
integer variable. Moreover, id is initialized from DNS_HEADER_QID which sets
only the first two bytes of id. I think that the id variable should be
declared as "unsigned short" in this function.
Even after declaring these variables as "unsigned short", the valgrind
errors are still there. Which brings us to the third problem.
3. The third problem is that Valgrind assumes that query->qid is not
initialised correctly. And it does that because query->qid is set from
DNS_HEADER_QID(qbuf); Valgrind says that qbuf has unitialised bytes. And
qbuf has uninitialised bytes because of channel->next_id . And next_id is
set by ares_init.c:ares__generate_new_id() . I found that putting short r=0
in this function (instead of short r) makes all Valgrind warnings go away.
I have studied ares__rc4() too, and this is the offending line:
buffer_ptr[counter] ^= state[xorIndex]; (ares_query.c:62)
This is what triggers Valgrind.. buffer_ptr is unitialised in this function,
and by applying ^= on it, it remains unitialised.
Version 1.4.0 (June 8, 2007)
* June 4 2007 (Daniel Stenberg)
- James Bursa reported a major memory problem when resolving multi-IP names
and I found and fixed the problem. It was added by Ashish Sharma's patch
two days ago.
When I then tried to verify multiple entries in /etc/hosts after my fix, I
got another segfault and decided this code was not ripe for inclusion and I
reverted the patch.
* June 2 2007
- Brad Spencer found and fixed three flaws in the code, found with the new
gcc 4.2.0 warning: -Waddress
- Brad House fixed VS2005 compiler warnings due to time_t being 64bit.
He also made recent Microsoft compilers use _strdup() instead of strdup().
- Brad House's man pages for ares_save_options() and ares_destroy_options()
were added.
- Ashish Sharma provided a patch for supporting multiple entries in the
/etc/hosts file. Patch edited for coding style and functionality by me
(Daniel).
* May 30 2007
- Shmulik Regev brought cryptographically secure transaction IDs:
The c-ares library implementation uses a DNS "Transaction ID" field that is
seeded with a pseudo random number (based on gettimeofday) which is
incremented (++) between consecutive calls and is therefore rather
predictable. In general, predictability of DNS Transaction ID is a well
known security problem (e.g.
http://bak.spc.org/dms/archive/dns_id_attack.txt) and makes a c-ares based
implementation vulnerable to DNS poisoning. Credit goes to Amit Klein
(Trusteer) for identifying this problem.
The patch I wrote changes the implementation to use a more secure way of
generating unique IDs. It starts by obtaining a key with reasonable entropy
which is used with an RC4 stream to generate the cryptographically secure
transaction IDs.
Note that the key generation code (in ares_init:randomize_key) has two
versions, the Windows specific one uses a cryptographically safe function
provided (but undocumented :) by the operating system (described at
http://blogs.msdn.com/michael_howard/archive/2005/01/14/353379.aspx). The
default implementation is a bit naive and uses the standard 'rand'
function. Surely a better way to generate random keys exists for other
platforms.
The patch can be tested by using the adig utility and using the '-s' option.
- Brad House added ares_save_options() and ares_destroy_options() that can be
used to keep options for later re-usal when ares_init_options() is used.
Problem: Calling ares_init() for each lookup can be unnecessarily resource
intensive. On windows, it must LoadLibrary() or search the registry
on each call to ares_init(). On unix, it must read and parse
multiple files to obtain the necessary configuration information. In
a single-threaded environment, it would make sense to only
ares_init() once, but in a heavily multi-threaded environment, it is
undesirable to ares_init() and ares_destroy() for each thread created
and track that.
Solution: Create ares_save_options() and ares_destroy_options() functions to
retrieve and free options obtained from an initialized channel. The
options populated can be used to pass back into ares_init_options(),
it should populate all needed fields and not retrieve any information
from the system. Probably wise to destroy the cache every minute or
so to prevent the data from becoming stale.
- Daniel S added ares_process_fd() to allow applications to ask for processing
on specific sockets and thus avoiding select() and associated
functions/macros. This function will be used by upcoming libcurl releases
for this very reason. It also made me export the ares_socket_t type in the
public ares.h header file, since ares_process_fd() uses that type for two of
the arguments.
* May 25 2007
- Ravi Pratap fixed a flaw in the init_by_resolv_conf() function for windows
that could cause it to return a bad return code.
* April 16 2007
- Yang Tse: Provide ares_getopt() command-line parser function as a source
code helper function, not belonging to the actual c-ares library.
* February 19 2007
- Vlad Dinulescu added ares_parse_ns_reply().
* February 13 2007
- Yang Tse: Fix failure to get the search sequence of /etc/hosts and
DNS from /etc/nsswitch.conf, /etc/host.conf or /etc/svc.conf when
/etc/resolv.conf did not exist or was unable to read it.
* November 22 2006
- Install ares_dns.h too
- Michael Wallner fixed this problem: When I set domains in the options
struct, and there are domain/search entries in /etc/resolv.conf, the domains
of the options struct will be overridden.
* November 6 2006
- Yang Tse removed a couple of potential zero size memory allocations.
- Andreas Rieke fixed the line endings in the areslib.dsp file that I (Daniel)
broke in the 1.3.2 release. We should switch to a system where that file is
auto-generated. We could rip some code for that from curl...
Version 1.3.2 (November 3, 2006)
* October 12 2006
- Prevent ares_getsock() to overflow if more than 16 sockets are used.
* September 11 2006
- Guilherme Balena Versiani: I noted a strange BUG in Win32 port
(ares_init.c/get_iphlpapi_dns_info() function): when I disable the network
by hand or disconnect the network cable in Windows 2000 or Windows XP, my
application gets 127.0.0.1 as the only name server. The problem comes from
'GetNetworkParams' function, that returns the empty string "" as the only
name server in that case. Moreover, the Windows implementation of
inet_addr() returns INADDR_LOOPBACK instead of INADDR_NONE.
* August 29 2006
- Brad Spencer did
o made ares_version.h use extern "C" for c++ compilers
o fixed compiler warnings in ares_getnameinfo.c
o fixed a buffer position init for TCP reads
* August 3 2006
- Ravi Pratap fixed ares_getsock() to actually return the proper bitmap and
not always zero!
Version 1.3.1 (June 24, 2006)
* July 23, 2006
- Gisle Vanem added getopt() to the ahost program. Currently accepts
only [-t {a|aaaa}] to specify address family in ares_gethostbyname().
* June 19, 2006
- (wahern) Removed "big endian" DNS section and RR data integer parser
macros from ares_dns.h, which break c-ares on my Sparc64. Bit-wise
operations in C operate on logical values. And in any event the octets are
already in big-endian (aka network) byte order so they're being reversed
(thus the source of the breakage).
* June 18, 2006
- William Ahern handles EAGAIN/EWOULDBLOCK errors in most of the I/O calls
from area_process.c.
TODO: Handle one last EAGAIN for a UDP socket send(2) in
ares__send_query().
* May 10, 2006
- Bram Matthys brought my attention to a libtool peculiarity where detecting
things such as C++ compiler actually is a bad thing and since we don't need
that detection I added a work-around, much inspired by a previous patch by
Paolo Bonzini. This also shortens the configure script quite a lot.
* May 3, 2006
- Nick Mathewson added the ARES_OPT_SOCK_STATE_CB option that when set makes
c-ares call a callback on socket state changes. A better way than the
ares_getsock() to get full control over the socket state.
* January 9, 2006
- Alexander Lazic improved the getservbyport_r() configure check.
* January 6, 2006
- Alexander Lazic pointed out that the buildconf should use the ACLOCAL_FLAGS
variable for easier controlling what it does and how it runs.
* January 5, 2006
- James Bursa fixed c-ares to find the hosts file on RISC OS, and made it
build with newer gcc versions that no longer defines "riscos".
* December 22
- Daniel Stenberg added ares_getsock() that extracts the set of sockets to
wait for action on. Similar to ares_fds() but not restricted to using
select() for the waiting.
* November 25
- Yang Tse fixed some send() / recv() compiler warnings
* September 18
- Added constants that will be used by ares_getaddrinfo
- Made ares_getnameinfo use the reentrant getservbyport (getservbyport_r) if it
is available to ensure it works properly in a threaded environment.
* September 10
- configure fix for detecting a member in the sockaddr_in6 struct which failed
on ipv6-enabled HP-UX 11.00
Version 1.3.0 (August 29, 2005)
* August 21
- Alfredo Tupone provided a fix for the Windows code in get_iphlpapi_dns_info()
when getting the DNS server etc.
* June 19
- Added some checks for the addrinfo structure.
* June 2
- William Ahern:
Make UDP sockets non-blocking. I've confirmed that at least on Linux 2.4 a
read event can come back from poll() on a valid SOCK_DGRAM socket but
recv(2) will still block. This patch doesn't ignore EAGAIN in
read_udp_packets(), though maybe it should. (This patch was edited by Daniel
Stenberg and a new configure test was added (imported from curl's configure)
to properly detect what non-blocking socket approach to use.)
I'm not quite sure how this was happening, but I've been seeing PTR queries
which seem to return empty responses. At least, they were empty when calling
ares_expand_name() on the record. Here's a patch which guarantees to
NUL-terminate the expanded name. The old behavior failed to NUL-terminate if
len was 0, and this was causing strlen() to run past the end of the buffer
after calling ares_expand_name() and getting ARES_SUCCESS as the return
value. If q is not greater than *s then it's equal and *s is always
allocated with at least one byte.
* May 16
- Added ares_getnameinfo which mimics the getnameinfo API (another feature
that could use testing).
* May 14
- Added an inet_ntop function from BIND for systems that do not have it.
* April 9
- Made sortlist support IPv6 (this can probably use some testing).
- Made sortlist support CIDR matching for IPv4.
* April 8
- Added preliminary IPv6 support to ares_gethostbyname. Currently, sortlist
does not work with IPv6. Also provided an implementation of bitncmp from
BIND for systems that do not supply this function. This will be used to add
IPv6 support to sortlist.
- Made ares_gethostbyaddr support IPv6 by specifying AF_INET6 as the family.
The function can lookup IPv6 addresses both from files (/etc/hosts) and
DNS lookups.
* April 7
- Tupone Alfredo fixed includes of arpa/nameser_compat.h to build fine on Mac
OS X.
* April 5
- Dominick Meglio: Provided implementations of inet_net_pton and inet_pton
from BIND for systems that do not include these functions.
* March 11, 2005
- Dominick Meglio added ares_parse_aaaa_reply.c and did various
adjustments. The first little steps towards IPv6 support!
* November 7
- Fixed the VC project and makefile to use ares_cancel and ares_version
* October 24
- The released ares_version.h from 1.2.1 says 1.2.0 due to a maketgz flaw.
This is now fixed.
Version 1.2.1 (October 20, 2004)
* September 29
- Henrik Stoerner fix: got a report that Tru64 Unix (the unix from Digital
when they made Alpha's) uses /etc/svc.conf for the purpose fixed below for
other OSes. He made c-ares check for and understand it if present.
- Now c-ares will use local host name lookup _before_ DNS resolving by default
if nothing else is told.
* September 26
- Henrik Stoerner: found out that c-ares does not look at the /etc/host.conf
file to determine the sequence in which to search /etc/hosts and DNS. So on
systems where this order is defined by /etc/host.conf instead of a "lookup"
entry in /etc/resolv.conf, c-ares will always default to looking in DNS
first, and /etc/hosts second.
c-ares now looks at
1) resolv.conf (for the "lookup" line);
2) nsswitch.fon (for the "hosts:" line);
3) host.conf (for the "order" line).
First match wins.
- Dominick Meglio patched: C-ares on Windows assumed that the HOSTS file is
located in a static location. It assumed
C:\Windows\System32\Drivers\Etc. This is a poor assumption to make. In fact,
the location of the HOSTS file can be changed via a registry setting.
There is a key called DatabasePath which specifies the path to the HOSTS
file:
http://www.microsoft.com/technet/itsolutions/network/deploy/depovg/tcpip2k.mspx
The patch will make c-ares correctly consult the registry for the location
of this file.
* August 29
- Gisle Vanem fixed the MSVC build files.
* August 20
- Gisle Vanem made c-ares build and work with his Watt-32 TCP/IP stack.
* August 13
- Harshal Pradhan made a minor syntax change in ares_init.c to make it build
fine with MSVC 7.1
* July 24
- Made the lib get built static only if --enable-debug is used.
- Gisle Vanem fixed:
Basically in loops like handle_errors(), 'query->next' was assigned a local
variable and then query was referenced after the memory was freed by
next_server(). I've changed that so next_server() and end_query() returns
the next query. So callers should use this ret-value.
The next problem was that 'server->tcp_buffer_pos' had a random value at
entry to 1st recv() (luckily causing Winsock to return ENOBUFS).
I've also added a ares_writev() for Windows to streamline the code a bit
more.
* July 20
- Fixed a few variable return types for some system calls. Made configure
check for ssize_t to make it possible to use that when receiving the send()
error code. This is necessary to prevent compiler warnings on some systems.
- Made configure create config.h, and all source files now include setup.h that
might include the proper config.h (or a handicrafted alternative).
- Switched to 'ares_socket_t' type for sockets in ares, since Windows don't
use 'int' for that.
- automake-ified and libool-ified c-ares. Now it builds libcares as a shared
lib on most platforms if wanted. (This bloated the size of the release
archive with another 200K!)
- Makefile.am now uses Makefile.inc for the c sources, h headers and man
pages, to make it easier for other makefiles to use the exact same set of
files.
- Adjusted 'maketgz' to use the new automake magic when building distribution
archives.
- Anyone desires HTML and/or PDF versions of the man pages in the release
archives?
* July 3
- Günter Knauf made c-ares build and run on Novell Netware.
* July 1
- Gisle Vanem provided Makefile.dj to build with djgpp, added a few more djgpp
fixes and made ares not use 'errno' to provide further info on Windows.
* June 30
- Gisle Vanem made it build with djgpp and run fine with the Watt-32 stack.
* June 10
- Gisle Vanem's init patch for Windows:
The init_by_resolv_conf() function fetches the DNS-server(s)
from a series of registry branches.
This can be wrong in the case where DHCP has assigned nameservers, but the
user has overridden these servers with other prefered settings. Then it's
wrong to use the DHCPNAMESERVER setting in registry.
In the case of no global DHCP-assigned or fixed servers, but DNS server(s)
per adapter, one has to query the adapter branches. But how can c-ares know
which adapter is valid for use? AFAICS it can't. There could be one adapter
that is down (e.g. a VPN adapter).
So it's better to leave this to the IP Helper API (iphlapi) available in
Win-98/2000 and later. My patch falls-back to the old way if not available.
* June 8
- James Bursa fixed an init issue for RISC OS.
* May 11
- Nico Stappenbelt reported that when processing domain and search lines in
the resolv.conf file, the first entry encountered is processed and used as
the search list. According to the manual pages for both Linux, Solaris and
Tru64, the last entry of either a domain or a search field is used.
This is now adjusted in the code
Version 1.2.0 (April 13, 2004)
* April 2, 2004
- Updated various man pages to look nicer when converted to HTML on the web
site.
* April 1, 2004
- Dirk Manske provided a new function that is now named ares_cancel(). It is
used to cancel/cleanup a resolve/request made using ares functions on the
given ares channel. It does not destroy/kill the ares channel itself.
- Dominick Meglio cleaned up the formatting in several man pages.
* March 30, 2004
- Dominick Meglio's new ares_expand_string. A helper function when decoding
incoming DNS packages.
- Daniel Stenberg modified the Makefile.in to use a for loop for the man page
installation to improve overview and make it easier to add man pages.
Version 1.1.0 (March 11, 2004)
* March 9, 2004
- Gisle Vanem improved build on Windows.
* February 25, 2004
- Dan Fandrich found a flaw in the Feb 22 fix.
- Added better configure --enable-debug logic (taken from the curl configure
script). Added acinclude.m4 to the tarball.
* February 23, 2004
- Removed ares_free_errmem(), the function, the file and the man page. It was
not used and it did nothing.
- Fixed a lot of code that wasn't "64bit clean" and thus caused a lot of
compiler warnings on picky compilers.
* February 22, 2004
- Dominick Meglio made ares init support multiple name servers in the
NameServer key on Windows.
* February 16, 2004
- Modified ares_private.h to include libcurl's memory debug header if
CURLDEBUG is set. This makes all the ares-functions supervised properly by
the curl test suite. This also forced me to add inclusion of the
ares_private.h header in a few more files that are using some kind of
memory-related resources.
- Made the makefile only build ahost and adig if 'make demos' is used.
* February 10, 2004
- Dirk Manske made ares_version.h installed with 'make install'
* February 4, 2004
- ares_free_errmem() is subject for removal, it is simply present for future
purposes, and since we removed the extra parameter in strerror() it won't
be used by c-ares!
- configure --enable-debug now enables picky compiler options if gcc is used
- fixed several compiler warnings --enable-debug showed and Joerg Mueller-Tolk
reported
Version 1.0.0 (February 3, 2004)
* February 3, 2004
- now we produce the libcares.a library instead of the previous libares.a
since we are no longer compatible
* February 2, 2004
- ares_strerror() has one argument less. This is the first official
modification of the existing provided ares API.
* January 29, 2004
- Dirk Manske fixed how the socket is set non-blocking.
* January 4, 2004
- Dominick Meglio made the private gettimeofday() become ares_gettimeofday()
instead in order to not pollute the name space and risk colliding with
other libraries' versions of this function.
* October 24, 2003. Daniel Stenberg
Added ares_version().
Version 1.0-pre1 (8 October 2003)
- James Bursa made it run on RISC OS
- Dominick Meglio made it run fine on NT4
- Duncan Wilcox made it work fine on Mac OS X
- Daniel Stenberg adjusted the windows port
- liren at vivisimo.com made the initial windows port
* Imported the sources from ares 1.1.1
/* 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
......@@ -48,6 +48,12 @@
# 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
......
......@@ -102,6 +102,9 @@
/* Define to 1 if the getaddrinfo function is threadsafe. */
#undef HAVE_GETADDRINFO_THREADSAFE
/* Define to 1 if you have the getenv function. */
#undef HAVE_GETENV
/* Define to 1 if you have the gethostbyaddr function. */
#undef HAVE_GETHOSTBYADDR
......@@ -123,12 +126,9 @@
/* Define to 1 if you have the `if_indextoname' function. */
#undef HAVE_IF_INDEXTONAME
/* Define to 1 if you have the `inet_net_pton' function. */
/* Define to 1 if you have a IPv6 capable working inet_net_pton function. */
#undef HAVE_INET_NET_PTON
/* Define to 1 if inet_net_pton supports IPv6. */
#undef HAVE_INET_NET_PTON_IPV6
/* Define to 1 if you have a IPv6 capable working inet_ntop function. */
#undef HAVE_INET_NTOP
......@@ -377,6 +377,9 @@
/* a suitable file/device to read random data from */
#undef RANDOM_FILE
/* Define to the type qualifier pointed by arg 5 for recvfrom. */
#undef RECVFROM_QUAL_ARG5
/* Define to the type of arg 1 for recvfrom. */
#undef RECVFROM_TYPE_ARG1
......
#ifndef ARES_DATA_H
#define ARES_DATA_H
/* Copyright (C) 2009-2010 by Daniel Stenberg
*
......@@ -65,5 +63,3 @@ struct ares_data {
void *ares_malloc_data(ares_datatype type);
ares_datatype ares_get_datatype(void * dataptr);
#endif
......@@ -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;
}
......
......@@ -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);
......
#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 */
......@@ -42,6 +42,7 @@
#include "ares.h"
#include "inet_net_pton.h"
#include "ares_platform.h"
#include "ares_private.h"
#ifdef WATT32
......@@ -59,12 +60,12 @@ struct addr_query {
int timeouts;
};
static void gethostbyaddr_next_lookup(struct addr_query *aquery);
static void next_lookup(struct addr_query *aquery);
static void addr_callback(void *arg, int status, int timeouts,
unsigned char *abuf, int alen);
static void end_aquery(struct addr_query *aquery, int status,
struct hostent *host);
static int gethostbyaddr_file_lookup(struct ares_addr *addr, struct hostent **host);
static int file_lookup(struct ares_addr *addr, struct hostent **host);
static void ptr_rr_name(char *name, const struct ares_addr *addr);
void ares_gethostbyaddr(ares_channel channel, const void *addr, int addrlen,
......@@ -102,10 +103,10 @@ void ares_gethostbyaddr(ares_channel channel, const void *addr, int addrlen,
aquery->remaining_lookups = channel->lookups;
aquery->timeouts = 0;
gethostbyaddr_next_lookup(aquery);
next_lookup(aquery);
}
static void gethostbyaddr_next_lookup(struct addr_query *aquery)
static void next_lookup(struct addr_query *aquery)
{
const char *p;
char name[128];
......@@ -123,7 +124,7 @@ static void gethostbyaddr_next_lookup(struct addr_query *aquery)
aquery);
return;
case 'f':
status = gethostbyaddr_file_lookup(&aquery->addr, &host);
status = file_lookup(&aquery->addr, &host);
/* this status check below previously checked for !ARES_ENOTFOUND,
but we should not assume that this single error code is the one
......@@ -166,7 +167,7 @@ static void addr_callback(void *arg, int status, int timeouts,
else if (status == ARES_EDESTRUCTION)
end_aquery(aquery, status, NULL);
else
gethostbyaddr_next_lookup(aquery);
next_lookup(aquery);
}
static void end_aquery(struct addr_query *aquery, int status,
......@@ -178,7 +179,7 @@ static void end_aquery(struct addr_query *aquery, int status,
free(aquery);
}
static int gethostbyaddr_file_lookup(struct ares_addr *addr, struct hostent **host)
static int file_lookup(struct ares_addr *addr, struct hostent **host)
{
FILE *fp;
int status;
......@@ -186,7 +187,13 @@ static int gethostbyaddr_file_lookup(struct ares_addr *addr, struct hostent **ho
#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;
......@@ -200,8 +207,10 @@ static int gethostbyaddr_file_lookup(struct ares_addr *addr, struct hostent **ho
RegCloseKey(hkeyHosts);
}
}
else
else if (platform == WIN_9X)
GetWindowsDirectory(PATH_HOSTS, MAX_PATH);
else
return ARES_ENOTFOUND;
strcat(PATH_HOSTS, WIN_PATH_HOSTS);
......
......@@ -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
......@@ -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 (hquery->want_family == AF_UNSPEC && (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);
......@@ -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 && hquery->want_family == AF_UNSPEC)
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);
......@@ -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;
......@@ -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);
......
......@@ -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 {
......@@ -187,7 +188,7 @@ 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(struct sockaddr_in));
memcpy(&niquery->addr.addr4, addr, sizeof(struct in_addr));
ares_gethostbyaddr(channel, &addr->sin_addr,
sizeof(struct in_addr), AF_INET,
nameinfo_callback, niquery);
......@@ -195,7 +196,7 @@ void ares_getnameinfo(ares_channel channel, const struct sockaddr *sa,
else
{
niquery->family = AF_INET6;
memcpy(&niquery->addr.addr6, addr6, sizeof(struct sockaddr_in6));
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);
......
/* Copyright 1998 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
......@@ -17,10 +17,6 @@
#include "ares_setup.h"
#ifdef USE_WINSOCK
#include <iphlpapi.h>
#endif
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
......@@ -63,17 +59,19 @@
#include <string.h>
#include <ctype.h>
#include <time.h>
#include <errno.h>
#ifdef ANDROID
#include <sys/system_properties.h>
#endif
#include "ares.h"
#include "inet_net_pton.h"
#include "ares_library_init.h"
#include "ares_nowarn.h"
#include "ares_platform.h"
#include "inet_ntop.h"
#include "ares_private.h"
#ifdef ANDROID
#include <sys/system_properties.h>
#endif
#ifdef WATT32
#undef WIN32 /* Redefined in MingW/MSVC headers */
#endif
......@@ -102,7 +100,7 @@ static int config_lookup(ares_channel channel, const char *str,
const char *bindch, const char *filech);
static int config_sortlist(struct apattern **sortlist, int *nsort,
const char *str);
static char *try_config(char *s, const char *opt);
static char *try_config(char *s, const char *opt, char scc);
#endif
#define ARES_CONFIG_CHECK(x) (x->lookups && x->nsort > -1 && \
......@@ -363,7 +361,7 @@ int ares_save_options(ares_channel channel, struct ares_options *options,
ipv4_nservers++;
}
if (ipv4_nservers) {
options->servers = malloc(ipv4_nservers * sizeof(struct server_state));
options->servers = malloc(ipv4_nservers * sizeof(struct in_addr));
if (!options->servers)
return ARES_ENOMEM;
for (i = j = 0; i < channel->nservers; i++)
......@@ -595,73 +593,195 @@ static int get_res_interfaces_nt(HKEY hKey, const char *subkey, char **obuf)
return 0;
}
/**
* The desired output for this method is that we set "ret_buf" to
* something like:
*
* 192.168.0.1,dns01.my.domain,fe80::200:f8ff:fe21:67cf
*
* The only ordering requirement is that primary servers are listed
* before secondary. There is no requirement that IPv4 addresses should
* necessarily be before IPv6.
*
* Note that ret_size should ideally be big enough to hold around
* 2-3 IPv4 and 2-3 IPv6 addresses.
*
* Finally, we need to return the total number of DNS servers located.
*/
static int get_iphlpapi_dns_info (char *ret_buf, size_t ret_size)
{
FIXED_INFO *fi, *newfi;
DWORD size = sizeof (*fi);
IP_ADDR_STRING *ipAddr;
int i, count = 0;
int debug = 0;
size_t ip_size = sizeof("255.255.255.255,")-1;
size_t left = ret_size;
char *ret = ret_buf;
HRESULT res;
fi = malloc(size);
if (!fi)
return 0;
res = (*ares_fpGetNetworkParams) (fi, &size);
if ((res != ERROR_BUFFER_OVERFLOW) && (res != ERROR_SUCCESS))
goto quit;
newfi = realloc(fi, size);
if (!newfi)
goto quit;
fi = newfi;
res = (*ares_fpGetNetworkParams) (fi, &size);
if (res != ERROR_SUCCESS)
goto quit;
if (debug)
const size_t ipv4_size = INET_ADDRSTRLEN + 1; /* +1 for ',' at end */
const size_t ipv6_size = INET6_ADDRSTRLEN + 12; /* +12 for "%0123456789," at end */
size_t left = ret_size;
char *ret = ret_buf;
int count = 0;
/* Use the GetAdaptersAddresses method if it's available, otherwise
fall back to GetNetworkParams. */
if (ares_fpGetAdaptersAddresses != ZERO_NULL)
{
printf ("Host Name: %s\n", fi->HostName);
printf ("Domain Name: %s\n", fi->DomainName);
printf ("DNS Servers:\n"
" %s (primary)\n", fi->DnsServerList.IpAddress.String);
const ULONG working_buf_size = 15000;
IP_ADAPTER_ADDRESSES *pFirstEntry = NULL;
IP_ADAPTER_ADDRESSES *pEntry = NULL;
ULONG bufSize = 0;
ULONG result = 0;
/* According to MSDN, the recommended way to do this is to use a temporary
buffer of 15K, to "dramatically reduce the chance that the GetAdaptersAddresses
method returns ERROR_BUFFER_OVERFLOW" */
pFirstEntry = ( IP_ADAPTER_ADDRESSES * ) malloc( working_buf_size );
bufSize = working_buf_size;
if( !pFirstEntry )
return 0;
/* Call the method one time */
result = ( *ares_fpGetAdaptersAddresses )( AF_UNSPEC, 0, 0, pFirstEntry, &bufSize );
if( result == ERROR_BUFFER_OVERFLOW )
{
/* Reallocate, bufSize should now be set to the required size */
pFirstEntry = ( IP_ADAPTER_ADDRESSES * ) realloc( pFirstEntry, bufSize );
if( !pFirstEntry )
return 0;
/* Call the method a second time */
result = ( *ares_fpGetAdaptersAddresses )( AF_UNSPEC, 0, 0, pFirstEntry, &bufSize );
if( result == ERROR_BUFFER_OVERFLOW )
{
/* Reallocate, bufSize should now be set to the required size */
pFirstEntry = ( IP_ADAPTER_ADDRESSES * ) realloc( pFirstEntry, bufSize );
if( !pFirstEntry )
return 0;
/* Call the method a third time. The maximum number of times we're going to do
this is 3. Three shall be the number thou shalt count, and the number of the
counting shall be three. Five is right out. */
result = ( *ares_fpGetAdaptersAddresses )( AF_UNSPEC, 0, 0, pFirstEntry, &bufSize );
}
}
/* Check the current result for failure */
if( result != ERROR_SUCCESS )
{
free( pFirstEntry );
return 0;
}
/* process the results */
for( pEntry = pFirstEntry ; pEntry != NULL ; pEntry = pEntry->Next )
{
IP_ADAPTER_DNS_SERVER_ADDRESS* pDNSAddr = pEntry->FirstDnsServerAddress;
for( ; pDNSAddr != NULL ; pDNSAddr = pDNSAddr->Next )
{
struct sockaddr *pGenericAddr = pDNSAddr->Address.lpSockaddr;
size_t stringlen = 0;
if( pGenericAddr->sa_family == AF_INET && left > ipv4_size )
{
/* Handle the v4 case */
struct sockaddr_in *pIPv4Addr = ( struct sockaddr_in * ) pGenericAddr;
ares_inet_ntop( AF_INET, &pIPv4Addr->sin_addr, ret, ipv4_size - 1 ); /* -1 for comma */
/* Append a comma to the end, THEN NULL. Should be OK because we
already tested the size at the top of the if statement. */
stringlen = strlen( ret );
ret[ stringlen ] = ',';
ret[ stringlen + 1 ] = '\0';
ret += stringlen + 1;
left -= ret - ret_buf;
++count;
}
else if( pGenericAddr->sa_family == AF_INET6 && left > ipv6_size )
{
/* Handle the v6 case */
struct sockaddr_in6 *pIPv6Addr = ( struct sockaddr_in6 * ) pGenericAddr;
ares_inet_ntop( AF_INET6, &pIPv6Addr->sin6_addr, ret, ipv6_size - 1 ); /* -1 for comma */
/* Append a comma to the end, THEN NULL. Should be OK because we
already tested the size at the top of the if statement. */
stringlen = strlen( ret );
ret[ stringlen ] = ',';
ret[ stringlen + 1 ] = '\0';
ret += stringlen + 1;
left -= ret - ret_buf;
++count;
/* NB on Windows this also returns stuff in the fec0::/10 range,
seems to be hard-coded somehow. Do we need to ignore them? */
}
}
}
if( pFirstEntry )
free( pFirstEntry );
if (ret > ret_buf)
ret[-1] = '\0';
return count;
}
if (strlen(fi->DnsServerList.IpAddress.String) > 0 &&
inet_addr(fi->DnsServerList.IpAddress.String) != INADDR_NONE &&
left > ip_size)
else
{
ret += sprintf (ret, "%s,", fi->DnsServerList.IpAddress.String);
left -= ret - ret_buf;
count++;
}
FIXED_INFO *fi, *newfi;
DWORD size = sizeof (*fi);
IP_ADDR_STRING *ipAddr;
int i;
int debug = 0;
HRESULT res;
fi = malloc(size);
if (!fi)
return 0;
res = (*ares_fpGetNetworkParams) (fi, &size);
if ((res != ERROR_BUFFER_OVERFLOW) && (res != ERROR_SUCCESS))
goto quit;
newfi = realloc(fi, size);
if (!newfi)
goto quit;
fi = newfi;
res = (*ares_fpGetNetworkParams) (fi, &size);
if (res != ERROR_SUCCESS)
goto quit;
for (i = 0, ipAddr = fi->DnsServerList.Next; ipAddr && left > ip_size;
ipAddr = ipAddr->Next, i++)
{
if (inet_addr(ipAddr->IpAddress.String) != INADDR_NONE)
if (debug)
{
ret += sprintf (ret, "%s,", ipAddr->IpAddress.String);
left -= ret - ret_buf;
count++;
printf ("Host Name: %s\n", fi->HostName);
printf ("Domain Name: %s\n", fi->DomainName);
printf ("DNS Servers:\n"
" %s (primary)\n", fi->DnsServerList.IpAddress.String);
}
if (strlen(fi->DnsServerList.IpAddress.String) > 0 &&
inet_addr(fi->DnsServerList.IpAddress.String) != INADDR_NONE &&
left > ipv4_size)
{
ret += sprintf (ret, "%s,", fi->DnsServerList.IpAddress.String);
left -= ret - ret_buf;
++count;
}
for (i = 0, ipAddr = fi->DnsServerList.Next; ipAddr && left > ipv4_size;
ipAddr = ipAddr->Next, i++)
{
if (inet_addr(ipAddr->IpAddress.String) != INADDR_NONE)
{
ret += sprintf (ret, "%s,", ipAddr->IpAddress.String);
left -= ret - ret_buf;
++count;
}
if (debug)
printf (" %s (secondary %d)\n", ipAddr->IpAddress.String, i+1);
}
if (debug)
printf (" %s (secondary %d)\n", ipAddr->IpAddress.String, i+1);
}
quit:
if (fi)
free(fi);
if (debug && left <= ip_size)
printf ("Too many nameservers. Truncating to %d addressess", count);
if (ret > ret_buf)
ret[-1] = '\0';
return count;
if (fi)
free(fi);
if (debug && left <= ipv4_size)
printf ("Too many nameservers. Truncating to %d addressess", count);
if (ret > ret_buf)
ret[-1] = '\0';
return count;
}
}
#endif
......@@ -704,7 +824,8 @@ DhcpNameServer
DWORD data_type;
DWORD bytes;
DWORD result;
char buf[256];
char buf[512];
win_platform platform;
if (channel->nservers > -1) /* don't override ARES_OPT_SERVER */
return ARES_SUCCESS;
......@@ -716,7 +837,9 @@ DhcpNameServer
goto okay;
}
if (IS_NT())
platform = ares__getplatform();
if (platform == WIN_NT)
{
if (RegOpenKeyEx(
HKEY_LOCAL_MACHINE, WIN_NS_NT_KEY, 0,
......@@ -750,7 +873,7 @@ DhcpNameServer
RegCloseKey(mykey);
}
}
else
else if (platform == WIN_9X)
{
if (RegOpenKeyEx(
HKEY_LOCAL_MACHINE, WIN_NS_9X, 0,
......@@ -832,7 +955,10 @@ DhcpNameServer
return ARES_ENOMEM;
for (i = 0; def_nameservers[i]; i++)
servers[i].addr.addrV4.s_addr = htonl(def_nameservers[i]);
{
servers[i].addr.addrV4.s_addr = htonl(def_nameservers[i]);
servers[i].addr.family = AF_INET;
}
status = ARES_EOF;
#elif defined(ANDROID)
......@@ -856,17 +982,19 @@ DhcpNameServer
if (fp) {
while ((status = ares__read_line(fp, &line, &linesize)) == ARES_SUCCESS)
{
if ((p = try_config(line, "domain")))
if ((p = try_config(line, "domain", ';')))
status = config_domain(channel, p);
else if ((p = try_config(line, "lookup")) && !channel->lookups)
else if ((p = try_config(line, "lookup", ';')) && !channel->lookups)
status = config_lookup(channel, p, "bind", "file");
else if ((p = try_config(line, "search")))
else if ((p = try_config(line, "search", ';')))
status = set_search(channel, p);
else if ((p = try_config(line, "nameserver")) && channel->nservers == -1)
else if ((p = try_config(line, "nameserver", ';')) &&
channel->nservers == -1)
status = config_nameserver(&servers, &nservers, p);
else if ((p = try_config(line, "sortlist")) && channel->nsort == -1)
else if ((p = try_config(line, "sortlist", ';')) &&
channel->nsort == -1)
status = config_sortlist(&sortlist, &nsort, p);
else if ((p = try_config(line, "options")))
else if ((p = try_config(line, "options", ';')))
status = set_options(channel, p);
else
status = ARES_SUCCESS;
......@@ -896,8 +1024,9 @@ DhcpNameServer
if (fp) {
while ((status = ares__read_line(fp, &line, &linesize)) == ARES_SUCCESS)
{
if ((p = try_config(line, "hosts:")) && !channel->lookups)
status = config_lookup(channel, p, "dns", "files");
if ((p = try_config(line, "hosts:", '\0')) && !channel->lookups)
/* ignore errors */
(void)config_lookup(channel, p, "dns", "files");
}
fclose(fp);
}
......@@ -923,8 +1052,9 @@ DhcpNameServer
if (fp) {
while ((status = ares__read_line(fp, &line, &linesize)) == ARES_SUCCESS)
{
if ((p = try_config(line, "order")) && !channel->lookups)
status = config_lookup(channel, p, "bind", "hosts");
if ((p = try_config(line, "order", '\0')) && !channel->lookups)
/* ignore errors */
(void)config_lookup(channel, p, "bind", "hosts");
}
fclose(fp);
}
......@@ -950,8 +1080,9 @@ DhcpNameServer
if (fp) {
while ((status = ares__read_line(fp, &line, &linesize)) == ARES_SUCCESS)
{
if ((p = try_config(line, "hosts=")) && !channel->lookups)
status = config_lookup(channel, p, "bind", "local");
if ((p = try_config(line, "hosts=", '\0')) && !channel->lookups)
/* ignore errors */
(void)config_lookup(channel, p, "bind", "local");
}
fclose(fp);
}
......@@ -1042,10 +1173,13 @@ static int init_by_defaults(ares_channel channel)
channel->nservers = 1;
}
#ifdef ENAMETOOLONG
#define toolong(x) (x == -1) && ((ENAMETOOLONG == errno) || (EINVAL == errno))
#if defined(USE_WINSOCK)
#define toolong(x) (x == -1) && (SOCKERRNO == WSAEFAULT)
#elif defined(ENAMETOOLONG)
#define toolong(x) (x == -1) && ((SOCKERRNO == ENAMETOOLONG) || \
(SOCKERRNO == EINVAL))
#else
#define toolong(x) (x == -1) && (EINVAL == errno)
#define toolong(x) (x == -1) && (SOCKERRNO == EINVAL)
#endif
if (channel->ndomains == -1) {
......@@ -1287,9 +1421,9 @@ static int config_sortlist(struct apattern **sortlist, int *nsort,
if (!sortlist_alloc(sortlist, nsort, &pat))
return ARES_ENOMEM;
}
if (ipbufpfx[0] &&
(bits = ares_inet_net_pton(AF_INET, ipbufpfx, &pat.addrV4,
sizeof(pat.addrV4))) > 0)
else if (ipbufpfx[0] &&
(bits = ares_inet_net_pton(AF_INET, ipbufpfx, &pat.addrV4,
sizeof(pat.addrV4))) > 0)
{
pat.type = PATTERN_CIDR;
pat.mask.bits = (unsigned short)bits;
......@@ -1426,7 +1560,7 @@ static const char *try_option(const char *p, const char *q, const char *opt)
}
#if !defined(WIN32) && !defined(WATT32)
static char *try_config(char *s, const char *opt)
static char *try_config(char *s, const char *opt, char scc)
{
size_t len;
char *p;
......@@ -1436,10 +1570,17 @@ static char *try_config(char *s, const char *opt)
/* no line or no option */
return NULL;
/* Hash '#' character is always used as primary comment char, additionally
a not-NUL secondary comment char will be considered when specified. */
/* trim line comment */
p = s;
while (*p && (*p != '#'))
p++;
if(scc)
while (*p && (*p != '#') && (*p != scc))
p++;
else
while (*p && (*p != '#'))
p++;
*p = '\0';
/* trim trailing whitespace */
......
......@@ -26,6 +26,7 @@
#ifdef USE_WINSOCK
fpGetNetworkParams_t ares_fpGetNetworkParams = ZERO_NULL;
fpSystemFunction036_t ares_fpSystemFunction036 = ZERO_NULL;
fpGetAdaptersAddresses_t ares_fpGetAdaptersAddresses = ZERO_NULL;
#endif
/* library-private global vars with source visibility restricted to this file */
......@@ -56,6 +57,15 @@ static int ares_win32_init(void)
return ARES_EADDRGETNETWORKPARAMS;
}
ares_fpGetAdaptersAddresses = (fpGetAdaptersAddresses_t)
GetProcAddress(hnd_iphlpapi, "GetAdaptersAddresses");
if (!ares_fpGetAdaptersAddresses)
{
/* This can happen on clients before WinXP, I don't
think it should be an error, unless we don't want to
support Windows 2000 anymore */
}
/*
* When advapi32.dll is unavailable or advapi32.dll has no SystemFunction036,
* also known as RtlGenRandom, which is the case for Windows versions prior
......
......@@ -3,7 +3,7 @@
/* Copyright 1998 by the Massachusetts Institute of Technology.
* Copyright (C) 2004-2009 by Daniel Stenberg
* Copyright (C) 2004-2011 by Daniel Stenberg
*
* Permission to use, copy, modify, and distribute this
* software and its documentation for any purpose and without
......@@ -23,15 +23,18 @@
#ifdef USE_WINSOCK
#include <iphlpapi.h>
#include <ares_iphlpapi.h>
typedef DWORD (WINAPI *fpGetNetworkParams_t) (FIXED_INFO*, DWORD*);
typedef BOOLEAN (APIENTRY *fpSystemFunction036_t) (void*, ULONG);
typedef ULONG (WINAPI *fpGetAdaptersAddresses_t) ( ULONG, ULONG, void*, IP_ADAPTER_ADDRESSES*, ULONG* );
/* Forward-declaration of variables defined in ares_library_init.c */
/* that are global and unique instances for whole c-ares library. */
extern fpGetNetworkParams_t ares_fpGetNetworkParams;
extern fpSystemFunction036_t ares_fpSystemFunction036;
extern fpGetAdaptersAddresses_t ares_fpGetAdaptersAddresses;
#endif /* USE_WINSOCK */
......
/* Copyright (C) 2010 by Daniel Stenberg
/* Copyright (C) 2010-2011 by Daniel Stenberg
*
* Permission to use, copy, modify, and distribute this
* software and its documentation for any purpose and without
......@@ -17,6 +17,26 @@
#include "ares_setup.h"
#ifdef HAVE_ASSERT_H
# include <assert.h>
#endif
#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
#ifdef HAVE_ARPA_INET_H
# include <arpa/inet.h>
#endif
#endif /* __INTEL_COMPILER && __unix__ */
#define BUILDING_ARES_NOWARN_C 1
#include "ares_nowarn.h"
#if (SIZEOF_INT == 2)
......@@ -34,7 +54,7 @@
#endif
/*
** size_t to signed int
** unsigned size_t to signed int
*/
int aresx_uztosi(size_t uznum)
......@@ -62,9 +82,100 @@ int aresx_sltosi(long slnum)
# pragma warning(disable:810) /* conversion may lose significant bits */
#endif
DEBUGASSERT(slnum >= 0);
return (int)(slnum & (long) CARES_MASK_SINT);
#ifdef __INTEL_COMPILER
# pragma warning(pop)
#endif
}
/*
** signed ssize_t to signed int
*/
int aresx_sztosi(ssize_t sznum)
{
#ifdef __INTEL_COMPILER
# pragma warning(push)
# pragma warning(disable:810) /* conversion may lose significant bits */
#endif
DEBUGASSERT(sznum >= 0);
return (int)(sznum & (ssize_t) CARES_MASK_SINT);
#ifdef __INTEL_COMPILER
# pragma warning(pop)
#endif
}
/*
** signed ssize_t to unsigned int
*/
unsigned int aresx_sztoui(ssize_t sznum)
{
#ifdef __INTEL_COMPILER
# pragma warning(push)
# pragma warning(disable:810) /* conversion may lose significant bits */
#endif
DEBUGASSERT(sznum >= 0);
return (unsigned int)(sznum & (ssize_t) CARES_MASK_UINT);
#ifdef __INTEL_COMPILER
# pragma warning(pop)
#endif
}
#if defined(__INTEL_COMPILER) && defined(__unix__)
int aresx_FD_ISSET(int fd, fd_set *fdset)
{
#pragma warning(push)
#pragma warning(disable:1469) /* clobber ignored */
return FD_ISSET(fd, fdset);
#pragma warning(pop)
}
void aresx_FD_SET(int fd, fd_set *fdset)
{
#pragma warning(push)
#pragma warning(disable:1469) /* clobber ignored */
FD_SET(fd, fdset);
#pragma warning(pop)
}
void aresx_FD_ZERO(fd_set *fdset)
{
#pragma warning(push)
#pragma warning(disable:593) /* variable was set but never used */
FD_ZERO(fdset);
#pragma warning(pop)
}
unsigned short aresx_htons(unsigned short usnum)
{
#if (__INTEL_COMPILER == 910) && defined(__i386__)
return (unsigned short)(((usnum << 8) & 0xFF00) | ((usnum >> 8) & 0x00FF));
#else
#pragma warning(push)
#pragma warning(disable:810) /* conversion may lose significant bits */
return htons(usnum);
#pragma warning(pop)
#endif
}
unsigned short aresx_ntohs(unsigned short usnum)
{
#if (__INTEL_COMPILER == 910) && defined(__i386__)
return (unsigned short)(((usnum << 8) & 0xFF00) | ((usnum >> 8) & 0x00FF));
#else
#pragma warning(push)
#pragma warning(disable:810) /* conversion may lose significant bits */
return ntohs(usnum);
#pragma warning(pop)
#endif
}
#endif /* __INTEL_COMPILER && __unix__ */
......@@ -2,7 +2,7 @@
#define HEADER_CARES_NOWARN_H
/* Copyright (C) 2010 by Daniel Stenberg
/* Copyright (C) 2010-2011 by Daniel Stenberg
*
* Permission to use, copy, modify, and distribute this
* software and its documentation for any purpose and without
......@@ -21,4 +21,35 @@ int aresx_uztosi(size_t uznum);
int aresx_sltosi(long slnum);
int aresx_sztosi(ssize_t sznum);
unsigned int aresx_sztoui(ssize_t sznum);
#if defined(__INTEL_COMPILER) && defined(__unix__)
int aresx_FD_ISSET(int fd, fd_set *fdset);
void aresx_FD_SET(int fd, fd_set *fdset);
void aresx_FD_ZERO(fd_set *fdset);
unsigned short aresx_htons(unsigned short usnum);
unsigned short aresx_ntohs(unsigned short usnum);
#ifndef BUILDING_ARES_NOWARN_C
# undef FD_ISSET
# define FD_ISSET(a,b) aresx_FD_ISSET((a),(b))
# undef FD_SET
# define FD_SET(a,b) aresx_FD_SET((a),(b))
# undef FD_ZERO
# define FD_ZERO(a) aresx_FD_ZERO((a))
# undef htons
# define htons(a) aresx_htons((a))
# undef ntohs
# define ntohs(a) aresx_ntohs((a))
#endif
#endif /* __INTEL_COMPILER && __unix__ */
#endif /* HEADER_CARES_NOWARN_H */
/* Copyright 1998 by the Massachusetts Institute of Technology.
* Copyright (C) 2008-2010 by Daniel Stenberg
* Copyright (C) 2008-2011 by Daniel Stenberg
*
* Permission to use, copy, modify, and distribute this
* software and its documentation for any purpose and without
......@@ -135,12 +135,10 @@ int ares_set_servers(ares_channel channel,
int ares_set_servers_csv(ares_channel channel,
const char* _csv)
{
int i;
size_t i;
char* csv = NULL;
char* ptr;
char* start_host;
long port;
bool found_port;
int rv = ARES_SUCCESS;
struct ares_addr_node *servers = NULL;
struct ares_addr_node *last = NULL;
......@@ -165,7 +163,6 @@ int ares_set_servers_csv(ares_channel channel,
}
start_host = csv;
found_port = false;
for (ptr = csv; *ptr; ptr++) {
if (*ptr == ',') {
char* pp = ptr - 1;
......@@ -186,9 +183,8 @@ int ares_set_servers_csv(ares_channel channel,
pp--;
}
if ((pp != start_host) && ((pp + 1) < ptr)) {
/* Found it. */
found_port = true;
port = strtol(pp + 1, NULL, 10);
/* 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 */
......@@ -233,7 +229,6 @@ int ares_set_servers_csv(ares_channel channel,
}
/* Set up for next one */
found_port = false;
start_host = ptr + 1;
}
}
......
......@@ -132,6 +132,7 @@ int ares_parse_a_reply(const unsigned char *abuf, int alen,
aptr += len;
if (aptr + RRFIXEDSZ > abuf + alen)
{
free(rr_name);
status = ARES_EBADRESP;
break;
}
......@@ -149,6 +150,7 @@ int ares_parse_a_reply(const unsigned char *abuf, int alen,
{
if (aptr + sizeof(struct in_addr) > abuf + alen)
{
free(rr_name);
status = ARES_EBADRESP;
break;
}
......@@ -159,6 +161,7 @@ int ares_parse_a_reply(const unsigned char *abuf, int alen,
struct ares_addrttl * const at = &addrttls[naddrs];
if (aptr + sizeof(struct in_addr) > abuf + alen)
{
free(rr_name);
status = ARES_EBADRESP;
break;
}
......@@ -238,6 +241,8 @@ int ares_parse_a_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;
}
......
......@@ -132,6 +132,7 @@ int ares_parse_aaaa_reply(const unsigned char *abuf, int alen,
aptr += len;
if (aptr + RRFIXEDSZ > abuf + alen)
{
free(rr_name);
status = ARES_EBADRESP;
break;
}
......@@ -149,6 +150,7 @@ int ares_parse_aaaa_reply(const unsigned char *abuf, int alen,
{
if (aptr + sizeof(struct ares_in6_addr) > abuf + alen)
{
free(rr_name);
status = ARES_EBADRESP;
break;
}
......@@ -159,6 +161,7 @@ int ares_parse_aaaa_reply(const unsigned char *abuf, int alen,
struct ares_addr6ttl * const at = &addrttls[naddrs];
if (aptr + sizeof(struct ares_in6_addr) > abuf + alen)
{
free(rr_name);
status = ARES_EBADRESP;
break;
}
......
......@@ -99,6 +99,7 @@ int ares_parse_ptr_reply(const unsigned char *abuf, int alen, const void *addr,
aptr += len;
if (aptr + RRFIXEDSZ > abuf + alen)
{
free(rr_name);
status = ARES_EBADRESP;
break;
}
......@@ -114,13 +115,17 @@ int ares_parse_ptr_reply(const unsigned char *abuf, int alen, const void *addr,
status = ares__expand_name_for_response(aptr, abuf, alen, &rr_data,
&len);
if (status != ARES_SUCCESS)
break;
{
free(rr_name);
break;
}
if (hostname)
free(hostname);
hostname = rr_data;
aliases[aliascnt] = malloc((strlen(rr_data)+1) * sizeof(char *));
aliases[aliascnt] = malloc((strlen(rr_data)+1) * sizeof(char));
if (!aliases[aliascnt])
{
free(rr_name);
status = ARES_ENOMEM;
break;
}
......@@ -131,6 +136,7 @@ int ares_parse_ptr_reply(const unsigned char *abuf, int alen, const void *addr,
alias_alloc *= 2;
ptr = realloc(aliases, alias_alloc * sizeof(char *));
if(!ptr) {
free(rr_name);
status = ARES_ENOMEM;
break;
}
......@@ -144,7 +150,10 @@ int ares_parse_ptr_reply(const unsigned char *abuf, int alen, const void *addr,
status = ares__expand_name_for_response(aptr, abuf, alen, &rr_data,
&len);
if (status != ARES_SUCCESS)
break;
{
free(rr_name);
break;
}
free(ptrname);
ptrname = rr_data;
}
......
#ifndef HEADER_CARES_PLATFORM_H
#define HEADER_CARES_PLATFORM_H
/* Copyright 1998 by the Massachusetts Institute of Technology.
* Copyright (C) 2004 - 2011 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.
*/
#include "ares_setup.h"
#if defined(WIN32) && !defined(MSDOS)
typedef enum {
WIN_UNKNOWN,
WIN_3X,
WIN_9X,
WIN_NT,
WIN_CE
} win_platform;
win_platform ares__getplatform(void);
#endif
#if defined(_WIN32_WCE)
struct servent *getservbyport(int port, const char *proto);
#endif
#endif /* HEADER_CARES_PLATFORM_H */
......@@ -52,7 +52,6 @@
#if defined(WIN32) && !defined(WATT32)
#define IS_NT() ((int)GetVersion() > 0)
#define WIN_NS_9X "System\\CurrentControlSet\\Services\\VxD\\MSTCP"
#define WIN_NS_NT_KEY "System\\CurrentControlSet\\Services\\Tcpip\\Parameters"
#define NAMESERVER "NameServer"
......@@ -89,6 +88,11 @@
#include "ares_ipv6.h"
#include "ares_llist.h"
#ifndef HAVE_GETENV
# include "ares_getenv.h"
# define getenv(ptr) ares_getenv(ptr)
#endif
#ifndef HAVE_STRDUP
# include "ares_strdup.h"
# define strdup(ptr) ares_strdup(ptr)
......@@ -199,7 +203,7 @@ struct query {
void *arg;
/* Query status */
int try; /* Number of times we tried this query already. */
int try_count; /* Number of times we tried this query already. */
int server; /* Server this query has last been sent to. */
struct query_server_info *server_info; /* per-server state */
int using_tcp;
......
......@@ -63,10 +63,10 @@
#include <stdlib.h>
#include <fcntl.h>
#include <time.h>
#include <errno.h>
#include "ares.h"
#include "ares_dns.h"
#include "ares_nowarn.h"
#include "ares_private.h"
......@@ -300,29 +300,28 @@ static void advance_tcp_send_queue(ares_channel channel, int whichserver,
{
struct send_request *sendreq;
struct server_state *server = &channel->servers[whichserver];
while (num_bytes > 0)
{
sendreq = server->qhead;
if ((size_t)num_bytes >= sendreq->len)
{
num_bytes -= sendreq->len;
server->qhead = sendreq->next;
if (server->qhead == NULL)
{
SOCK_STATE_CALLBACK(channel, server->tcp_socket, 1, 0);
server->qtail = NULL;
}
if (sendreq->data_storage != NULL)
free(sendreq->data_storage);
free(sendreq);
}
else
{
sendreq->data += num_bytes;
sendreq->len -= num_bytes;
num_bytes = 0;
}
while (num_bytes > 0) {
sendreq = server->qhead;
if ((size_t)num_bytes >= sendreq->len) {
num_bytes -= sendreq->len;
server->qhead = sendreq->next;
if (sendreq->data_storage)
free(sendreq->data_storage);
free(sendreq);
if (server->qhead == NULL) {
SOCK_STATE_CALLBACK(channel, server->tcp_socket, 1, 0);
server->qtail = NULL;
/* qhead is NULL so we cannot continue this loop */
break;
}
}
else {
sendreq->data += num_bytes;
sendreq->len -= num_bytes;
num_bytes = 0;
}
}
}
/* If any TCP socket selects true for reading, read some data,
......@@ -686,7 +685,7 @@ static void next_server(ares_channel channel, struct query *query,
* servers to try. In total, we need to do channel->nservers * channel->tries
* attempts. Use query->try to remember how many times we already attempted
* this query. Use modular arithmetic to find the next server to try. */
while (++(query->try) < (channel->nservers * channel->tries))
while (++(query->try_count) < (channel->nservers * channel->tries))
{
struct server_state *server;
......@@ -791,7 +790,7 @@ void ares__send_query(ares_channel channel, struct query *query,
return;
}
}
timeplus = channel->timeout << (query->try / channel->nservers);
timeplus = channel->timeout << (query->try_count / channel->nservers);
timeplus = (timeplus * (9 + (rand () & 7))) / 16;
query->timeout = *now;
ares__timeadd(&query->timeout,
......
......@@ -20,7 +20,6 @@
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <errno.h>
#ifdef HAVE_STRINGS_H
# include <strings.h>
......@@ -292,7 +291,7 @@ static int single_domain(ares_channel channel, const char *name, char **s)
}
else
{
error = errno;
error = ERRNO;
switch(error)
{
case ENOENT:
......
......@@ -96,7 +96,7 @@ void ares_send(ares_channel channel, const unsigned char *qbuf, int qlen,
query->arg = arg;
/* Initialize query status. */
query->try = 0;
query->try_count = 0;
/* Choose the server to send the query to. If rotation is enabled, keep track
* of the next server we want to use. */
......
......@@ -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"
#if (ARES_VERSION >= 0x010700)
# define CARES_HAVE_ARES_LIBRARY_INIT 1
......
#ifndef __ARES_CONFIG_WIN32_H
#define __ARES_CONFIG_WIN32_H
#ifndef HEADER_CARES_CONFIG_WIN32_H
#define HEADER_CARES_CONFIG_WIN32_H
/* Copyright (C) 2004 - 2008 by Daniel Stenberg et al
/* Copyright (C) 2004 - 2011 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
......@@ -16,22 +15,28 @@
*/
/* ================================================================ */
/* ares/config-win32.h - Hand crafted config file for Windows */
/* c-ares/config-win32.h - Hand crafted config file for Windows */
/* ================================================================ */
/* ---------------------------------------------------------------- */
/* HEADER FILES */
/* ---------------------------------------------------------------- */
/* Define if you have the <getopt.h> header file. */
/* Define if you have the <assert.h> header file. */
#define HAVE_ASSERT_H 1
/* Define if you have the <errno.h> header file. */
#define HAVE_ERRNO_H 1
/* Define if you have the <getopt.h> header file. */
#if defined(__MINGW32__) || defined(__POCC__)
#define HAVE_GETOPT_H 1
#endif
/* Define if you have the <limits.h> header file. */
/* Define if you have the <limits.h> header file. */
#define HAVE_LIMITS_H 1
/* Define if you have the <process.h> header file. */
/* Define if you have the <process.h> header file. */
#ifndef __SALFORDC__
#define HAVE_PROCESS_H 1
#endif
......@@ -42,27 +47,27 @@
/* Define if you have the <sys/time.h> header file */
/* #define HAVE_SYS_TIME_H 1 */
/* Define if you have the <time.h> header file. */
/* Define if you have the <time.h> header file. */
#define HAVE_TIME_H 1
/* Define if you have the <unistd.h> header file. */
/* Define if you have the <unistd.h> header file. */
#if defined(__MINGW32__) || defined(__WATCOMC__) || defined(__LCC__) || \
defined(__POCC__)
#define HAVE_UNISTD_H 1
#endif
/* Define if you have the <windows.h> header file. */
/* Define if you have the <windows.h> header file. */
#define HAVE_WINDOWS_H 1
/* Define if you have the <winsock.h> header file. */
/* Define if you have the <winsock.h> header file. */
#define HAVE_WINSOCK_H 1
/* Define if you have the <winsock2.h> header file. */
/* Define if you have the <winsock2.h> header file. */
#ifndef __SALFORDC__
#define HAVE_WINSOCK2_H 1
#endif
/* Define if you have the <ws2tcpip.h> header file. */
/* Define if you have the <ws2tcpip.h> header file. */
#ifndef __SALFORDC__
#define HAVE_WS2TCPIP_H 1
#endif
......@@ -74,20 +79,23 @@
/* Define if sig_atomic_t is an available typedef. */
#define HAVE_SIG_ATOMIC_T 1
/* Define if you have the ANSI C header files. */
/* Define if you have the ANSI C header files. */
#define STDC_HEADERS 1
/* Define if you can safely include both <sys/time.h> and <time.h>. */
/* Define if you can safely include both <sys/time.h> and <time.h>. */
/* #define TIME_WITH_SYS_TIME 1 */
/* ---------------------------------------------------------------- */
/* FUNCTIONS */
/* ---------------------------------------------------------------- */
/* Define if you have the closesocket function. */
/* Define if you have the closesocket function. */
#define HAVE_CLOSESOCKET 1
/* Define if you have the gethostname function. */
/* Define if you have the getenv function. */
#define HAVE_GETENV 1
/* Define if you have the gethostname function. */
#define HAVE_GETHOSTNAME 1
/* Define if you have the ioctlsocket function. */
......@@ -174,7 +182,7 @@
/* Define to the function return type for send. */
#define SEND_TYPE_RETV int
/* Specifics for the Watt-32 tcp/ip stack */
/* Specifics for the Watt-32 tcp/ip stack. */
#ifdef WATT32
#define SOCKET int
#define NS_INADDRSZ 4
......@@ -197,13 +205,13 @@
/* TYPEDEF REPLACEMENTS */
/* ---------------------------------------------------------------- */
/* Define this if in_addr_t is not an available 'typedefed' type */
/* Define if in_addr_t is not an available 'typedefed' type. */
#define in_addr_t unsigned long
/* Define as the return type of signal handlers (int or void). */
/* Define to the return type of signal handlers (int or void). */
#define RETSIGTYPE void
/* Define ssize_t if it is not an available 'typedefed' type */
/* Define if ssize_t is not an available 'typedefed' type. */
#ifndef _SSIZE_T_DEFINED
# if (defined(__WATCOMC__) && (__WATCOMC__ >= 1240)) || \
defined(__POCC__) || \
......@@ -221,13 +229,13 @@
/* TYPE SIZES */
/* ---------------------------------------------------------------- */
/* The size of `int', as computed by sizeof. */
/* Define to the size of `int', as computed by sizeof. */
#define SIZEOF_INT 4
/* The size of `short', as computed by sizeof. */
/* Define to the size of `short', as computed by sizeof. */
#define SIZEOF_SHORT 2
/* The size of `size_t', as computed by sizeof. */
/* Define to the size of `size_t', as computed by sizeof. */
#if defined(_WIN64)
# define SIZEOF_SIZE_T 8
#else
......@@ -238,34 +246,35 @@
/* STRUCT RELATED */
/* ---------------------------------------------------------------- */
/* Define this if you have struct addrinfo */
/* Define if you have struct addrinfo. */
#define HAVE_STRUCT_ADDRINFO 1
/* Define this if you have struct sockaddr_storage */
#ifndef __SALFORDC__
/* Define if you have struct sockaddr_storage. */
#if !defined(__SALFORDC__) && !defined(__BORLANDC__)
#define HAVE_STRUCT_SOCKADDR_STORAGE 1
#endif
/* Define this if you have struct timeval */
/* Define if you have struct timeval. */
#define HAVE_STRUCT_TIMEVAL 1
/* ---------------------------------------------------------------- */
/* COMPILER SPECIFIC */
/* ---------------------------------------------------------------- */
/* Define to avoid VS2005 complaining about portable C functions */
/* Define to avoid VS2005 complaining about portable C functions. */
#if defined(_MSC_VER) && (_MSC_VER >= 1400)
#define _CRT_SECURE_NO_DEPRECATE 1
#define _CRT_NONSTDC_NO_DEPRECATE 1
# define _CRT_SECURE_NO_DEPRECATE 1
# define _CRT_NONSTDC_NO_DEPRECATE 1
#endif
/* Officially, Microsoft's Windows SDK versions 6.X do not support Windows
2000 as a supported build target. VS2008 default installations provide an
embedded Windows SDK v6.0A along with the claim that Windows 2000 is a
valid build target for VS2008. Popular belief is that binaries built using
Windows SDK versions 6.X and Windows 2000 as a build target are functional */
2000 as a supported build target. VS2008 default installations provide
an embedded Windows SDK v6.0A along with the claim that Windows 2000 is
a valid build target for VS2008. Popular belief is that binaries built
with VS2008 using Windows SDK versions 6.X and Windows 2000 as a build
target are functional. */
#if defined(_MSC_VER) && (_MSC_VER >= 1500)
# define VS2008_MINIMUM_TARGET 0x0500
# define VS2008_MIN_TARGET 0x0500
#endif
/* When no build target is specified VS2008 default build target is Windows
......@@ -273,18 +282,18 @@
for VS2008 we will target the minimum Officially supported build target,
which happens to be Windows XP. */
#if defined(_MSC_VER) && (_MSC_VER >= 1500)
# define VS2008_DEFAULT_TARGET 0x0501
# define VS2008_DEF_TARGET 0x0501
#endif
/* VS2008 default target settings and minimum build target check */
/* VS2008 default target settings and minimum build target check. */
#if defined(_MSC_VER) && (_MSC_VER >= 1500)
# ifndef _WIN32_WINNT
# define _WIN32_WINNT VS2008_DEFAULT_TARGET
# define _WIN32_WINNT VS2008_DEF_TARGET
# endif
# ifndef WINVER
# define WINVER VS2008_DEFAULT_TARGET
# define WINVER VS2008_DEF_TARGET
# endif
# if (_WIN32_WINNT < VS2008_MINIMUM_TARGET) || (WINVER < VS2008_MINIMUM_TARGET)
# if (_WIN32_WINNT < VS2008_MIN_TARGET) || (WINVER < VS2008_MIN_TARGET)
# error VS2008 does not support Windows build targets prior to Windows 2000
# endif
#endif
......@@ -331,30 +340,30 @@
/* IPV6 COMPATIBILITY */
/* ---------------------------------------------------------------- */
/* Define this if you have address family AF_INET6 */
/* Define if you have address family AF_INET6. */
#ifdef HAVE_WINSOCK2_H
#define HAVE_AF_INET6 1
#endif
/* Define this if you have protocol family PF_INET6 */
/* Define if you have protocol family PF_INET6. */
#ifdef HAVE_WINSOCK2_H
#define HAVE_PF_INET6 1
#endif
/* Define this if you have struct in6_addr */
/* Define if you have struct in6_addr. */
#ifdef HAVE_WS2TCPIP_H
#define HAVE_STRUCT_IN6_ADDR 1
#endif
/* Define this if you have struct sockaddr_in6 */
/* Define if you have struct sockaddr_in6. */
#ifdef HAVE_WS2TCPIP_H
#define HAVE_STRUCT_SOCKADDR_IN6 1
#endif
/* Define this if you have sockaddr_in6 with scopeid */
/* Define if you have sockaddr_in6 with scopeid. */
#ifdef HAVE_WS2TCPIP_H
#define HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID 1
#endif
#endif /* __ARES_CONFIG_WIN32_H */
#endif /* HEADER_CARES_CONFIG_WIN32_H */
#! /bin/sh
# Attempt to guess a canonical system name.
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
# Free Software Foundation, Inc.
# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
# 2011 Free Software Foundation, Inc.
timestamp='2009-12-30'
timestamp='2011-05-11'
# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
......@@ -57,7 +57,7 @@ GNU config.guess ($timestamp)
Originally written by Per Bothner.
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free
2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free
Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
......@@ -181,7 +181,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
fi
;;
*)
os=netbsd
os=netbsd
;;
esac
# The OS release
......@@ -224,7 +224,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
;;
*5.*)
UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`
UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`
;;
esac
# According to Compaq, /usr/sbin/psrinfo has been available on
......@@ -270,7 +270,10 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
# A Xn.n version is an unreleased experimental baselevel.
# 1.2 uses "1.2" for uname -r.
echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
exit ;;
# Reset EXIT trap before exiting to avoid spurious non-zero exit code.
exitcode=$?
trap '' 0
exit $exitcode ;;
Alpha\ *:Windows_NT*:*)
# How do we know it's Interix rather than the generic POSIX subsystem?
# Should we change UNAME_MACHINE based on the output of uname instead
......@@ -296,7 +299,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
echo s390-ibm-zvmoe
exit ;;
*:OS400:*:*)
echo powerpc-ibm-os400
echo powerpc-ibm-os400
exit ;;
arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
echo arm-acorn-riscix${UNAME_RELEASE}
......@@ -395,23 +398,23 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
# MiNT. But MiNT is downward compatible to TOS, so this should
# be no problem.
atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*)
echo m68k-atari-mint${UNAME_RELEASE}
echo m68k-atari-mint${UNAME_RELEASE}
exit ;;
atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
echo m68k-atari-mint${UNAME_RELEASE}
exit ;;
exit ;;
*falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
echo m68k-atari-mint${UNAME_RELEASE}
echo m68k-atari-mint${UNAME_RELEASE}
exit ;;
milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
echo m68k-milan-mint${UNAME_RELEASE}
exit ;;
echo m68k-milan-mint${UNAME_RELEASE}
exit ;;
hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
echo m68k-hades-mint${UNAME_RELEASE}
exit ;;
echo m68k-hades-mint${UNAME_RELEASE}
exit ;;
*:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
echo m68k-unknown-mint${UNAME_RELEASE}
exit ;;
echo m68k-unknown-mint${UNAME_RELEASE}
exit ;;
m68k:machten:*:*)
echo m68k-apple-machten${UNAME_RELEASE}
exit ;;
......@@ -481,8 +484,8 @@ EOF
echo m88k-motorola-sysv3
exit ;;
AViiON:dgux:*:*)
# DG/UX returns AViiON for all architectures
UNAME_PROCESSOR=`/usr/bin/uname -p`
# DG/UX returns AViiON for all architectures
UNAME_PROCESSOR=`/usr/bin/uname -p`
if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ]
then
if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \
......@@ -495,7 +498,7 @@ EOF
else
echo i586-dg-dgux${UNAME_RELEASE}
fi
exit ;;
exit ;;
M88*:DolphinOS:*:*) # DolphinOS (SVR3)
echo m88k-dolphin-sysv3
exit ;;
......@@ -552,7 +555,7 @@ EOF
echo rs6000-ibm-aix3.2
fi
exit ;;
*:AIX:*:[456])
*:AIX:*:[4567])
IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then
IBM_ARCH=rs6000
......@@ -595,52 +598,52 @@ EOF
9000/[678][0-9][0-9])
if [ -x /usr/bin/getconf ]; then
sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
case "${sc_cpu_version}" in
523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0
528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1
532) # CPU_PA_RISC2_0
case "${sc_kernel_bits}" in
32) HP_ARCH="hppa2.0n" ;;
64) HP_ARCH="hppa2.0w" ;;
sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
case "${sc_cpu_version}" in
523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0
528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1
532) # CPU_PA_RISC2_0
case "${sc_kernel_bits}" in
32) HP_ARCH="hppa2.0n" ;;
64) HP_ARCH="hppa2.0w" ;;
'') HP_ARCH="hppa2.0" ;; # HP-UX 10.20
esac ;;
esac
esac ;;
esac
fi
if [ "${HP_ARCH}" = "" ]; then
eval $set_cc_for_build
sed 's/^ //' << EOF >$dummy.c
sed 's/^ //' << EOF >$dummy.c
#define _HPUX_SOURCE
#include <stdlib.h>
#include <unistd.h>
#define _HPUX_SOURCE
#include <stdlib.h>
#include <unistd.h>
int main ()
{
#if defined(_SC_KERNEL_BITS)
long bits = sysconf(_SC_KERNEL_BITS);
#endif
long cpu = sysconf (_SC_CPU_VERSION);
int main ()
{
#if defined(_SC_KERNEL_BITS)
long bits = sysconf(_SC_KERNEL_BITS);
#endif
long cpu = sysconf (_SC_CPU_VERSION);
switch (cpu)
{
case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
case CPU_PA_RISC2_0:
#if defined(_SC_KERNEL_BITS)
switch (bits)
{
case 64: puts ("hppa2.0w"); break;
case 32: puts ("hppa2.0n"); break;
default: puts ("hppa2.0"); break;
} break;
#else /* !defined(_SC_KERNEL_BITS) */
puts ("hppa2.0"); break;
#endif
default: puts ("hppa1.0"); break;
}
exit (0);
}
switch (cpu)
{
case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
case CPU_PA_RISC2_0:
#if defined(_SC_KERNEL_BITS)
switch (bits)
{
case 64: puts ("hppa2.0w"); break;
case 32: puts ("hppa2.0n"); break;
default: puts ("hppa2.0"); break;
} break;
#else /* !defined(_SC_KERNEL_BITS) */
puts ("hppa2.0"); break;
#endif
default: puts ("hppa1.0"); break;
}
exit (0);
}
EOF
(CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy`
test -z "$HP_ARCH" && HP_ARCH=hppa
......@@ -731,22 +734,22 @@ EOF
exit ;;
C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
echo c1-convex-bsd
exit ;;
exit ;;
C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
if getsysinfo -f scalar_acc
then echo c32-convex-bsd
else echo c2-convex-bsd
fi
exit ;;
exit ;;
C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
echo c34-convex-bsd
exit ;;
exit ;;
C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
echo c38-convex-bsd
exit ;;
exit ;;
C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
echo c4-convex-bsd
exit ;;
exit ;;
CRAY*Y-MP:*:*:*)
echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
exit ;;
......@@ -770,14 +773,14 @@ EOF
exit ;;
F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
exit ;;
FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
exit ;;
5000:UNIX_System_V:4.*:*)
FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'`
echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'`
echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
exit ;;
i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
......@@ -805,14 +808,14 @@ EOF
echo ${UNAME_MACHINE}-pc-mingw32
exit ;;
i*:windows32*:*)
# uname -m includes "-pc" on this system.
echo ${UNAME_MACHINE}-mingw32
# uname -m includes "-pc" on this system.
echo ${UNAME_MACHINE}-mingw32
exit ;;
i*:PW*:*)
echo ${UNAME_MACHINE}-pc-pw32
exit ;;
*:Interix*:*)
case ${UNAME_MACHINE} in
case ${UNAME_MACHINE} in
x86)
echo i586-pc-interix${UNAME_RELEASE}
exit ;;
......@@ -867,7 +870,7 @@ EOF
EV6) UNAME_MACHINE=alphaev6 ;;
EV67) UNAME_MACHINE=alphaev67 ;;
EV68*) UNAME_MACHINE=alphaev68 ;;
esac
esac
objdump --private-headers /bin/sh | grep -q ld.so.1
if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi
echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC}
......@@ -879,7 +882,13 @@ EOF
then
echo ${UNAME_MACHINE}-unknown-linux-gnu
else
echo ${UNAME_MACHINE}-unknown-linux-gnueabi
if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \
| grep -q __ARM_PCS_VFP
then
echo ${UNAME_MACHINE}-unknown-linux-gnueabi
else
echo ${UNAME_MACHINE}-unknown-linux-gnueabihf
fi
fi
exit ;;
avr32*:Linux:*:*)
......@@ -892,7 +901,7 @@ EOF
echo crisv32-axis-linux-gnu
exit ;;
frv:Linux:*:*)
echo frv-unknown-linux-gnu
echo frv-unknown-linux-gnu
exit ;;
i*86:Linux:*:*)
LIBC=gnu
......@@ -960,7 +969,7 @@ EOF
echo ${UNAME_MACHINE}-ibm-linux
exit ;;
sh64*:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
echo ${UNAME_MACHINE}-unknown-linux-gnu
exit ;;
sh*:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
......@@ -968,6 +977,9 @@ EOF
sparc:Linux:*:* | sparc64:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
exit ;;
tile*:Linux:*:*)
echo ${UNAME_MACHINE}-tilera-linux-gnu
exit ;;
vax:Linux:*:*)
echo ${UNAME_MACHINE}-dec-linux-gnu
exit ;;
......@@ -975,7 +987,7 @@ EOF
echo x86_64-unknown-linux-gnu
exit ;;
xtensa*:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
echo ${UNAME_MACHINE}-unknown-linux-gnu
exit ;;
i*86:DYNIX/ptx:4*:*)
# ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
......@@ -984,11 +996,11 @@ EOF
echo i386-sequent-sysv4
exit ;;
i*86:UNIX_SV:4.2MP:2.*)
# Unixware is an offshoot of SVR4, but it has its own version
# number series starting with 2...
# I am not positive that other SVR4 systems won't match this,
# Unixware is an offshoot of SVR4, but it has its own version
# number series starting with 2...
# I am not positive that other SVR4 systems won't match this,
# I just have to hope. -- rms.
# Use sysv4.2uw... so that sysv4* matches it.
# Use sysv4.2uw... so that sysv4* matches it.
echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
exit ;;
i*86:OS/2:*:*)
......@@ -1020,7 +1032,7 @@ EOF
fi
exit ;;
i*86:*:5:[678]*)
# UnixWare 7.x, OpenUNIX and OpenServer 6.
# UnixWare 7.x, OpenUNIX and OpenServer 6.
case `/bin/uname -X | grep "^Machine"` in
*486*) UNAME_MACHINE=i486 ;;
*Pentium) UNAME_MACHINE=i586 ;;
......@@ -1048,13 +1060,13 @@ EOF
exit ;;
pc:*:*:*)
# Left here for compatibility:
# uname -m prints for DJGPP always 'pc', but it prints nothing about
# the processor, so we play safe by assuming i586.
# uname -m prints for DJGPP always 'pc', but it prints nothing about
# the processor, so we play safe by assuming i586.
# Note: whatever this is, it MUST be the same as what config.sub
# prints for the "djgpp" host, or else GDB configury will decide that
# this is a cross-build.
echo i586-pc-msdosdjgpp
exit ;;
exit ;;
Intel:Mach:3*:*)
echo i386-pc-mach3
exit ;;
......@@ -1089,8 +1101,8 @@ EOF
/bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
&& { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;;
3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
&& { echo i486-ncr-sysv4; exit; } ;;
/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
&& { echo i486-ncr-sysv4; exit; } ;;
NCR*:*:4.2:* | MPRAS*:*:4.2:*)
OS_REL='.3'
test -r /etc/.relid \
......@@ -1133,10 +1145,10 @@ EOF
echo ns32k-sni-sysv
fi
exit ;;
PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
# says <Richard.M.Bartel@ccMail.Census.GOV>
echo i586-unisys-sysv4
exit ;;
PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
# says <Richard.M.Bartel@ccMail.Census.GOV>
echo i586-unisys-sysv4
exit ;;
*:UNIX_System_V:4*:FTX*)
# From Gerald Hewes <hewes@openmarket.com>.
# How about differentiating between stratus architectures? -djm
......@@ -1162,11 +1174,11 @@ EOF
exit ;;
R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
if [ -d /usr/nec ]; then
echo mips-nec-sysv${UNAME_RELEASE}
echo mips-nec-sysv${UNAME_RELEASE}
else
echo mips-unknown-sysv${UNAME_RELEASE}
echo mips-unknown-sysv${UNAME_RELEASE}
fi
exit ;;
exit ;;
BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only.
echo powerpc-be-beos
exit ;;
......@@ -1231,6 +1243,9 @@ EOF
*:QNX:*:4*)
echo i386-pc-qnx
exit ;;
NEO-?:NONSTOP_KERNEL:*:*)
echo neo-tandem-nsk${UNAME_RELEASE}
exit ;;
NSE-?:NONSTOP_KERNEL:*:*)
echo nse-tandem-nsk${UNAME_RELEASE}
exit ;;
......@@ -1276,13 +1291,13 @@ EOF
echo pdp10-unknown-its
exit ;;
SEI:*:*:SEIUX)
echo mips-sei-seiux${UNAME_RELEASE}
echo mips-sei-seiux${UNAME_RELEASE}
exit ;;
*:DragonFly:*:*)
echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
exit ;;
*:*VMS:*:*)
UNAME_MACHINE=`(uname -p) 2>/dev/null`
UNAME_MACHINE=`(uname -p) 2>/dev/null`
case "${UNAME_MACHINE}" in
A*) echo alpha-dec-vms ; exit ;;
I*) echo ia64-dec-vms ; exit ;;
......@@ -1322,11 +1337,11 @@ main ()
#include <sys/param.h>
printf ("m68k-sony-newsos%s\n",
#ifdef NEWSOS4
"4"
"4"
#else
""
""
#endif
); exit (0);
); exit (0);
#endif
#endif
......
#! /bin/sh
# Configuration validation subroutine script.
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
# Free Software Foundation, Inc.
# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
# 2011 Free Software Foundation, Inc.
timestamp='2010-01-22'
timestamp='2011-03-23'
# This file is (in principle) common to ALL GNU software.
# The presence of a machine in this file suggests that SOME GNU software
......@@ -76,7 +76,7 @@ version="\
GNU config.sub ($timestamp)
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free
2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free
Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
......@@ -124,8 +124,9 @@ esac
# Here we must recognize all the valid KERNEL-OS combinations.
maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
case $maybe_os in
nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \
uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \
nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \
linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \
knetbsd*-gnu* | netbsd*-gnu* | \
kopensolaris*-gnu* | \
storm-chaos* | os2-emx* | rtmk-nova*)
os=-$maybe_os
......@@ -157,8 +158,8 @@ case $os in
os=
basic_machine=$1
;;
-bluegene*)
os=-cnk
-bluegene*)
os=-cnk
;;
-sim | -cisco | -oki | -wec | -winbond)
os=
......@@ -174,10 +175,10 @@ case $os in
os=-chorusos
basic_machine=$1
;;
-chorusrdb)
os=-chorusrdb
-chorusrdb)
os=-chorusrdb
basic_machine=$1
;;
;;
-hiux*)
os=-hiuxwe2
;;
......@@ -282,11 +283,13 @@ case $basic_machine in
| moxie \
| mt \
| msp430 \
| nds32 | nds32le | nds32be \
| nios | nios2 \
| ns16k | ns32k \
| open8 \
| or32 \
| pdp10 | pdp11 | pj | pjl \
| powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \
| powerpc | powerpc64 | powerpc64le | powerpcle \
| pyramid \
| rx \
| score \
......@@ -294,15 +297,24 @@ case $basic_machine in
| sh64 | sh64le \
| sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \
| sparcv8 | sparcv9 | sparcv9b | sparcv9v \
| spu | strongarm \
| tahoe | thumb | tic4x | tic80 | tron \
| spu \
| tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \
| ubicom32 \
| v850 | v850e \
| we32k \
| x86 | xc16x | xscale | xscalee[bl] | xstormy16 | xtensa \
| x86 | xc16x | xstormy16 | xtensa \
| z8k | z80)
basic_machine=$basic_machine-unknown
;;
c54x)
basic_machine=tic54x-unknown
;;
c55x)
basic_machine=tic55x-unknown
;;
c6x)
basic_machine=tic6x-unknown
;;
m6811 | m68hc11 | m6812 | m68hc12 | picochip)
# Motorola 68HC11/12.
basic_machine=$basic_machine-unknown
......@@ -314,6 +326,18 @@ case $basic_machine in
basic_machine=mt-unknown
;;
strongarm | thumb | xscale)
basic_machine=arm-unknown
;;
xscaleeb)
basic_machine=armeb-unknown
;;
xscaleel)
basic_machine=armel-unknown
;;
# We use `pc' rather than `unknown'
# because (1) that's what they normally are, and
# (2) the word "unknown" tends to confuse beginning users.
......@@ -334,7 +358,7 @@ case $basic_machine in
| arm-* | armbe-* | armle-* | armeb-* | armv*-* \
| avr-* | avr32-* \
| bfin-* | bs2000-* \
| c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \
| c[123]* | c30-* | [cjt]90-* | c4x-* \
| clipper-* | craynv-* | cydra-* \
| d10v-* | d30v-* | dlx-* \
| elxsi-* \
......@@ -368,26 +392,28 @@ case $basic_machine in
| mmix-* \
| mt-* \
| msp430-* \
| nds32-* | nds32le-* | nds32be-* \
| nios-* | nios2-* \
| none-* | np1-* | ns16k-* | ns32k-* \
| open8-* \
| orion-* \
| pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
| powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \
| powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \
| pyramid-* \
| romp-* | rs6000-* | rx-* \
| sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \
| shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
| sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \
| sparclite-* \
| sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | strongarm-* | sv1-* | sx?-* \
| tahoe-* | thumb-* \
| sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx?-* \
| tahoe-* \
| tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \
| tile-* | tilegx-* \
| tron-* \
| ubicom32-* \
| v850-* | v850e-* | vax-* \
| we32k-* \
| x86-* | x86_64-* | xc16x-* | xps100-* | xscale-* | xscalee[bl]-* \
| x86-* | x86_64-* | xc16x-* | xps100-* \
| xstormy16-* | xtensa*-* \
| ymp-* \
| z8k-* | z80-*)
......@@ -412,7 +438,7 @@ case $basic_machine in
basic_machine=a29k-amd
os=-udi
;;
abacus)
abacus)
basic_machine=abacus-unknown
;;
adobe68k)
......@@ -482,11 +508,20 @@ case $basic_machine in
basic_machine=powerpc-ibm
os=-cnk
;;
c54x-*)
basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
c55x-*)
basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
c6x-*)
basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
c90)
basic_machine=c90-cray
os=-unicos
;;
cegcc)
cegcc)
basic_machine=arm-unknown
os=-cegcc
;;
......@@ -518,7 +553,7 @@ case $basic_machine in
basic_machine=craynv-cray
os=-unicosmp
;;
cr16)
cr16 | cr16-*)
basic_machine=cr16-unknown
os=-elf
;;
......@@ -734,7 +769,7 @@ case $basic_machine in
basic_machine=ns32k-utek
os=-sysv
;;
microblaze)
microblaze)
basic_machine=microblaze-xilinx
;;
mingw32)
......@@ -841,6 +876,12 @@ case $basic_machine in
np1)
basic_machine=np1-gould
;;
neo-tandem)
basic_machine=neo-tandem
;;
nse-tandem)
basic_machine=nse-tandem
;;
nsr-tandem)
basic_machine=nsr-tandem
;;
......@@ -923,9 +964,10 @@ case $basic_machine in
;;
power) basic_machine=power-ibm
;;
ppc) basic_machine=powerpc-unknown
ppc | ppcbe) basic_machine=powerpc-unknown
;;
ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
ppc-* | ppcbe-*)
basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
ppcle | powerpclittle | ppc-le | powerpc-little)
basic_machine=powerpcle-unknown
......@@ -1019,6 +1061,9 @@ case $basic_machine in
basic_machine=i860-stratus
os=-sysv4
;;
strongarm-* | thumb-*)
basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
sun2)
basic_machine=m68000-sun
;;
......@@ -1075,20 +1120,8 @@ case $basic_machine in
basic_machine=t90-cray
os=-unicos
;;
tic54x | c54x*)
basic_machine=tic54x-unknown
os=-coff
;;
tic55x | c55x*)
basic_machine=tic55x-unknown
os=-coff
;;
tic6x | c6x*)
basic_machine=tic6x-unknown
os=-coff
;;
# This must be matched before tile*.
tilegx*)
# This must be matched before tile*.
tilegx*)
basic_machine=tilegx-unknown
os=-linux-gnu
;;
......@@ -1163,6 +1196,9 @@ case $basic_machine in
xps | xps100)
basic_machine=xps100-honeywell
;;
xscale-* | xscalee[bl]-*)
basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'`
;;
ymp)
basic_machine=ymp-cray
os=-unicos
......@@ -1260,11 +1296,11 @@ esac
if [ x"$os" != x"" ]
then
case $os in
# First match some system type aliases
# that might get confused with valid system types.
# First match some system type aliases
# that might get confused with valid system types.
# -solaris* is a basic system type, with this one exception.
-auroraux)
os=-auroraux
-auroraux)
os=-auroraux
;;
-solaris1 | -solaris1.*)
os=`echo $os | sed -e 's|solaris1|sunos4|'`
......@@ -1301,7 +1337,8 @@ case $os in
| -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
| -chorusos* | -chorusrdb* | -cegcc* \
| -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
| -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \
| -mingw32* | -linux-gnu* | -linux-android* \
| -linux-newlib* | -linux-uclibc* \
| -uxpv* | -beos* | -mpeix* | -udk* \
| -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
| -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
......@@ -1348,7 +1385,7 @@ case $os in
-opened*)
os=-openedition
;;
-os400*)
-os400*)
os=-os400
;;
-wince*)
......@@ -1397,7 +1434,7 @@ case $os in
-sinix*)
os=-sysv4
;;
-tpf*)
-tpf*)
os=-tpf
;;
-triton*)
......@@ -1442,8 +1479,8 @@ case $os in
-dicos*)
os=-dicos
;;
-nacl*)
;;
-nacl*)
;;
-none)
;;
*)
......@@ -1466,10 +1503,10 @@ else
# system, and we'll never get to this point.
case $basic_machine in
score-*)
score-*)
os=-elf
;;
spu-*)
spu-*)
os=-elf
;;
*-acorn)
......@@ -1481,8 +1518,17 @@ case $basic_machine in
arm*-semi)
os=-aout
;;
c4x-* | tic4x-*)
os=-coff
c4x-* | tic4x-*)
os=-coff
;;
tic54x-*)
os=-coff
;;
tic55x-*)
os=-coff
;;
tic6x-*)
os=-coff
;;
# This must come before the *-dec entry.
pdp10-*)
......@@ -1509,7 +1555,7 @@ case $basic_machine in
m68*-cisco)
os=-aout
;;
mep-*)
mep-*)
os=-elf
;;
mips*-cisco)
......@@ -1536,7 +1582,7 @@ case $basic_machine in
*-ibm)
os=-aix
;;
*-knuth)
*-knuth)
os=-mmixware
;;
*-wec)
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -37,20 +37,20 @@
#endif
#include <ctype.h>
#include <errno.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"
const struct ares_in6_addr ares_in6addr_any = { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } } };
#if !defined(HAVE_INET_NET_PTON) || !defined(HAVE_INET_NET_PTON_IPV6)
#ifndef HAVE_INET_NET_PTON
/*
* static int
......@@ -83,16 +83,17 @@ inet_net_pton_ipv4(const char *src, unsigned char *dst, size_t size)
ch = *src++;
if (ch == '0' && (src[0] == 'x' || src[0] == 'X')
&& ISASCII(src[1])
&& ISXDIGIT(src[1])) {
/* Hexadecimal: Eat nybble string. */
if (!size)
goto emsgsize;
dirty = 0;
src++; /* skip x or X. */
while ((ch = *src++) != '\0' && ISXDIGIT(ch)) {
while ((ch = *src++) != '\0' && ISASCII(ch) && ISXDIGIT(ch)) {
if (ISUPPER(ch))
ch = tolower(ch);
n = (int)(strchr(xdigits, ch) - xdigits);
n = aresx_sztosi(strchr(xdigits, ch) - xdigits);
if (dirty == 0)
tmp = n;
else
......@@ -109,18 +110,18 @@ inet_net_pton_ipv4(const char *src, unsigned char *dst, size_t size)
goto emsgsize;
*dst++ = (unsigned char) (tmp << 4);
}
} else if (ISDIGIT(ch)) {
} else if (ISASCII(ch) && ISDIGIT(ch)) {
/* Decimal: eat dotted digit string. */
for (;;) {
tmp = 0;
do {
n = (int)(strchr(digits, ch) - digits);
n = aresx_sztosi(strchr(digits, ch) - digits);
tmp *= 10;
tmp += n;
if (tmp > 255)
goto enoent;
} while ((ch = *src++) != '\0' &&
ISDIGIT(ch));
ISASCII(ch) && ISDIGIT(ch));
if (!size--)
goto emsgsize;
*dst++ = (unsigned char) tmp;
......@@ -129,27 +130,27 @@ inet_net_pton_ipv4(const char *src, unsigned char *dst, size_t size)
if (ch != '.')
goto enoent;
ch = *src++;
if (!ISDIGIT(ch))
if (!ISASCII(ch) || !ISDIGIT(ch))
goto enoent;
}
} else
goto enoent;
bits = -1;
if (ch == '/' &&
if (ch == '/' && ISASCII(src[0]) &&
ISDIGIT(src[0]) && dst > odst) {
/* CIDR width specifier. Nothing can follow it. */
ch = *src++; /* Skip over the /. */
bits = 0;
do {
n = (int)(strchr(digits, ch) - digits);
n = aresx_sztosi(strchr(digits, ch) - digits);
bits *= 10;
bits += n;
} while ((ch = *src++) != '\0' && ISDIGIT(ch));
if (bits > 32)
goto enoent;
} while ((ch = *src++) != '\0' && ISASCII(ch) && ISDIGIT(ch));
if (ch != '\0')
goto enoent;
if (bits > 32)
goto emsgsize;
}
/* Firey death and destruction unless we prefetched EOS. */
......@@ -173,7 +174,7 @@ inet_net_pton_ipv4(const char *src, unsigned char *dst, size_t size)
bits = 8;
/* If imputed mask is narrower than specified octets, widen. */
if (bits < ((dst - odst) * 8))
bits = (int)(dst - odst) * 8;
bits = aresx_sztosi(dst - odst) * 8;
/*
* If there are no additional bits specified for a class D
* address adjust bits to 4.
......@@ -216,7 +217,7 @@ getbits(const char *src, int *bitsp)
if (n++ != 0 && val == 0) /* no leading zeros */
return (0);
val *= 10;
val += (pch - digits);
val += aresx_sztosi(pch - digits);
if (val > 128) /* range */
return (0);
continue;
......@@ -248,7 +249,7 @@ getv4(const char *src, unsigned char *dst, int *bitsp)
if (n++ != 0 && val == 0) /* no leading zeros */
return (0);
val *= 10;
val += (pch - digits);
val += aresx_sztoui(pch - digits);
if (val > 255) /* range */
return (0);
continue;
......@@ -269,8 +270,8 @@ getv4(const char *src, unsigned char *dst, int *bitsp)
return (0);
if (dst - odst > 3) /* too many octets? */
return (0);
*dst++ = (unsigned char)val;
return (1);
*dst = (unsigned char)val;
return 1;
}
static int
......@@ -308,7 +309,7 @@ inet_net_pton_ipv6(const char *src, unsigned char *dst, size_t size)
pch = strchr((xdigits = xdigits_u), ch);
if (pch != NULL) {
val <<= 4;
val |= (pch - xdigits);
val |= aresx_sztoui(pch - xdigits);
if (++digits > 4)
goto enoent;
saw_xdigit = 1;
......@@ -425,7 +426,7 @@ ares_inet_net_pton(int af, const char *src, void *dst, size_t size)
}
}
#endif
#endif /* HAVE_INET_NET_PTON */
#ifndef HAVE_INET_PTON
int ares_inet_pton(int af, const char *src, void *dst)
......
#ifndef __ARES_INET_NET_PTON_H
#define __ARES_INET_NET_PTON_H
#ifndef HEADER_CARES_INET_NET_PTON_H
#define HEADER_CARES_INET_NET_PTON_H
/* Copyright (C) 2005 by Daniel Stenberg
/* Copyright (C) 2005-2010 by Daniel Stenberg et al
*
* Permission to use, copy, modify, and distribute this
* software and its documentation for any purpose and without
......@@ -22,10 +21,11 @@
#else
int ares_inet_pton(int af, const char *src, void *dst);
#endif
#if defined(HAVE_INET_NET_PTON) && defined(HAVE_INET_NET_PTON_IPV6)
#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 /* __ARES_INET_NET_PTON_H */
#endif /* HEADER_CARES_INET_NET_PTON_H */
/* Copyright (c) 1996 by Internet Software Consortium.
/*
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 1996-1999 by Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include "ares_setup.h"
......@@ -36,7 +36,6 @@
#endif
#include <ctype.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
......@@ -48,12 +47,6 @@
#ifndef HAVE_INET_NTOP
#ifdef SPRINTF_CHAR
# define SPRINTF(x) strlen(sprintf/**/x)
#else
# define SPRINTF(x) ((size_t)sprintf x)
#endif
/*
* WARNING: Don't even consider trying to compile this on a system where
* sizeof(int) < 4. sizeof(int) > 4 is fine; all the world's not a VAX.
......@@ -68,32 +61,31 @@ static const char *inet_ntop6(const unsigned char *src, char *dst, size_t size);
* return:
* pointer to presentation format address (`dst'), or NULL (see errno).
* note:
* On Windows we store the error in the thread errno, not
* in the winsock error code. This is to avoid loosing the
* actual last winsock error. So use macro ERRNO to fetch the
* errno this funtion sets when returning NULL, not SOCKERRNO.
* On Windows we store the error in the thread errno, not
* in the winsock error code. This is to avoid loosing the
* actual last winsock error. So use macro ERRNO to fetch the
* errno this funtion sets when returning NULL, not SOCKERRNO.
* author:
* Paul Vixie, 1996.
*/
const char *
ares_inet_ntop(int af, const void *src, char *dst, size_t size)
{
switch (af)
{
case AF_INET:
return (inet_ntop4(src, dst, size));
case AF_INET6:
return (inet_ntop6(src, dst, size));
default:
SET_ERRNO(EAFNOSUPPORT);
return (NULL);
}
switch (af) {
case AF_INET:
return (inet_ntop4(src, dst, size));
case AF_INET6:
return (inet_ntop6(src, dst, size));
default:
SET_ERRNO(EAFNOSUPPORT);
return (NULL);
}
/* NOTREACHED */
}
/* const char *
* inet_ntop4(src, dst, size)
* format an IPv4 address, more or less like inet_ntoa()
* format an IPv4 address
* return:
* `dst' (as a const)
* notes:
......@@ -106,22 +98,21 @@ static const char *
inet_ntop4(const unsigned char *src, char *dst, size_t size)
{
static const char fmt[] = "%u.%u.%u.%u";
char tmp[sizeof "255.255.255.255"];
char tmp[sizeof("255.255.255.255")];
if (SPRINTF((tmp, fmt, src[0], src[1], src[2], src[3])) > size)
{
SET_ERRNO(ENOSPC);
return (NULL);
}
strcpy(dst, tmp);
return (dst);
if ((size_t)sprintf(tmp, fmt, src[0], src[1], src[2], src[3]) >= size) {
SET_ERRNO(ENOSPC);
return (NULL);
}
strcpy(dst, tmp);
return (dst);
}
/* const char *
* inet_ntop6(src, dst, size)
* convert IPv6 binary address into presentation (printable) format
* convert IPv6 binary address into presentation (printable) format
* author:
* Paul Vixie, 1996.
* Paul Vixie, 1996.
*/
static const char *
inet_ntop6(const unsigned char *src, char *dst, size_t size)
......@@ -135,11 +126,8 @@ inet_ntop6(const unsigned char *src, char *dst, size_t size)
*/
char tmp[sizeof("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255")];
char *tp;
struct {
long base;
long len;
} best, cur;
unsigned long words[NS_IN6ADDRSZ / NS_INT16SZ];
struct { int base, len; } best, cur;
unsigned int words[NS_IN6ADDRSZ / NS_INT16SZ];
int i;
/*
......@@ -149,37 +137,29 @@ inet_ntop6(const unsigned char *src, char *dst, size_t size)
*/
memset(words, '\0', sizeof(words));
for (i = 0; i < NS_IN6ADDRSZ; i++)
words[i / 2] |= (src[i] << ((1 - (i % 2)) << 3));
words[i / 2] |= (src[i] << ((1 - (i % 2)) << 3));
best.base = -1;
cur.base = -1;
best.len = 0;
cur.base = -1;
cur.len = 0;
for (i = 0; i < (NS_IN6ADDRSZ / NS_INT16SZ); i++)
{
if (words[i] == 0)
{
if (cur.base == -1)
cur.base = i, cur.len = 1;
else
cur.len++;
}
for (i = 0; i < (NS_IN6ADDRSZ / NS_INT16SZ); i++) {
if (words[i] == 0) {
if (cur.base == -1)
cur.base = i, cur.len = 1;
else
{
if (cur.base != -1)
{
if (best.base == -1 || cur.len > best.len)
best = cur;
cur.base = -1;
}
}
}
if (cur.base != -1)
{
if (best.base == -1 || cur.len > best.len)
best = cur;
cur.len++;
} else {
if (cur.base != -1) {
if (best.base == -1 || cur.len > best.len)
best = cur;
cur.base = -1;
}
}
}
if (cur.base != -1) {
if (best.base == -1 || cur.len > best.len)
best = cur;
}
if (best.base != -1 && best.len < 2)
best.base = -1;
......@@ -187,46 +167,42 @@ inet_ntop6(const unsigned char *src, char *dst, size_t size)
* Format the result.
*/
tp = tmp;
for (i = 0; i < (NS_IN6ADDRSZ / NS_INT16SZ); i++)
{
/* Are we inside the best run of 0x00's? */
if (best.base != -1 && i >= best.base &&
i < (best.base + best.len))
{
if (i == best.base)
*tp++ = ':';
continue;
}
/* Are we following an initial run of 0x00s or any real hex? */
if (i != 0)
for (i = 0; i < (NS_IN6ADDRSZ / NS_INT16SZ); i++) {
/* Are we inside the best run of 0x00's? */
if (best.base != -1 && i >= best.base &&
i < (best.base + best.len)) {
if (i == best.base)
*tp++ = ':';
/* Is this address an encapsulated IPv4? */
if (i == 6 && best.base == 0 &&
(best.len == 6 || (best.len == 5 && words[5] == 0xffff)))
{
if (!inet_ntop4(src+12, tp, sizeof(tmp) - (tp - tmp)))
return (NULL);
tp += strlen(tp);
break;
}
tp += SPRINTF((tp, "%lx", words[i]));
continue;
}
/* Are we following an initial run of 0x00s or any real hex? */
if (i != 0)
*tp++ = ':';
/* Is this address an encapsulated IPv4? */
if (i == 6 && best.base == 0 && (best.len == 6 ||
(best.len == 7 && words[7] != 0x0001) ||
(best.len == 5 && words[5] == 0xffff))) {
if (!inet_ntop4(src+12, tp, sizeof(tmp) - (tp - tmp)))
return (NULL);
tp += strlen(tp);
break;
}
tp += sprintf(tp, "%x", words[i]);
}
/* Was it a trailing run of 0x00's? */
if (best.base != -1 && (best.base + best.len) == (NS_IN6ADDRSZ / NS_INT16SZ))
if (best.base != -1 && (best.base + best.len) ==
(NS_IN6ADDRSZ / NS_INT16SZ))
*tp++ = ':';
*tp++ = '\0';
/*
* Check for overflow, copy, and we're done.
*/
if ((size_t)(tp - tmp) > size)
{
SET_ERRNO(ENOSPC);
return (NULL);
}
if ((size_t)(tp - tmp) > size) {
SET_ERRNO(ENOSPC);
return (NULL);
}
strcpy(dst, tmp);
return (dst);
}
#endif
......@@ -75,6 +75,11 @@ typedef enum __ns_type {
ns_t_sink = 40, /* Kitchen sink (experimentatl) */
ns_t_opt = 41, /* EDNS0 option (meta-RR) */
ns_t_apl = 42, /* Address prefix list (RFC3123) */
ns_t_ds = 43, /* Delegation Signer (RFC4034) */
ns_t_sshfp = 44, /* SSH Key Fingerprint (RFC4255) */
ns_t_rrsig = 46, /* Resource Record Signature (RFC4034) */
ns_t_nsec = 47, /* Next Secure (RFC4034) */
ns_t_dnskey = 48, /* DNS Public Key (RFC4034) */
ns_t_tkey = 249, /* Transaction key */
ns_t_tsig = 250, /* Transaction signature. */
ns_t_ixfr = 251, /* Incremental zone transfer. */
......@@ -181,6 +186,11 @@ typedef enum __ns_rcode {
#define T_SRV ns_t_srv
#define T_ATMA ns_t_atma
#define T_NAPTR ns_t_naptr
#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_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 - 2010 by Daniel Stenberg et al
/* Copyright (C) 2004 - 2011 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
......@@ -35,7 +35,10 @@
#include <string.h>
#include <stdarg.h>
#include <ctype.h>
#ifdef HAVE_ERRNO_H
#include <errno.h>
#endif
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
......@@ -248,6 +251,7 @@ struct timeval {
#define ISPRINT(x) (isprint((int) ((unsigned char)x)))
#define ISUPPER(x) (isupper((int) ((unsigned char)x)))
#define ISLOWER(x) (islower((int) ((unsigned char)x)))
#define ISASCII(x) (isascii((int) ((unsigned char)x)))
#define ISBLANK(x) (int)((((unsigned char)x) == ' ') || \
(((unsigned char)x) == '\t'))
......@@ -366,7 +370,7 @@ typedef int sig_atomic_t;
* (or equivalent) on this platform to hide platform details to code using it.
*/
#ifdef WIN32
#if defined(WIN32) && !defined(WATT32)
#define ERRNO ((int)GetLastError())
#define SET_ERRNO(x) (SetLastError((DWORD)(x)))
#else
......@@ -455,6 +459,18 @@ typedef int sig_atomic_t;
#endif
/*
* System error codes for Windows CE
*/
#if defined(WIN32) && !defined(HAVE_ERRNO_H)
#define ENOENT ERROR_FILE_NOT_FOUND
#define ESRCH ERROR_PATH_NOT_FOUND
#define ENOMEM ERROR_NOT_ENOUGH_MEMORY
#define ENOSPC ERROR_INVALID_PARAMETER
#endif
/*
* Actually use __32_getpwuid() on 64-bit VMS builds for getpwuid()
*/
......
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