summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYu Jiung <jiung.yu@samsung.com>2016-11-10 16:24:08 +0900
committerYu Jiung <jiung.yu@samsung.com>2016-11-10 16:25:02 +0900
commit8166b0204b6945a4fdb89bbae0b0b7168a7cf6e8 (patch)
tree81f0750d91aa467df3ee81cf30d22a65db2e6685
parentccccebb78520ec3a26a18370936516b12ae5d53a (diff)
parent45e88a8337839e5fd88519bc55467053d521c9f6 (diff)
downloadc-ares-8166b0204b6945a4fdb89bbae0b0b7168a7cf6e8.tar.gz
c-ares-8166b0204b6945a4fdb89bbae0b0b7168a7cf6e8.tar.bz2
c-ares-8166b0204b6945a4fdb89bbae0b0b7168a7cf6e8.zip
Conflicts: packaging/c-ares.spec Change-Id: I1ec10e394aed3ef19ee21fefbe3aba7d7a615c74
-rw-r--r--AUTHORS24
-rw-r--r--CHANGES3971
-rw-r--r--CHANGES.01218
-rw-r--r--GIT-INFO9
-rw-r--r--INSTALL2
-rw-r--r--LICENSE.md (renamed from LICENSE)5
-rw-r--r--LICENSE.mit21
-rw-r--r--Makefile.am11
-rw-r--r--Makefile.dj2
-rw-r--r--Makefile.inc27
-rw-r--r--Makefile.m3213
-rw-r--r--Makefile.msvc72
-rw-r--r--Makefile.netware9
-rw-r--r--README.cares18
-rw-r--r--README.md (renamed from README)36
-rw-r--r--RELEASE-NOTES63
-rw-r--r--acinclude.m418
-rw-r--r--acountry.c16
-rw-r--r--ahost.112
-rw-r--r--ahost.c24
-rw-r--r--ares.h52
-rw-r--r--ares__close_sockets.c6
-rw-r--r--ares__get_hostent.c30
-rw-r--r--ares__read_line.c10
-rw-r--r--ares__timeval.c2
-rw-r--r--ares_build.h.in16
-rw-r--r--ares_cancel.315
-rw-r--r--ares_create_query.369
-rw-r--r--[-rwxr-xr-x]ares_create_query.c14
-rw-r--r--ares_data.c44
-rw-r--r--ares_data.h16
-rw-r--r--ares_destroy.320
-rw-r--r--ares_destroy.c22
-rw-r--r--ares_destroy_options.39
-rw-r--r--ares_dup.36
-rw-r--r--ares_expand_name.c18
-rw-r--r--ares_expand_string.c2
-rw-r--r--ares_free_hostent.c12
-rw-r--r--ares_free_string.35
-rw-r--r--ares_free_string.c2
-rw-r--r--ares_get_servers.320
-rw-r--r--ares_get_servers_ports.31
-rw-r--r--ares_gethostbyaddr.c6
-rw-r--r--ares_gethostbyname.c23
-rw-r--r--ares_getnameinfo.31
-rw-r--r--ares_getnameinfo.c41
-rw-r--r--ares_getsock.c8
-rw-r--r--ares_init.3170
-rw-r--r--ares_init.c451
-rw-r--r--ares_init_options.3263
-rw-r--r--ares_ipv6.h8
-rw-r--r--ares_library_init.319
-rw-r--r--ares_library_init.c30
-rw-r--r--ares_nowarn.c59
-rw-r--r--ares_options.c160
-rw-r--r--ares_parse_a_reply.c54
-rw-r--r--ares_parse_aaaa_reply.c54
-rw-r--r--ares_parse_mx_reply.c8
-rw-r--r--ares_parse_naptr_reply.c8
-rw-r--r--ares_parse_ns_reply.c38
-rw-r--r--ares_parse_ptr_reply.c58
-rw-r--r--ares_parse_soa_reply.c13
-rw-r--r--ares_parse_srv_reply.c8
-rw-r--r--ares_parse_txt_reply.348
-rw-r--r--ares_parse_txt_reply.c52
-rw-r--r--ares_private.h35
-rw-r--r--ares_process.c133
-rw-r--r--ares_query.c6
-rw-r--r--ares_rules.h21
-rw-r--r--ares_save_options.32
-rw-r--r--ares_search.c40
-rw-r--r--ares_send.c14
-rw-r--r--ares_set_local_dev.32
-rw-r--r--ares_set_servers.330
-rw-r--r--ares_set_servers_csv.336
-rw-r--r--ares_set_servers_ports.31
-rw-r--r--ares_set_servers_ports_csv.31
-rw-r--r--ares_set_socket_callback.310
-rw-r--r--ares_set_socket_configure_callback.333
-rw-r--r--ares_set_sortlist.358
-rw-r--r--ares_strdup.c35
-rw-r--r--ares_strdup.h2
-rw-r--r--ares_timeout.c9
-rw-r--r--ares_version.h6
-rw-r--r--ares_writev.c4
-rw-r--r--bitncmp.c2
-rwxr-xr-xbuildconf46
-rw-r--r--cares.rc6
-rw-r--r--config-dos.h3
-rw-r--r--config-win32.h18
-rw-r--r--configure.ac124
-rw-r--r--inet_net_pton.c2
-rwxr-xr-xinstall-sh681
-rw-r--r--m4/ax_check_user_namespace.m454
-rw-r--r--m4/ax_check_uts_namespace.m476
-rw-r--r--m4/ax_code_coverage.m4219
-rw-r--r--m4/ax_cxx_compile_stdcxx_11.m4163
-rw-r--r--m4/ax_pthread.m4332
-rw-r--r--m4/cares-confopts.m442
-rw-r--r--m4/xc-am-iface.m4253
-rwxr-xr-xmkinstalldirs167
-rw-r--r--packaging/c-ares.spec10
102 files changed, 7583 insertions, 2635 deletions
diff --git a/AUTHORS b/AUTHORS
index 905c1bb..af29ec8 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -2,9 +2,13 @@ c-ares is based on ares, and these are the people that have worked on it since
the fork was made:
Albert Chin
+Alex Loukissas
+Alexander Klauer
Alexander Lazic
Alexey Simak
Andreas Rieke
+Andrew Andkjar
+Andrew Ayer
Andrew C. Morrow
Ashish Sharma
Ben Greear
@@ -13,20 +17,27 @@ BogDan Vatra
Brad House
Brad Spencer
Bram Matthys
+Chris Araman
Dan Fandrich
Daniel Johnson
Daniel Stenberg
+David Drysdale
David Stuart
Denis Bilenko
Dima Tisnek
Dirk Manske
Dominick Meglio
Doug Goldstein
+Doug Kwan
Duncan Wilcox
Eino Tuominen
Erik Kline
+Fedor Indutny
+Frederic Germain
+Geert Uytterhoeven
George Neill
Gisle Vanem
+Gregor Jasny
Guenter Knauf
Guilherme Balena Versiani
Gunter Knauf
@@ -34,25 +45,38 @@ Henrik Stoerner
Jakub Hrozek
James Bursa
Jérémy Lal
+Keith Shaw
+Lei Shi
Marko Kreen
Michael Wallner
Mike Crowe
Nick Alcock
Nick Mathewson
+Nicolas "Pixel" Noble
+Ning Dong
+Oleg Pudeyev
+Patrick Valsecchi
Patrik Thunstrom
+Paul Saab
Peter Pentchev
Phil Blundell
Poul Thomas Lomholt
Ravi Pratap
Robin Cornelius
+Saúl Ibarra Corretgé
Sebastian at basti79.de
Shmulik Regev
Stefan Bühler
Steinar H. Gunderson
+Svante Karlsson
Tofu Linden
Tom Hughes
Tor Arntsen
+Viktor Szakats
Vlad Dinulescu
William Ahern
Yang Tse
+hpopescu at ixiacom.com
liren at vivisimo.com
+nordsturm
+saghul
diff --git a/CHANGES b/CHANGES
index f1426fd..93e6a43 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,7 +1,3968 @@
-This file no longer holds the changelog. Now you can generate it yourself
-like this:
+ Changelog for the c-ares project. Generated with git2changes.pl
- $ git log --pretty=fuller --no-color --date=short --decorate=full -1000 |
- ./git2changes.pl
+Version 1.12.0 (29 Sep 2016)
-The older, manually edited, changelog is found in git named CHANGES.0
+Daniel Stenberg (29 Sep 2016)
+- RELEASE-NOTES: 1.12.0
+
+- [David Drysdale brought this change]
+
+ ares-test-misc: test ares_create_query with escaped trailing dot
+
+- ares_create_query: avoid single-byte buffer overwrite
+
+ ... when the name ends with an escaped dot.
+
+ CVE-2016-5180
+
+ Bug: https://c-ares.haxx.se/adv_20160929.html
+
+- ares_library_initialized.3: added
+
+- make: bump CARES_VERSION_INFO for release
+
+David Drysdale (29 Sep 2016)
+- man: update ares_init_options.3
+
+Daniel Stenberg (29 Sep 2016)
+- ares_library_init.3: corrected the ares_library_init_mem proto
+
+- README.md: remove space from link
+
+- README: link to the correct c-ares badge!
+
+ Reported-by: David Hotham
+
+ Fixes #63
+
+- docs: minor formatting edits
+
+- ares_destroy.3: formatting polish
+
+- ares_init.3: split the init docs into two separate man pages
+
+- SECURITY: point to the vulnerabilities page now
+
+- RELEASE-NOTES: synced with daa7235b1a5
+
+- ares_create_query.3: edit language
+
+ Tried to make the man page more readable.
+
+David Drysdale (26 Sep 2016)
+- test: fix gMock to work with gcc >= 6.x
+
+ Taken from:
+ https://github.com/google/googletest/issues/705#issuecomment-235067917
+
+Daniel Stenberg (26 Sep 2016)
+- [Brad House brought this change]
+
+ headers: remove checks for and defines of variable sizes
+
+ ... they're not really used and by avoiding them in the ares_build.h
+ output we make the public header less dependent on data sizes.
+
+David Drysdale (24 Sep 2016)
+- api: add ARES_OPT_NOROTATE optmask value
+
+ Fix up a couple of problems with configuring whether c-ares rotates
+ between different name servers between requests.
+
+ Firstly, ares_save_options() returns (in *optmask) the value of
+ (channel->optmask & ARES_OPT_ROTATE), which doesn't necessarily
+ indicate whether the channel is or is not actually doing rotation.
+ This can be confusing/incorrect if:
+ - the channel was originally configured without ARES_OPT_ROTATE
+ (so it appears that the channel is not rotating)
+ - the /etc/resolv.conf file includes the 'rotate' option
+ (so the channel is actually performing rotation).
+
+ Secondly, it is not possible to reliably configure a channel
+ to not-rotate; leaving off ARES_OPT_ROTATE is not enough, since
+ a 'rotate' option in /etc/resolv.conf will turn it on again.
+
+ Therefore:
+ - add an ARES_OPT_NOROTATE optmask value to allow explicit
+ configuration of no-rotate behaviour
+ - in ares_save_options(), report the value of channel->rotate
+ as exactly one of (optmask & ARES_OPT_ROTATE) or
+ (optmask & ARES_OPT_NOROTATE).
+
+ In terms of back-compatibility:
+ - existing apps that set ARES_OPT_ROTATE will continue to rotate,
+ and to have ARES_OPT_ROTATE reported back from ares_save_options()
+ - existing apps that don't set ARES_OPT_ROTATE will continue to
+ use local config/defaults to decide whether to rotate, and will
+ now get ARES_OPT_ROTATE or ARES_OPT_NOROTATE reported back from
+ ares_save_options() rather than 0.
+
+- ares_init_options: only propagate init failures from options
+
+ Commit 46bb820be3a8 ("ares_init_options: don't lose init failure")
+ changed init behaviour so that earlier errors in initialization
+ weren't lost. In particular, if the user passes in specific
+ options but they are not applied (e.g. because of an allocation
+ failure), that failure needs to be reported back to the user; this
+ also applies when duplicating a channel with ares_dup().
+
+ However, other initialization failures can be ignored and
+ overridden -- in particular, if init_by_resolv_conf() or
+ init_by_environment() fail, then falling back to default values
+ is OK.
+
+ So only preserve failures from the init_by_options() stage, not
+ from all initialization stages.
+
+ Fixes issue 60.
+
+- test: Force reinstall of libtool on OSX
+
+ Travis build environment appears to have changed.
+
+- test: Add valgrind build variant
+
+- test: Add null pointer to gtest args
+
+ GoogleTest assumes that there is a null pointer in argv[argc],
+ so make it look like that. Without this change, tests run with
+ command-line arguments get memory errors under valgrind/ASAN.
+
+Daniel Stenberg (21 Aug 2016)
+- AUTHOR: maybe gitgub isn't really an author =)
+
+- AUTHORS: added contributors from the git log
+
+- LICENSE.md: add a stand-alone license file
+
+ Just the MIT license used in the top the source files moved out to a
+ stand-alone file for easier reference and discovery.
+
+- README: added "CII best practices" badge
+
+- SECURITY.md: suggested "security process" for the project
+
+David Drysdale (17 Aug 2016)
+- test: Add Clang static analysis build to Travis
+
+ Run scan-build over the library source code, but skip the
+ tests. Needs a later Clang install in Travis
+
+- test: more info on how to run fuzz testing
+
+- test: make fuzzer driver code C not C++
+
+- test: fuzzer mode for AFL's persistent mode
+
+ When fuzzing with AFL, if the LLVM-based instrumentation is
+ used (via the afl-clang-fast wrapper), then it is possible to
+ have a single execution of the fuzzer program iterate multiple
+ times over the fuzzing entrypoint (similar to libFuzzer's normal
+ mode of execution) with different data. This is much (e.g. 10x)
+ faster.
+
+ Add code to support this, by checking whether __AFL_LOOP is
+ defined at compile-time.
+
+ Also, shift the code to effectively be C rather than C++.
+
+- test: simplify deps for fuzzer entrypoint
+
+ No need to depend on the rest of the test code (ares-test.h) for
+ the fuzzer entrypoint; this makes the entrypoint slightly simpler
+ to build with LLVM's libFuzzer.
+
+ Also shift the code to effectively be C rather than C++
+
+- test: disable MinGW tests
+
+ The test binary built in the MinGW build is failing for some
+ reason. It works for me when I build locally, so I'm guessing
+ it's down to some sort of AppVeyor environment issue.
+
+ Disable for now.
+
+Daniel Stenberg (16 Aug 2016)
+- read_tcp_data: remove superfluous NULL check
+
+ CID 56884 by Coverity. The pointer is already derefenced before this
+ point so it can't be NULL here anyway.
+
+- web: http => https
+
+GitHub (20 Jul 2016)
+- [David Drysdale brought this change]
+
+ Merge pull request #59 from fuze/master
+
+ Update msvc_ver.inc for VS2015 Update 3
+
+- [Chris Araman brought this change]
+
+ Update msvc_ver.inc
+
+ support Visual Studio 2015 Update 3
+
+David Drysdale (2 May 2016)
+- Fix trailing comment for #endif
+
+Daniel Stenberg (30 Apr 2016)
+- email: use Gisle's "new" address
+
+David Drysdale (18 Apr 2016)
+- test: drop superfluous fuzz inputs
+
+ Where there are multiple fuzz input files that only differ in
+ the first two bytes (the query ID), just keep the first such
+ file.
+
+svante karlsson (15 Apr 2016)
+- Update msvc_ver.inc
+
+ support Visual Studio 2015 Update 2
+
+David Drysdale (31 Mar 2016)
+- test: Run fuzzcheck.sh in Travis build
+
+- test: add fuzzing check script to tests
+
+ Add a test script that runs the fuzzing command over the
+ corpus of DNS packets. This doesn't actually do any fuzzing
+ (it just runs them as inputs without generating any variations)
+ but it does ensure that the fuzzing entrypoint is still working.
+
+- test: allow multiple files in aresfuzz command line
+
+ If no arguments are specified, use stdin as input.
+ Otherwise treat each argument as a filename and feed
+ its contents to the fuzz entrypoint.
+
+- test: Add corpus of DNS packets
+
+ For fuzz testing it is useful to start from a corpus of valid
+ packets, so fill out the test/fuzzinput/ directory with a bunch
+ of inputs.
+
+ These packets were generated by temporarily modifying the c-ares
+ process_answer() function to save off any incoming response messages.
+
+- test: Add utility to show DNS packet from file
+
+- [nordsturm brought this change]
+
+ Fix nsort initialization
+
+ Author: Alexander Drachevskiy
+ http://c-ares.haxx.se/mail/c-ares-archive-2014-07/0004.shtml
+ http://c-ares.haxx.se/mail/c-ares-archive-2014-07/0014.shtml
+
+- test: Check setting nsort=0 option is respected
+
+- test: Update fuzzing function prototype
+
+ libFuzzer changed expected return type from void to int
+ in LLVM 3.8.
+
+- Explicitly clear struct servent before use
+
+ On a build where MSAN has been manually set up (which involves
+ using an MSAN-instrumented version of the standard C++ library, see
+ https://github.com/google/sanitizers/wiki/MemorySanitizerLibcxxHowTo)
+ there's a warning about use of uninitialized memory here. It
+ might be a false positive, but the fix is trivial so include it.
+
+- test: for AF_UNSPEC, return CNAME only for AAAA, but valid A record
+
+ Also shuffle expected responses rsp6/rsp4 into the order they will occur.
+
+- [Chris Araman brought this change]
+
+ msvc_ver.inc: support Visual Studio 2015 Update 1
+
+- build: commonize MSVC version detection
+
+ Remove the need to copy/paste version number mapping between
+ Makefile.msvc and test/Makefile.msvc.
+
+- test: Use different name in live test
+
+- test: Only pass unused args to GoogleTest
+
+- ahost.c: add cast to fix C++ compile
+
+ If ahost.c is force-compiled as C++ the missing cast from
+ (void *) to (char **) is problematic.
+
+- ares_library_cleanup: reset ares_realloc too
+
+ Otherwise a subsequent use of the library might use a previous
+ incarnation's realloc() implementation.
+
+Daniel Stenberg (9 Mar 2016)
+- [Brad House brought this change]
+
+ configure: check if tests can get built before enabled
+
+ The current approach for disabling tests is not a good solution because
+ it forces you to pass --disable-tests, rather than auto-detect if your
+ system can support the tests in the first place. Many (most?) systems
+ do not have C++11. This also causes issues when chain-building c-ares,
+ the hosting system needs to be updated to support passing this
+ additional flag if necessary, it doesn't seem reasonable to add this
+ requirement which breaks compatibility.
+
+ This change auto-detects if the system can build the tests and
+ automatically disable them if it cannot. If you pass --enable-tests to
+ configure and the system cannot build them either due to lack of system
+ support, or because cross-compilation is being used, it will throw an
+ appropriate error since the user indicated they really did want the
+ tests.
+
+David Drysdale (3 Mar 2016)
+- [Viktor Szakats brought this change]
+
+ Makefile.m32: add support for CROSSPREFIX
+
+- [Viktor Szakats brought this change]
+
+ Makefile.m32: add support for extra flags
+
+ Allow specification of CARES_{LD,C}FLAG_EXTRAS envvars
+ for mingw
+
+- test: Build with MinGW on AppVeyor
+
+- test: avoid in6addr_* constants
+
+ These aren't available on MinGW, so use explicit addresses instead.
+
+- test: add missing #includes for dns-proto.cc
+
+- [Gregor Jasny brought this change]
+
+ Fix man page typos detected by Lintian
+
+Daniel Stenberg (19 Feb 2016)
+- configure: acknowledge --disable-tests
+
+ Fixes #44
+
+- AUTHORS: added contributors from the 1.11.0 release
+
+- bump: start working on the next version
+
+Version 1.11.0 (19 Feb 2016)
+
+Daniel Stenberg (19 Feb 2016)
+- RELEASE-NOTES: final edits for 1.11.0
+
+David Drysdale (15 Feb 2016)
+- ares_dup.3: remove mention of nonexistent function
+
+ ares_dup_options() doesn't exist, so don't document it.
+
+- test: skip repeated build steps
+
+ Top-level buildconf/configure now triggers for the
+ test/ subdir too, so don't need to do explicitly.
+
+- test: namespaces unavailable when cross-compiling
+
+Daniel Stenberg (13 Feb 2016)
+- configure: only run configure in test when NOT cross-compiling
+
+ ... as the tests won't run cross-compiled anyway
+
+David Drysdale (13 Feb 2016)
+- test: prefer ON_CALL to EXPECT_CALL to reduce flakes
+
+ For UDP tests, there's a chance of a retry. EXPECT_CALL only
+ expects a single request to arrive at the server; ON_CALL allows
+ for a UDP retry and repeats the same answer.
+
+ Note that ON_CALL and EXPECT_CALL can't be mixed in the same
+ test, and that tests that have a varied sequence of responses
+ for the same repeated request still have to use EXPECT_CALL.
+
+Daniel Stenberg (13 Feb 2016)
+- configure: run configure in 'test' too
+
+ Having the test dir completely stand-alone causes too many issues for
+ users and devs. It still needs to be built specifically.
+
+- configure: build silently by default
+
+- buildconf: run test/buildconf too if present
+
+- test/configure: build silently by default
+
+- [Gregor Jasny brought this change]
+
+ dist: Distribute README.md
+
+ Closes #42
+
+Version 1.11.0 (11 Feb 2016)
+
+Daniel Stenberg (11 Feb 2016)
+- Makefile.am: distribute the test dir too
+
+- RELEASE-NOTES: synced with 385582bd14b68a
+
+- [Nicolas \"Pixel\" Noble brought this change]
+
+ ares_win32_init: make LoadLibrary work when using UNICODE too
+
+ Closes #17
+
+David Drysdale (11 Feb 2016)
+- Use "resolve" as synonym of "dns" in nsswitch.conf
+
+ Modern Linux systems may have libnss_resolve from systemd as the
+ resolver, which is then configured in /etc/nsswitch.conf with
+ the "resolve" keyword rather than "dns".
+
+ Fixes #33
+
+- ares_set_socket_callback: make manpage match code
+
+ The code in ares_process.c that invokes the socket creation/connection
+ callback only checks for rc < 0, not for standard ares error codes.
+
+- Merge pull request #36 from AGWA-forks/master
+
+ Add ares_set_socket_configure_callback()
+
+- test: Update init tests to match behaviour
+
+ Unreadable config files are now treated the same way
+ as absent config files.
+
+- [Fedor Indutny brought this change]
+
+ Ignore `fopen` errors to use default values
+
+ After 46bb820be3a83520e70e6c5f0c5133253fcd69cd `init_by_resolv_conf`
+ errors are no longer swallowed in `ares_init_options`. This has exposed
+ a previously unknown bug in `lookups` initialization code.
+
+ If there is no lookup configuration in `resolv.conf`,
+ `init_by_resolv_conf` will attempt to read it from other files available
+ on the system. However, some of these files may have restricted
+ permissions (like `600`), which will lead to `EACCESS` errno, which in
+ turn is handled like a fatal error by `init_by_resolv_conf`.
+
+ However, it sounds illogical that this error should be handled as a
+ fatal. There is a `init_by_defaults` call that overrides `lookups` with
+ default value, and certainly possible absence of lookup information is
+ the reason why this function exists in a first place!
+
+ I suggest handling any `fopen` errors as non-fatal ones, allowing to
+ pick up the `lookups` value from different config files, or to pick up
+ default value.
+
+Andrew Ayer (9 Feb 2016)
+- Document callback type in man page for ares_set_socket_callback
+
+- Add ares_set_socket_configure_callback()
+
+ This function sets a callback that is invoked after the socket is
+ created, but before the connection is established. This is an ideal
+ time to customize various socket options.
+
+David Drysdale (9 Feb 2016)
+- test: ares_set_socket_callback failure behaviour
+
+- test: Check ares_parse_txt_reply_ext() entrypoint
+
+- [Fedor Indutny brought this change]
+
+ txt: introduce `ares_parse_txt_reply_ext`
+
+ Introduce `ares_txt_ext` structure with an extra `record_start`
+ field, which indicates a start of a new TXT record, thus allowing to
+ differentiate the chunks in the same record, from a chunks in a
+ different record.
+
+ Introduce a new API method: `ares_parse_txt_reply_ext` that works with
+ this kind of struct.
+
+- doc: Update missed repo references
+
+- doc: Update docs on contributing
+
+- test: Run command line tools in Travis
+
+ Do a quick execution of each of the command line tools
+ in the continuous integration build, so that any (say)
+ sanitizer failures show up.
+
+- acountry: drop inert test
+
+ If ver_1 is true, then z0 and z1 must both be 'z', and so
+ (z0 != 'z' && z1 != 'z') can never be true.
+
+ CID 56879, pointed out by Coverity.
+
+- doc: update badge locations to master repo
+
+- test: Enable maintainer mode + debug in Travis
+
+- test: Add an iOS build target
+
+- test: Ignore SIGPIPE in tests
+
+- test: More initialization tests
+
+- test: Improve containerized test mechanism
+
+ Aim is to ensure that code coverage information can escape the
+ container. To do this:
+ - Enter a new mount namespace too, so that we can...
+ - Bind mount the expected source directory into the container
+ - Share memory with the sub-process so coverage information is
+ shared too.
+
+- test: Make contained tests easier to write
+
+- test: Add framework for containerized testing
+
+ On Linux we can potentially use user and UTS namespaces to run a test
+ in a pseudo-container with:
+ - arbitrary filesystem (e.g. /etc/resolv.conf, /etc/nsswitch.conf, /etc/hosts)
+ - arbitrary hostname/domainname.
+
+ Include a first pass at the framework code to allow this, along with a
+ first test case that uses the container.
+
+- test: Use a longer timeout for less flakiness
+
+ Having occasional test failures from timeout before multiple
+ queries can complete, so up the default timeout for the test
+ from 100ms to 1500ms.
+
+- test: Make failure tests more robust
+
+ Different platforms will do different numbers of allocations
+ in the processing of a given API call; just check that the
+ return code is either success or ENOMEM, and free off any
+ returned state in the former case.
+
+ Also cope with ECONNREFUSED as well as ENOTFOUND.
+
+- test: Get test code building under Windows
+
+ - Initial nmake file based off library nmake file
+ - Cast socket call arguments to (char *)
+ - Use wrapper sclose() that maps to closesocket() or close()
+ - Build a config.h indicating presence of headers
+ - Conditionally include netdb.h
+ - Remove unnecessary include of sys/socket.h
+ - Force longer bitmask for allocation failure tracking
+ - Call WSAStartup() / WSACleanup() in main()
+ - Set TCP_NODELAY for mock server
+ - Turn on tests in AppVeyor build
+
+- test: Disable tests that manipulate env on Windows
+
+- test: Move file lists into Makefile.inc
+
+ In preparation for a Win32 build of the test suite.
+
+- test: Add a simple multi-server test
+
+ Check rotate option does something
+
+- test: Allow for multiple mock servers
+
+ - Update the MockServer to allow separate specification of
+ UDP and TCP ports
+ - Have an array of mock servers listening on consecutive
+ sets of ports.
+ - Rename Process(fd) to ProcessFD(fd) to avoid confusion.
+ - Initialize channel by using the new ares_set_servers_ports()
+ entrypoint, so multiple ports on the same loopback address
+ can be used.
+
+- test: Update test for set/get_servers variants
+
+ Ports are significant in the _ports_ variant functions, so update test to cope.
+
+- test: Make GetNameServers() utility function port-aware
+
+ Also make it generally available.
+
+- test: more testing, including of internal static functions
+
+- test: more tests, especially fallback processing
+
+ - Make mock server listen on UDP + TCP in parallel.
+ - Test UDP->TCP fallback on truncation
+ - Test EDNS->no-EDNS fallback
+ - Test some environment init options
+ - Test nonsense reply
+
+ test: short response
+
+- test: more tests, particularly of initialization
+
+- test: Run mock tests over both TCP and UDP
+
+ With the exception of a few tests that make use of the timed
+ retry aspect of UDP.
+
+- test: Run mock tests over both IPv4 and IPv6
+
+- test: Add more tests for edge cases
+
+- test: more nooks and crannies of pton functions
+
+- test: More tests for PTR parsing
+
+- test: Use of HOSTALIAS environment variable
+
+- test: Add RAII utility classes for testing
+
+ - TempFile holds specific contents
+ - EnvValue sets an environment variable
+
+- test: More search domain scenarios
+
+- test: Remove duplicate flags from Makefile.am
+
+- test: Make test code leak-free
+
+- test: More tests
+
+ - test use of sortlist
+ - test gethostbyname(AF_UNSPEC)
+
+- test: Test ares_gethostbyname_file()
+
+- test: Add more tests of ares_getnameinfo()
+
+- test: Tweak tests, add alloc failure test
+
+- test: Test init with options
+
+- test: More tests
+
+ - ares_inet_net_pton() variants
+ - ares_getsock() variants
+
+- test: Expose ProcessWork() function
+
+- test: More parsing tests
+
+ Including:
+ - Split each parse function test set out into separate files.
+ - Add an allocation failure test for each parsing function.
+ - Add error check test for each parsing function.
+
+- test: Add various additional tests
+
+- test: More tests
+
+ Include tests of internal functions, based on the value of the
+ CARES_SYMBOL_HIDING macro; need to configure the library with
+ --disable-symbol-hiding to enable these tests.
+
+- test: Allow command line override of mock server port
+
+- test: Add README.md documentation
+
+- test: Temporarily avoid latest Python requests package
+
+ Currently get error from Travis on this install step, and downgrading one
+ version appears to fix the problem.
+
+ "Could not find any downloads that satisfy the requirement pyOpenSSL>=0.13
+ (from requests[security])"
+
+- test: Add AppVeyor config file for Windows build
+
+- test: Add configuration for a Travis build
+
+ Cover Linux & OSX on the container infrastructure, but install
+ a later G++ to satisfy the tests' need for C++11.
+
+ Use a build matrix to include a variety of build variants:
+ - ASAN
+ - UBSAN
+ - LSAN
+ - Coverage via coveralls.io
+
+ test: invoke ASAN and coverage in Travis build
+
+ Also shift to use explicit build matrix
+
+ test: Use coveralls.io for coverage tracking
+
+ test: Add a build with UBSAN
+
+ Also expand and re-order the setting of environment variables
+ for easier modification.
+
+ test: Add LSAN build to Travis config
+
+- test: Add initial unit tests for c-ares library
+
+ The tests are written in C++11, using the GoogleTest and GoogleMock
+ frameworks. They have their own independent autoconf setup, so that
+ users of the library need not have a C++ compiler just to get c-ares
+ working (however, the test/configure.ac file does assume the use of
+ a shared top-level m4/ directory). However, this autoconf setup has
+ only been tested on Linux and OSX so far.
+
+ Run with "./arestest", or "./arestest -v" to see extra debug info.
+ The GoogleTest options for running specific tests are also
+ available (e.g. "./arestest --gtest_filter=*Live*").
+
+ The tests are nowhere near complete yet (currently hitting around
+ 60% coverage as reported by gcov), but they do include examples
+ of a few different styles of testing:
+
+ - There are live tests (ares-test-live.cc), which assume that the
+ current machine has a valid DNS setup and connection to the
+ internet; these tests issue queries for real domains but don't
+ particularly check what gets returned. The tests will fail on
+ an offline machine.
+
+ - There a few mock tests (ares-test-mock.cc) that set up a fake DNS
+ server and inject its port into the c-ares library configuration.
+ These tests allow specific response messages to be crafted and
+ injected, and so are likely to be used for many more tests in
+ future.
+
+ - To make this generation/injection easier, the dns-proto.h file
+ includes C++ helper classes for building DNS packets.
+
+ - Other library entrypoints that don't require network activity
+ (e.g. ares_parse_*_reply) are tested directly.
+
+ - There are few tests of library-internal functions that are not
+ normally visible to API users (in ares-test-internal.cc).
+
+ - A couple of the tests use a helper method of the test fixture to
+ inject memory allocation failures, using the earlier change to the
+ library to allow override of malloc/realloc/free.
+
+ - There is also an entrypoint to allow Clang's libfuzzer to drive
+ the packet parsing code in ares_parse_*_reply, together with a
+ standalone wrapper for it (./aresfuzz) to allow use of afl-fuzz
+ for further fuzz testing.
+
+- test: Add local copy of GoogleMock/GoogleTest 1.7.0
+
+ Don't check in gtest/m4 files, as they are unused and interfere
+ with the top-level configure process.
+
+- doc: Show build badges in README.md
+
+ Note that these URLs will need to be updated if/when the test branch
+ gets pulled into the master repo/branch.
+
+- doc: Convert README to README.md
+
+ Gives better display on GitHub
+
+- doc: Update in preparation for next release
+
+ Assume 1.11.0 is next (as there are various API additions).
+ Also add myself to AUTHORS.
+
+- build: Allow header compilation by Windows C++ compiler
+
+- build: Expose whether symbol hiding is on
+
+ Adding the CARES_SYMBOL_HIDING definition allows the test suite to
+ detect whether internal symbols are available or not.
+
+- build: Add autoconf macros for C++11 code using pthreads
+
+ Pull in testing macros from the GNU autoconf archive to allow
+ configure scripts to test for and setup use of a C++11 compiler
+ (AX_CXX_COMPILE_STDCXX_11) and the pthreads library (AX_PTHREAD).
+
+ Note that these macros are not used by the main library autoconf,
+ just by the tests (which share the same m4/ directory).
+
+- build: Add a code coverage option
+
+ Configure with:
+ ./configure --enable-code-coverage
+ Show coverage output with:
+ make code-coverage-capture
+
+ Built on m4/ax_code_coverage.m4 from the GNU autoconf archive
+ to provide the macros to check for presence of gcov + lcov;
+ upstream macro modified to:
+ - Remove use of $(AM_DEFAULT_VERBOSITY) , as earlier versions of
+ autoconf (such as the one used by default on Travis) do not have this.
+ - Rather than automatically defining CODE_COVERAGE_RULES to be a set
+ of makefile rules that use ifeq/endif (which is GNU make-specific),
+ instead only define CODE_COVERAGE_RULES if coverages is turned on,
+ and in that case don't use conditionals in the makefile.
+
+- api: Add entrypoints to allow use of per-server ports
+
+ Add user-visible entrypoints ares_{get,set}_servers_ports(3), which
+ take struct ares_addr_port_node rather than struct ares_addr_node.
+ This structure includes a UDP and TCP port number; if this is set
+ to zero, the channel-wide port values are used as before.
+
+ Similarly, add a new ares_set_servers_ports_csv(3) entrypoint, which
+ is analogous to ares_set_servers(3) except it doesn't ignore any
+ specified port information; instead, any per-server specified port
+ is used as both the UDP and TCP port for that server.
+
+ The internal struct ares_addr is extended to hold the UDP/TCP ports,
+ stored in network order, with the convention that a value of zero
+ indicates that the channel-wide UDP/TCP port should be used.
+
+ For the internal implementation of ares_dup(3), shift to use the
+ _ports() version of the get/set functions, so port information is
+ transferred correctly to the new channel.
+
+ Update manpages, and add missing ares_set_servers_csv to the lists
+ while we're at it
+
+- api: Add ares_set_sortlist(3) entrypoint
+
+ Allow explicit configuration of the channel's sortlist, by
+ specifying a string in the same format as the equivalent
+ /etc/resolv.conf option.
+
+ This allows library users to perform the same configuration
+ that is available via /etc/resolv.conf, but without needing
+ to change that file.
+
+- api: Allow injection of user-specified malloc/free functions
+
+ Add a new ares_library_init_mem() initialization function for the
+ library which allows the library user to specify their own malloc,
+ realloc & free equivalents for use library-wide.
+
+ Store these function pointers in library-wide global variables,
+ defaulting to libc's malloc(), realloc() and free().
+
+ Change all calls to malloc, realloc and free to use the function pointer
+ instead. Also ensure that ares_strdup() is always available
+ (even if the local environment includes strdup(3)), and change the
+ library code to always use it.
+
+ Convert calls to calloc() to use ares_malloc() + memset
+
+- api: Add option to expose some internal functions
+
+ Purely for testing, add --enable-expose-statics option to configure
+ which converts some static internal functions to be externally visible.
+
+- api: Expose the ares_library_initialized() function
+
+- ahost: Allow repeated -s <domain> options
+
+ This also removes a potential leak where later -s options would
+ replace earlier ones without freeing the relevant string.
+
+- Mark unhittable lines
+
+ Add comments for the benefit of the lcov tool, marking
+ lines that cannot be hit. Typically these are fall-back
+ protection arms that are already covered by earlier checks,
+ and so it's not worth taking out the unhittable code (in case
+ someone changes the code between the two places in future).
+
+- ares_set_servers_csv.3: make return type match code
+
+- bitncmp: update comment to match code behaviour
+
+- ares_striendstr: fix so non-NULL return can happen
+
+ This looks to have been broken since it was first introduced in 2005 in
+ commit aba0b775ea30 ("Added ares_getnameinfo which mimics the
+ getnameinfo API")
+
+- config_sortlist: free any existing sortlist on (re)alloc failure
+
+ If we get an allocation failure on 2nd or later entry in the sortlist, the
+ code would return ENOMEM but still leave the initial entries allocated.
+ Ensure that *sortlist is set to NULL whenever ENOMEM is returned.
+
+- ares_dup: clear new channel on failure
+
+ If the attempt to transfer IPv6 servers from the old to the new channel
+ fails, the previous code would still return a channel to the user even though
+ an error return code was generated. This makes it likely that users would
+ leak the channel, so explicitly clear the channel in this case.
+
+- ares_init_options: don't lose init failure
+
+ If (say) init_by_options() fails, the subsequent call to
+ init_by_defaults() was overwriting the return code with
+ success. Still call init_by_defaults() regardless, but track
+ its return value separately
+
+- ares_gethostbyname: don't leak valid-but-empty hostent
+
+ If an AF_UNSPEC query gets a valid response to its AAAA query,
+ but which has no IPv6 addresses in it, then the code chains on to
+ a A record query. However, the hostent from the AAAA response
+ was being leaked along the way (because it gets replaced before
+ the follow-on end_hquery() invocation).
+
+- ares_parse_txt_reply: propagate errors from per-substring loop
+
+ If we get an allocation failure when processing a particular substring in a
+ TXT record, that failure is silently lost; fix that by propagating errors from
+ the inner loop to the outer loop.
+
+- process_answer: fix things up correctly when removing EDNS option
+
+ When a server rejects an EDNS-equipped request, we retry without
+ the EDNS option. However, in TCP mode, the 2-byte length prefix was
+ being calculated wrong -- it was built from the answer length rather than
+ the length of the original request.
+
+ Also, it is theoretically possible that the call to realloc() might change
+ the data pointed to; to allow for this, qbuf also needs updating.
+
+ (Both these fixes were actually included in a patchset sent on the mailing
+ list in Oct 2012, but were included with other functional changes that
+ didn't get merged:
+ http://c-ares.haxx.se/mail/c-ares-archive-2012-10/0004.shtml)
+
+- ares__read_line: clear buf pointer on realloc failure
+
+- ares_expand_name: check for valid bits in label length
+
+ The top two bits of the label length indicate whether this is a
+ label length (00) or an index to a name elsewhere in the message
+ (11). RFC1035 4.1.4 says that the other possible values for the
+ top two bits (01, 10) are reserved for future use.
+
+Daniel Stenberg (23 Jan 2016)
+- [Gregor Jasny brought this change]
+
+ Fix typos detected by lintian
+
+ Closes #32
+
+- [Gregor Jasny brought this change]
+
+ Distribute all man pages
+
+- README.cares: s/I/Daniel
+
+ ... and add a pointer to an existing version of the original area 1.1.1
+ package.a
+
+- read_tcp_data: don't try to use NULL pointer after malloc failure
+
+ CID 56884, pointed out by Coverity. We really should make this function
+ return an error code so that a malloc() failure can return back a major
+ failure.
+
+- configure_socket: explicitly ignore return code
+
+ CID 56889 in Coverity pointed out the return code from setsocknonblock()
+ is ignored, and this added typecast to (void) makes it explicit.
+
+- ahost: check the select() return code
+
+ Fixes CID 137189, pointed out by Coverity
+
+David Drysdale (18 Jan 2016)
+- Fix buildconf on platforms using glibtoolize
+
+ Commit c49a87eea538 changed buildconf to only check for
+ libtoolize, but missed a line
+
+- Don't exit loop early leaving uninitialized entries
+
+ Update for commit affc63cba875d.
+
+ The original patch from Gregor Jasny did not have the break
+ statement; I incorrectly added it to prevent continuing the loop.
+ However, the later entries in the array would then be left
+ uninitialized, causing problems for later cleanup.
+
+ So fix to match Gregor's original patch, with apologies.
+
+Daniel Stenberg (18 Jan 2016)
+- buildconf: remove check for libtool, it only requires libtoolize
+
+David Drysdale (17 Jan 2016)
+- [Gregor Jasny brought this change]
+
+ Use libresolv to initialize cares on iPhone targets
+
+ On iPhone targets like iOS, watchOS or tvOS the file
+ /etc/resolv.conf cannot be used to configure cares.
+
+ Instead the resolver library is queried for configuration
+ values.
+
+ CC: Yury Kirpichev <ykirpichev@yandex-team.ru>
+
+Daniel Stenberg (17 Jan 2016)
+- README: updated to new repo URL
+
+David Drysdale (14 Jan 2016)
+- [Lei Shi brought this change]
+
+ Fixing slow DNS lookup issue
+
+ This patch is fixing the dns lookup issue due to dummy dns information
+ of a disconnected adapter(in my case is a bluetooth adapter). I changed
+ the dns lookup policy to try GetNetworkParams first because the
+ GetNetworkParams provides the most reliable dns information (lots of
+ checks were done by system). I also filter out inoperable adapter in
+ DNS_AdaptersAddresses in case GetNetworkParams fail.
+
+- Merge pull request #30 from p-push/vs-2015
+
+ Support Visual Studio 2015
+
+Oleg Pudeyev (3 Jan 2016)
+- [Gisle Vanem brought this change]
+
+ Support Visual Studio 2015
+
+David Drysdale (11 Nov 2015)
+- [Andrew Andkjar brought this change]
+
+ added another version case to Makefile.msvc
+
+ nmake version 11.00.61030.0 resolves to CC_VERS_NUM = 110
+
+- Merge pull request #26 from bitbouncer/vs-2013
+
+ added define for visual studio 2013
+
+svante karlsson (25 Jun 2015)
+- added define for visual studio 2013
+
+Jakub Hrozek (6 Nov 2014)
+- ares__read_line: free buf on realloc failure
+
+- Destroy options if ares_save_options fails
+
+ It's possible that, if ares_save_options failed, the opts structure
+ would contain some allocated memory. Calling ares_destroy_options in
+ this case is safe, because ares_save_options zeroes out the memory
+ initially.
+
+- [David Drysdale brought this change]
+
+ Continue loop if space for hostname not large enough
+
+ When attempting to build a search domain from the local hostname
+ (used as a fallback when no other methods have given a search
+ domain), the code doubles the buffer size on each loop iteration.
+
+ However, the loop previously had a WHILE_FALSE terminator so the continue
+ statement exited the loop rather than going round again.
+
+Daniel Stenberg (30 Oct 2014)
+- ares_getnameinfo.3: there is no ares_getaddrinfo
+
+David Drysdale (30 Sep 2014)
+- [Gregor Jasny brought this change]
+
+ Prevent tmpbuf from overrunning
+
+ Fix Coverity error CID 56886.
+
+ Signed-off-by: Gregor Jasny <gjasny@googlemail.com>
+
+- [Gregor Jasny brought this change]
+
+ Re-start loop if select fails
+
+ Fix Coverity error CID 56882
+
+ Signed-off-by: Gregor Jasny <gjasny@googlemail.com>
+
+- [Gregor Jasny brought this change]
+
+ Free temporary variable in error path
+
+ Fix Coverity CID 56890
+
+ Signed-off-by: Gregor Jasny <gjasny@googlemail.com>
+
+- [Gregor Jasny brought this change]
+
+ Fix integer shift overflow if both tcp_socket and udp_socket are set
+
+ The problem occurs if at the start of the loop the sockindex is at the
+ last valid ARES_GETSOCK_MAXNUM position. If then both udp_socket and
+ tcp_socket are valid, sockindex gets incremented for UDP first and
+ points one entry behind the array for the tcp block.
+ So the fix is to check after every increment of sockindex if it is still
+ valid.
+
+ Fix Coverity error CID 56878
+
+ Signed-off-by: Gregor Jasny <gjasny@googlemail.com>
+
+- [Gregor Jasny brought this change]
+
+ Null check before dereference
+
+ Fix Coverity error CID 56880
+
+ Signed-off-by: Gregor Jasny <gjasny@googlemail.com>
+
+Jakub Hrozek (28 Jul 2014)
+- [Gisle Vanem brought this change]
+
+ Comment in ares_ipv6.h
+
+David Drysdale (25 Jul 2014)
+- CONTRIBUTING: add file to indicate mailing list is preferred
+
+- Add -t u option to ahost
+
+ Add an option to allow specification of the AF_UNSPEC
+ address family.
+
+Jakub Hrozek (24 Jul 2014)
+- host_callback: Fall back to AF_INET on searching with AF_UNSPEC
+
+ Previously, when an ares_gethostbyname() searched with AF_UNSPEC and the
+ first AF_INET6 call only returned CNAMEs, the host_callback never
+ retried AF_INET.
+
+ This patch makes sure than on ARES_SUCCESS, the result of AF_INET6 is
+ taken as authoritative only if the result contains some addresses.
+
+- [David Drysdale brought this change]
+
+ Move memset call below platform-specific declarations
+
+ A GitHub commenter [1] says that my recent change to ahost.c has
+ problems compiling on Windows + C89 platforms.
+
+ [1] https://github.com/bagder/c-ares/commit/ee22246507c9#commitcomment-6587616
+
+- [David Drysdale brought this change]
+
+ Update ahost man page to describe -s option.
+
+ Commit ee22246507c9 added the -s <domain> option to the
+ ahost command, but neglected to update the man page to
+ describe it.
+
+ Also fix typo in description of -t option.
+
+- ares_parse_soa_reply: Do not leak rr_name on allocation failure
+
+ If ares_malloc_data failed, already allocated rr_name would go out of
+ scope.
+
+- [David Drysdale brought this change]
+
+ Don't override explicitly specified search domains
+
+ Only set search domains from /etc/resolv.conf if there isn't a value
+ already present in the channel.
+
+- [David Drysdale brought this change]
+
+ Allow specification of search domain in ahost
+
+ Add the "-s domain" command line option to override the search
+ domains.
+
+Daniel Stenberg (12 May 2014)
+- Revert "ares_parse_aaaa_reply: fix leak when reply contains 1 alias and no address"
+
+ This reverts commit 440110b303fdbfadb3ad53d30eeb98cc45d70451.
+
+- [Frederic Germain brought this change]
+
+ ares_parse_aaaa_reply: fix leak when reply contains 1 alias and no address
+
+- [Doug Kwan brought this change]
+
+ ares_build.h: fix building on 64-bit powerpc
+
+ There are two issues.
+
+ 1. gcc actually does not use __ppc__ and __ppc64__ but __PPC__ and
+ __PPC64__. The tests of __ILP32__ and __LP64__ are sufficient for gcc.
+
+ 2. clang defines __GNU__ and defines both __ppc64__ and __ppc__ when
+ targeting ppc64. This makes CARES_SIZEOF_LONG to be 4 on a ppc64 system
+ when building with clang.
+
+ My patch is two change the order of the checks so that we check the
+ 64-bit case first.
+
+- refresh: updated now with automake 1.14
+
+- [David Drysdale brought this change]
+
+ single_domain: Invalid memory access for empty string input
+
+ We noticed a small buglet in ares_search() when it gets an empty string
+ as input -- the single_domain() utility function in ares_search.c
+ accesses invalid memory (before the start of the string).
+
+Guenter Knauf (31 Aug 2013)
+- Fixed warning 'type specifier missing'.
+
+Daniel Stenberg (30 Aug 2013)
+- [Tor Arntsen brought this change]
+
+ ares_rules.h: CARES_SIZEOF_LONG doesn't exist anymore, don't test for it
+
+ It was removed in f19387dd72432
+
+- nowarn: use <limits.h> instead of configure for size of long
+
+ This makes the header file much more multi-arch friendly and can be used
+ as-is with both 32 bit and 64 bit builds.
+
+- timeoffset: made static and private
+
+ ares__timeoffset() was only used once within this single source file
+
+- timeadd: make static
+
+ ares__timeadd() was only ever used from within the same source
+
+Yang Tse (18 Jul 2013)
+- xc-am-iface.m4: comments refinement
+
+- configure: fix 'subdir-objects' distclean related issue
+
+ See XC_AMEND_DISTCLEAN comments for details.
+
+- configure: automake 1.14 compatibility tweak (use XC_AUTOMAKE)
+
+- xc-am-iface.m4: provide XC_AUTOMAKE macro
+
+Daniel Stenberg (12 May 2013)
+- gitignore: ignore all ares_*pdf but also CHANGES.dist
+
+- bump: start working towards 1.10.1
+
+Version 1.10.0 (12 May 2013)
+
+Daniel Stenberg (12 May 2013)
+- RELEASE-NOTES: two more bug fixes
+
+- [Keith Shaw brought this change]
+
+ ares_set_servers_csv: fixed IPv6 address parsing
+
+ Fixed bug that caused the last part of an IPv6 address to be parsed as
+ the port number when the last part is all numeric.
+
+- nroff: fix two syntax mistakes
+
+ ares_parse_a_reply and ares_parse_aaaa_reply both had two \fB instead of
+ \fP
+
+ Reported-by: Alexander Klauer
+ Bug: http://c-ares.haxx.se/mail/c-ares-archive-2013-03/0010.shtml
+
+- [Alex Loukissas brought this change]
+
+ build: fix build on msvc11
+
+- Makefile.am: increment -version-info for 1.10.0 release
+
+- README: remove unnecessary comment
+
+- ares_version.h: copyright end range year is now 2013
+
+- RELEASE-NOTES: synced with fb0737f3a0a1c37
+
+- [Paul Saab brought this change]
+
+ ares_parse_aaaa_reply: Plug memory leak
+
+ This change is similar to ares_parse_a_reply.c in commit
+ bffd67f16a8f42fe6dbf79ab2e39d92eea05c8a6
+
+- [Patrick Valsecchi brought this change]
+
+ ares_parse_txt_reply: return a ares_txt_reply node for each sub-string
+
+ Previously, the function would wrongly return all substrings merged into
+ one.
+
+- [Alexander Klauer brought this change]
+
+ library init: documentation update
+
+ This commit updates the documentation of ares_library_init() and
+ ares_library_cleanup() with regard to the newly introduced reference
+ counting of initializations and deinitializations.
+
+- [Alexander Klauer brought this change]
+
+ library init: be recursive
+
+ Previously, a single call to ares_library_cleanup() would deinitialise
+ the c-ares library, regardless of how many times ares_library_init() was
+ called. This behaviour may cause problems in programs linking two or
+ more libraries which, in turn, use c-ares. The present commit fixes this
+ problem, deinitializing the library only after a number of calls to
+ ares_library_cleanup() matching the number of calls to
+ ares_library_init().
+
+- [Patrick Valsecchi brought this change]
+
+ protocol parsing: check input data stricter
+
+ ... so that bad length fields aren't blindly accepted
+
+ Bug: http://c-ares.haxx.se/mail/c-ares-archive-2013-04/0016.shtml
+
+Guenter Knauf (11 Apr 2013)
+- Create ares_build.h when buidling from Git.
+
+- Added -DCARES_STATICLIB to CFLAGS.
+
+ Currently this static makefile does only support building the
+ static library libcares.a.
+
+Daniel Stenberg (8 Apr 2013)
+- [Alexander Klauer brought this change]
+
+ .gitignore: ignore patch files
+
+ This commit adds a line to .gitignore to the effect that patch files
+ generated by 'git format-patch' are excluded from the repository.
+
+- [Alexander Klauer brought this change]
+
+ ares_destroy() documentation: no new requests
+
+ Clarify that no new requests may be added to a resolver channel that is
+ currently being destroyed.
+
+- [Alexander Klauer brought this change]
+
+ Documentation: properly document ARES_ECANCELLED
+
+ This commit clarifies the behaviour of ares_cancel() with respect to
+ callbacks and adds missing documentation of ARES_ECANCELLED to the man
+ pages of the affected functions.
+
+- [Alexander Klauer brought this change]
+
+ ares_cancel(): cancel requests safely
+
+ An invocation of ares_cancel() walks through the request list, calling
+ the callbacks of all pending requests on a channel. Previously, if such
+ a callback added a new request to the channel, the request list might
+ not end up empty, causing an abort by assertion failure. The present
+ commit ensures that precisely all requests present upon entry of
+ ares_cancel() are cancelled, and that adding new requests through
+ callbacks is safe.
+
+Yang Tse (10 Mar 2013)
+- ares.h: stricter CARES_EXTERN linkage decorations logic
+
+ No API change involved.
+
+- ares_build.h.dist: enhance non-configure GCC ABI detection logic
+
+ GCC specific adjustments:
+
+ - check __ILP32__ before 32 and 64bit processor architectures in
+ order to detect ILP32 programming model on 64 bit processors
+ which, of course, also support LP64 programming model, when using
+ gcc 4.7 or newer.
+
+ - keep 32bit processor architecture checks in order to support gcc
+ versions older than 4.7 which don't define __ILP32__
+
+ - check __LP64__ for gcc 3.3 and newer, while keeping 64bit processor
+ architecture checks for older versions which don't define __LP64__
+
+Daniel Stenberg (9 Mar 2013)
+- ares.h: there is no ares_free_soa function
+
+Yang Tse (9 Mar 2013)
+- Makefile.am: empty AM_LDFLAGS definition for automake 1.7 compatibility
+
+- ares_inet_ntop.3: s/socklen_t/ares_socklen_t
+
+- configure: use XC_LIBTOOL for portability across libtool versions
+
+- xc-lt-iface.m4: provide XC_LIBTOOL macro
+
+- Makefile.am: use AM_CPPFLAGS instead of INCLUDES
+
+- inet_ntop.c: s/socklen_t/ares_socklen_t
+
+- inet_ntop.c: s/socklen_t/ares_socklen_t for portability
+
+Daniel Stenberg (19 Feb 2013)
+- ares.h: s/socklen_t/ares_socklen_t for portability
+
+- ares_inet_ntop.3: 4th argument is socklen_t!
+
+- spell inet correctly!
+
+- ares_inet_pton/ntop: cleanup
+
+ Make sure that the symbols are always exported and present in c-ares.
+
+ Make the headers prefixed with 'ares'.
+
+ Removed the inet_ntop.h version as it no longer features any content.
+
+- ares_inet_ntop/ares_inet_pton: added man pages
+
+Yang Tse (15 Feb 2013)
+- [Gisle Vanem brought this change]
+
+ curl_setup_once.h: definition of HAVE_CLOSE_S defines sclose() to close_s()
+
+- [Gisle Vanem brought this change]
+
+ config-dos.h: define HAVE_CLOSE_S for MSDOS/Watt-32
+
+- [Gisle Vanem brought this change]
+
+ config-dos.h: define strerror() to strerror_s_() for High-C
+
+Daniel Stenberg (13 Feb 2013)
+- ares_get_datatype: removed unused function
+
+ it was also wrongly named as internal functions require two underscores
+
+- ares__bitncmp: use two underscores for private functions
+
+ It used a single one previously making it look like a public one
+
+- ares__generate_new_id: moved to ares_query.c
+
+ ... and ares__rc4 is turned into a local static function.
+
+- ares__swap_lists: make private and static
+
+ ... since there's only one user, make it static within ares_process.c
+
+Yang Tse (13 Feb 2013)
+- Makefile.msvc: add four VS version strings
+
+Daniel Stenberg (13 Feb 2013)
+- ares_expand_name.3: clarify how to free the data
+
+Yang Tse (30 Jan 2013)
+- zz40-xc-ovr.m4: fix 'wc' detection - follow-up 2
+
+ - Fix a pair of single quotes to double quotes.
+
+ URL: http://curl.haxx.se/mail/lib-2013-01/0355.html
+ Reported by: Tor Arntsen
+
+- zz40-xc-ovr.m4: fix 'wc' detection - follow-up
+
+ - Take into account that 'wc' may return leading spaces and/or tabs.
+
+ - Set initial IFS to space, tab and newline.
+
+- zz40-xc-ovr.m4: fix 'wc' detection
+
+ - Take into account that 'wc' may return leading spaces.
+
+ - Set internationalization behavior variables.
+
+ Tor Arntsen analyzed and reported the issue.
+
+ URL: http://curl.haxx.se/mail/lib-2013-01/0351.html
+
+- zz40-xc-ovr.m4: check another three basic utilities
+
+- zz40-xc-ovr.m4: 1.0 interface stabilization
+
+ - Stabilization results in 4 public interface m4 macros:
+ XC_CONFIGURE_PREAMBLE
+ XC_CONFIGURE_PREAMBLE_VER_MAJOR
+ XC_CONFIGURE_PREAMBLE_VER_MINOR
+ XC_CHECK_PATH_SEPARATOR
+ - Avoid one level of internal indirection
+ - Update comments
+ - Drop XC_OVR_ZZ40 macro
+
+- zz40-xc-ovr.m4: emit witness message in configure BODY
+
+ This avoids witness message in output when running configure --help,
+ while sending the message to config.log for other configure runs.
+
+- zz40-xc-ovr.m4: truly do version conditional overriding
+
+ - version conditional overriding
+ - catch unexpanded XC macros
+ - fix double words in comments
+
+- zz40-xc-ovr.m4: fix variable assignment of subshell output bashism
+
+ Tor Arntsen analyzed and reported the issue.
+
+ URL: http://curl.haxx.se/mail/lib-2013-01/0306.html
+
+- zz40-xc-ovr.m4: reinstate strict AC_REQUIRE macro dependencies
+
+- zz40-xc-ovr.m4: avoid double single-quote usage
+
+- zz40-xc-ovr.m4: parentheses balancing of 'case' statements
+
+ m4 quadrigraph shell comment technique allows proper autoconf
+ parentheses balancing in shell 'case' statements. The presence
+ of unbalanced parentheses may otherwise trigger expansion bugs.
+
+- zz40-xc-ovr.m4: internals overhauling
+
+ - Update comments
+ - Execute commands in subshells
+ - Faster path separator check
+ - Fix missing 'test' command
+ - Rename private macros
+ - Minimize AC_REQUIRE usage
+
+- zz40-xc-ovr.m4: redirect errors and warnings to stderr
+
+- configure: use XC_CONFIGURE_PREAMBLE early checks
+
+ Some basic checks we make were placed early enough in generated
+ configure script when using autoconf 2.5X versions. Newer autoconf
+ versions expand these checks much further into the configure script,
+ rendering them useless. Using XC_CONFIGURE_PREAMBLE fixes placement
+ of early intended checks across all our autoconf supported versions.
+
+- zz40-xc-ovr.m4: provide XC_CONFIGURE_PREAMBLE macro
+
+- configure: autotools compatibility fixes - step I
+
+ Fix proper macro expansion order across autotools versions for
+ C compiler and preprocessor program checks.
+
+- configure: fix automake 1.13 compatibility
+
+ Tested with:
+
+ buildconf: autoconf version 2.69
+ buildconf: autom4te version 2.69
+ buildconf: autoheader version 2.69
+ buildconf: automake version 1.13.1
+ buildconf: aclocal version 1.13.1
+ buildconf: libtool version 2.4
+ buildconf: GNU m4 version 1.4.16
+
+- ares_private.h: use again memdebug.h instead of curl_memdebug.h
+
+- configure.ac: replace AM_CONFIG_HEADER with AC_CONFIG_HEADERS
+
+ automake 1.13 errors if AM_CONFIG_HEADER is used in configure script.
+
+- cares-override.m4: provide AC_CONFIG_MACRO_DIR definition conditionally
+
+ Provide a 'traceable' AC_CONFIG_MACRO_DIR definition only when using
+ an autoconf version that does not provide it, instead of what we were
+ doing up to now of providing and overriding AC_CONFIG_MACRO_DIR for
+ all autoconf versions.
+
+- ares_private.h: use curl_memdebug.h instead of memdebug.h
+
+- vc6cares.dsp: add ares_create_query.c and ares_parse_soa_reply.c
+
+- cares-functions.m4: improve gethostname arg 2 data type check
+
+- setup_once.h: HP-UX specific 'bool', 'false' and 'true' definitions.
+
+ Also reverts commit bceb40095a
+
+- configure: check if compiler halts on function prototype mismatch
+
+- cares-functions.m4: add gethostname arg 2 data type check and definition
+
+- cares-functions.m4: update thread-safeness detection of getaddrinfo()
+
+ Take in account that POSIX standard Issue 7 drops h_errno support. Now, we also
+ consider getaddrinfo() to be thread-safe when (_POSIX_C_SOURCE >= 200809L) or
+ (_XOPEN_SOURCE >= 700) independently of whether h_errno exists or not.
+
+ Take in account that h_errno might be a modifiable lvalue not defined as
+ a C preprocessor macro.
+
+- setup_once.h: HP-UX <sys/socket.h> issue workaround
+
+ Issue: When building a 32bit target with large file support HP-UX
+ <sys/socket.h> header file may simultaneously provide two different
+ sets of declarations for sendfile and sendpath functions, one with
+ static and another with external linkage. Given that we do not use
+ mentioned functions we really don't care which linkage is the
+ appropriate one, but on the other hand, the double declaration emmits
+ warnings when using the HP-UX compiler and errors when using modern
+ gcc versions resulting in fatal compilation errors.
+
+ Mentioned issue is now fixed as long as we don't use sendfile nor
+ sendpath functions.
+
+- setup_once.h: refactor inclusion of <unistd.h> and <sys/socket.h>
+
+ Inclusion of these two header files now done in setup_once.h
+
+- Header inclusion clean-up
+
+ Remove header inclusions already done in setup_once.h
+
+- setup_once.h: HP-UX specific TRUE and FALSE definitions
+
+ Some HP-UX system headers require TRUE defined to 1 and FALSE to 0.
+
+- ares_timeout.c: fix compiler warning
+
+- ares_create_query.c: IRIX compilation fix
+
+- c-ares/nameser.h: add some T_* defines for ns_t_* values
+
+Daniel Stenberg (7 Nov 2012)
+- Revert "ares_parse_aaaa_reply: fix memory leak"
+
+ This reverts commit 50f25d8a4b2d16f4c5e0ef620238688b7a315c7a.
+
+- ares_parse_aaaa_reply: fix memory leak
+
+ an allocated buffer was not freed in the successful case.
+
+- [Gisle Vanem brought this change]
+
+ adig: perror() doesn't work for socket errors on windows
+
+ ... so print the SOCKERRNO instead
+
+- get_DNS_AdaptersAddresses: fix IPv6 parsing
+
+ Use of the wrong define made the function not parse IPv6 addresses
+ properly.
+
+ Bug: http://c-ares.haxx.se/mail/c-ares-archive-2012-06/0028.shtml
+ Reported by: Saúl Ibarra Corretgé
+
+- version: bumped to 1.10.0
+
+ Due to the newly added function: ares_create_query()
+
+- AUTHORS: synced with 83093ac450
+
+ Added 21 authors since this document was last updated
+
+- ares_create_query.3: mention when this is added
+
+- [hpopescu@ixiacom.com brought this change]
+
+ Added new feature (rfc2671)
+
+- code police: fix indents, < 80 columns, reflowed comments
+
+Guenter Knauf (11 Jul 2012)
+- Cleaned up version awk script.
+
+Daniel Stenberg (30 Jun 2012)
+- [Gisle Vanem brought this change]
+
+ read_udp_packets: bail out loop on bad sockets
+
+ I can see that recvfrom() in ares_process.c many times is called with
+ 'udp_socket' == ARES_SOCKET_BAD. The code takes care not to call
+ recv/recvfrom with ARES_SOCKET_BAD in the outer-loop. So should the
+ inner-loop.
+
+Yang Tse (29 Jun 2012)
+- cares-compilers.m4: remove -Wstrict-aliasing=3 from clang
+
+ Currently it is unknown if there is any version of clang that
+ actually supports -Wstrict-aliasing. What is known is that there
+ are several that don't support it.
+
+- cares-compilers.m4: -Wstrict-aliasing=3 for warning enabled gcc and clang builds
+
+Daniel Stenberg (18 Jun 2012)
+- version: work towards 1.9.2 (at least)
+
+Version 1.9.1 (18 Jun 2012)
+
+Daniel Stenberg (18 Jun 2012)
+- RELEASE-NOTES: 1.9.1 coming up
+
+Version 1.9.0 (16 Jun 2012)
+
+Daniel Stenberg (16 Jun 2012)
+- ares_version.h: next version is 1.9.0
+
+- [Marko Kreen brought this change]
+
+ ares_data.h: ARES_DATATYPE_SOA_REPLY is added in 1.9.0
+
+- RELEASE-NOTES: synced with 979bf951d
+
+ Next release deemed to become 1.9.0 due to the new function
+
+- [Marko Kreen brought this change]
+
+ SOA parser added
+
+ I need to do SOA queries, so here is a parser for them.
+
+ - ares_soa_reply: new struct
+ - ares_malloc_data/ares_free_soa: ARES_DATATYPE_SOA_REPLY
+ - ares_parse_soa_reply: actual function
+
+Yang Tse (14 Jun 2012)
+- Kill compiler warning
+
+- Fix libcares.pc generation for static MingW* cross builds
+
+Daniel Stenberg (21 May 2012)
+- [Nick Alcock brought this change]
+
+ Fix UDP and TCP port byte order in saved options.
+
+ The UDP and TCP port are stored in network byte order in the
+ ares_channeldata, but are passed in to ares_init_options() in host byte
+ order. Thus we must return them from ares_save_options() in host byte
+ order too, or a duplicated channel will convert them again, leading to a
+ nonfunctional channel and a mysterious connection refused error from
+ ares_gethostbyname(). This breaks ares_dup(), thus the curl easy API
+ when c-ares is used by curl, and thus all the curl easy API's users.
+
+Yang Tse (28 Apr 2012)
+- version: start working on 1.8.1-DEV
+
+Version 1.8.0 (27 Apr 2012)
+
+Daniel Stenberg (27 Apr 2012)
+- RELEASE-NOTES: call next 1.8 instead
+
+ Since we added a function, let's use a stricter bumping scheme
+
+Yang Tse (25 Apr 2012)
+- INSTALL: some adjustments
+
+Daniel Stenberg (25 Apr 2012)
+- GIT-INFO: mention buildconf
+
+Yang Tse (25 Apr 2012)
+- INSTALL: remove more sections that don't apply to c-ares
+
+- ares_timeout.c: fix compiler warning
+
+Daniel Stenberg (25 Apr 2012)
+- [Ben Noordhuis brought this change]
+
+ Makefile.m32: fix mingw32 build
+
+ * add . to include path so ares_build.h is picked up
+ * make ar configurable to ease cross-compiling
+
+- RELEASE-NOTES: added what's happened since 1.7.5
+
+Guenter Knauf (22 Apr 2012)
+- Updated copyright year.
+
+Yang Tse (21 Apr 2012)
+- ares_init.c: Further refactoring of Windows system's DNS fetching code
+
+Guenter Knauf (20 Apr 2012)
+- Android: small changes to dns property part.
+
+ Prefix prop vars; kill var; use DNS_PROP_NAME_PREFIX macro.
+
+- Handle CNAME-only in ares_parse_aaaa_reply().
+
+ posted to the c-ares list by Peter Griess <pg@std.in>.
+
+- Add support for multiple DNS servers on Android.
+
+ Before, c-ares always used the first DNS server on Android, causing
+ network problems if this DNS server was not available.
+
+ Signed-off-by: Geert Uytterhoeven <Geert.Uytterhoeven@sonycom.com>
+
+- Added INSTALL so it gets into tarballs.
+
+- Added some more ifdefs to silent compiler warnings.
+
+Yang Tse (17 Apr 2012)
+- INSTALL: remove a non c-ares section
+
+- cares-compilers.m4: -Wno-pedantic-ms-format for Windows gcc 4.5 builds
+
+ When building a Windows target with gcc 4.5 or newer and strict compiler
+ warnings enabled use -Wno-pedantic-ms-format in addition to other flags.
+
+- setup_once.h: tighten requirements for stdbool.h header inclusion
+
+ Include stdbool.h only when it is available and configure is capable of
+ detecting a proper 'bool' data type when the header is included.
+
+- configure: NATIVE_WINDOWS no longer defined in config file
+
+- cares-compilers.m4: double underscore decoration for visibility attribute
+
+- build adjustments: CARES_SYMBOL_HIDING no longer defined in config files
+
+ configure script now provides conditional definitions for Makefile.am
+ that result in CARES_SYMBOL_HIDING being defined by resulting makefiles
+ when appropriate.
+
+- configure: Windows cross-compilation fixes
+
+ CARES_BUILDING_LIBRARY and CARES_STATICLIB no longer defined in ares_config.h,
+ configure will generate appropriate conditionals so that mentioned symbols
+ get defined and used in Makefile derived from Makefile.am at compilation time.
+
+Guenter Knauf (17 Apr 2012)
+- Added INSTALL file adapted from libcurl.
+
+ Not yet ready, and needs further edits.
+
+Yang Tse (16 Apr 2012)
+- ares_init.c: get_iphlpapi_dns_info() refactoring
+
+Guenter Knauf (16 Apr 2012)
+- Kill some more compiler warnings.
+
+- Kill compiler warning about unused var.
+
+- Fixed my last commit: wrong preprocessor directive.
+
+- Check for __ANDROID__ in addition to ANDROID macro.
+
+- Check for __ANDROID__ in addition to ANDROID macro.
+
+ Posted to c-ares list by Wayne.
+
+- Fix for Android to disable useless arpa/nameser.h.
+
+- Fix for Android to include sys/select.h for fd_set.
+
+Yang Tse (17 Mar 2012)
+- ares_data.c: some NAPTR related fixes
+
+Daniel Stenberg (16 Mar 2012)
+- port numbers: convert them to network order!
+
+ When the config options ARES_OPT_UDP_PORT or ARES_OPT_TCP_PORT are used,
+ make sure to convert them to network byte order!
+
+ Bug: http://c-ares.haxx.se/mail/c-ares-archive-2012-02/0004.shtml
+
+- white space cleanup
+
+ - Keep code within 80 columns
+
+ - Removed funny spaces after open paren and before closing paren
+
+- [Poul Thomas Lomholt brought this change]
+
+ get_iphlpapi_dns_info: fix buffer overrun
+
+ I experienced a buffer overrun exception in c-ares on Windows and
+ tracked it down to be an error in the calculation of the 'left' variable
+ in get_iphlpapi_dns_info().
+
+ I changed the variable type of 'left' to a _signed_ type because of the
+ subtraction arithmetic; not sure if a long is the best choice
+
+- Merge pull request #7 from saghul/naptr
+
+ Added support for parsing NAPTR records
+
+saghul (23 Feb 2012)
+- Added support for parsing NAPTR records
+
+Yang Tse (19 Jan 2012)
+- ares_init.c: fix compiler warning on winsock builds
+
+- configure: libtool 1.5 tweaks
+
+Daniel Stenberg (19 Dec 2011)
+- ares_timeout.3: fix the NAME section
+
+ It was clearly a copy n' paste error
+
+Yang Tse (27 Sep 2011)
+- [Albert Chin brought this change]
+
+ configure - m4: make CURL_CHECK_DEF ignore leading whitespace on symbol def
+
+ When using Sun C compiler the preprocessor somehow inserts an extra space
+ in front of replaced symbol, breaking CURL_CHECK_DEF macro. To workaround
+ this, macro CURL_CHECK_DEF now ignores all leading whitespace in front of
+ symbol substitution result.
+
+- ares_init.c: fix segfault triggered in ares_init_options() upon previous
+ failure of init_by_defaults() and incomplete cleanup there.
+
+- ares_process.c: fix compiler warning
+
+- fix MSVC compiler warning 'conditional expression is constant'
+
+- setup_once.h cleanup and sync
+
+- [Denis Bilenko brought this change]
+
+ ares_getnameinfo: fix random results with c-ares 1.7.5
+
+ In ares_getnameinfo memcpy did not copy enough bytes, causing
+ it to return arbitrary memory contents as a result.
+
+- warnings: fix another 'conversion may lose significant bits' compiler warning
+
+- ares_dns.h: adjust DNS__16BIT and DNS__32BIT macro definitions
+
+ Fixing compiler warnings existing definitions triggered on these.
+
+- ares_destroy.c: fix segfault in ares_destroy_options()
+
+Daniel Stenberg (21 Aug 2011)
+- ares_parse_srv_reply: silence compiler warnings
+
+ ... by adding ugly typecasts.
+
+- CHANGES: generate from script
+
+ The CHANGES file is now generated automatically with 'git2changes.pl',
+ invoked by the maketgz script which is used to build release archives.
+
+ The former human edited CHANGES file was renamed to CHANGES.0 in git.
+
+Yang Tse (21 Aug 2011)
+- Makefile.netware: SIZEOF_SHORT definition
+
+- warnings: fix some 'conversion may lose significant bits' compiler warnings
+
+- configure: fix symbol hiding usability check
+
+ A more thorough test is done now in order to determine visibility attribute
+ usability, given that some compilers don't support visibility attribute on
+ all configurations.
+
+Daniel Stenberg (16 Aug 2011)
+- 1.7.6: start working...
+
+Version 1.7.5 (16 Aug 2011)
+
+Daniel Stenberg (16 Aug 2011)
+- CHANGES: synced for 1.7.5 release
+
+- RELEASE-NOTES: synced with bb4096effef7f000
+
+Jakub Hrozek (15 Aug 2011)
+- Only fall back to AF_INET searches when looking for AF_UNSPEC addresses
+
+Yang Tse (10 Aug 2011)
+- [Gisle Vanem brought this change]
+
+ ares_iphlpapi.h: Watcom C fix
+
+ Added "!defined(_WS2DEF_)" since Watcom doesn't have
+ a per type guard for the typedefs 'CSADDR_INFO' (that MingW has) or
+ 'SOCKET_ADDRESS' (that MSVC has). But we can use the header-guard for
+ <ws2def.h> instead.
+
+- [Gisle Vanem brought this change]
+
+ Makefile.Watcom:
+ * The 'NTDDI_VERSION' needs to be raised to 0x05010000
+ in order for SOCKADDR_STORAGE etc. to be typedefed.
+ * Replaced '-dUSE_WATT32' with '-dWATT32'.
+ * Added $(DEMOS) to the 'all' target and removed the 'demos'
+ target to be consistent with e.g. Makefile.msvc etc.
+ * 'ENABLE_IPV6' is no longer used. Hence removed the '%use_ipv6' construct.
+ * object-file order seems to be important (Watcom v.19). Hence
+ 'ares_getopt.obj' must be put after the .obj that references getopt().
+
+- cares-compilers.m4: CARES_CONVERT_INCLUDE_TO_ISYSTEM adjustments
+
+ Add CARES_CHECK_COMPILER as a requirement.
+
+ Ensure macro does nothing unless GNU_C or CLANG compiler is used.
+
+ This should allow usage of this macro in unforeseen placements.
+
+- config-win32.h: comments adjustments - followup
+
+- config-win32.h: comments adjustments
+
+Daniel Stenberg (5 Aug 2011)
+- [Tom Hughes brought this change]
+
+ ares_parse_a_reply: fix memleak
+
+Yang Tse (29 Jul 2011)
+- cares-functions.m4 serial # bump
+
+- Revert "configure: additional flag checks for fcntl() and socket()"
+
+ This reverts commit 5f2a3b0e48f26d24cb1fefea0dccb92d417dcbf7.
+
+- configure: additional flag checks for fcntl() and socket()
+
+- xc-translit.m4 fix quoting
+
+- configure: avoid direct usage of AS_TR_* macros
+
+- xc-translit.m4 provides transliteration macros with well defined behavior.
+
+Jakub Hrozek (15 Jun 2011)
+- Revert "Only fall back to AF_INET searches when looking for AF_UNSPEC addresses"
+
+ This reverts commit b5823d65706af687c0e5110af8f0cfdcd068997d.
+
+ This patch was not reviewed properly before pushing
+
+- Revert "Do not use sized constants in public headers"
+
+ This reverts commit 22c01e96f7b2ae9923e1baa50bfe3c0d22297a7d.
+
+ This is a Red Hat specific patch that does not belong into upstream
+
+- Use correct sizeof in ares_getnameinfo()
+
+- Do not leak rr_name on failures inside ares_parse_ptr_reply
+
+- Do not leak rr_name on failures inside ares_parse_a_reply
+
+- Do not leak rr_name on failures inside ares_parse_aaaa_reply
+
+- Do not leak rr_name on failures inside ares_parse_ns_reply
+
+- Fix incorrect sizeof() in ares_save_options
+
+- Fix incorrect allocation in ares_parse_ptr_reply()
+
+- Only fall back to AF_INET searches when looking for AF_UNSPEC addresses
+
+- Do not use sized constants in public headers
+
+Daniel Stenberg (13 Jun 2011)
+- [Jakub Hrozek brought this change]
+
+ ares_free_hostent(NULL) should be a noop
+
+Yang Tse (8 Jun 2011)
+- configure: fix recvfrom 5th arg type qualifier detection (followup)
+
+- configure: fix recvfrom 5th arg type qualifier detection
+
+ Additionally remove whitespace from EOL
+
+Daniel Stenberg (4 Jun 2011)
+- strlen: use size_t to receive the return
+
+Yang Tse (4 Jun 2011)
+- xlc: avoid preprocessor definition usage when linking
+
+- ares_nowarn: icc 9.1 workaround
+
+- ares_nowarn: header inclusion fix
+
+- ares_init: make ares_private.h last included header again
+
+- compiler warning: fix
+
+ Fix compiler warning: conversion may lose significant bits
+
+- compiler warning: fix
+
+ Fix compiler warning: variable was set but never used
+
+ Fix compiler warning: clobber ignored
+
+- ares_iphlpapi: fix compiler warnings
+
+- winsock: compilation fixes
+
+ Provide winsock iphlpapi alternative definitions to prevent compilation
+ failures when using a variety of winsock header implementations.
+
+Daniel Stenberg (17 May 2011)
+- [David Stuart brought this change]
+
+ IPv6-on-windows: find DNS servers correctly
+
+- man pages: docs for the c-ares utility programs
+
+- ares_parse_ns_reply.c: remove CVSism
+
+Yang Tse (27 Mar 2011)
+- build: fix header inclusion
+
+- getservbyport replacement for Win CE
+
+- renamed getplatform() to ares__getplatform() to avoid namespace pollution
+
+- configure: fix libtool warning
+
+ Recent versions of libtool are now tracing usage of AC_CONFIG_MACRO_DIR
+ macro and warn heavily when not used in configure script along with
+ ACLOCAL_AMFLAGS in Makefile.am. So in order to make libtool happy
+ while keeping backwards compatibility this is added.
+
+- adig: RFC4034 resource record type detection
+
+ Can be tested with: adig -s 8.8.8.8 -t ANY example.com
+
+- nameser.h: RFC4034 resource record type definitions
+
+- build: move platform stuff to ares_platform.c and ares_platform.h
+
+- build: find out windows platform using GetVersionEx()
+
+- build: use getenv() replacement function for systems which lack it
+
+- setup_once: system error codes for Windows CE
+
+- ares_search: use ERRNO macro for portability sake
+
+- System's errno.h inclusion cleanup follow-up.
+
+ System's errno.h is conditionally included from setup_once.h
+
+- Windows CE specific adjustment
+
+ All versions of Windows CE support Winsock 1.1
+
+- System's errno.h inclusion cleanup.
+
+ System's errno.h is conditionally included from setup_once.h
+
+- ares_init: fix gethostname error detection on winsock platforms
+
+- configure: r-enable temporarily disabled detection of system's inet_ntop()
+
+ Detection was temporarily disabled in commit 674e044ccb21f2f63537da53565fce868f
+
+Daniel Stenberg (15 Mar 2011)
+- configure: stop using the deprecated AM_INIT_AUTOMAKE syntax
+
+- [Gisle Vanem brought this change]
+
+ Watt-32: use errno
+
+ Make sure Watt-32 programs use 'errno' even on Win32 targets
+
+Guenter Knauf (18 Feb 2011)
+- Removed commented CLFAGS no longer needed.
+
+- Fixed CFLAGS for NetWare.
+
+ Added -m32 to enable compilation with x86_64 compilers;
+ added conditional to set -fpcc-struct-return only for gcc compiler.
+
+Daniel Stenberg (18 Feb 2011)
+- [Gisle Vanem brought this change]
+
+ Watt32: fix server init
+
+ Somewhere in the process, programs using the Watt-32 tcp/ip stack
+ stopped working.
+
+- [Dima Tisnek brought this change]
+
+ config_sortlist: (win32) missing else
+
+ Without an else there, contents of "pat" that could have been
+ successfully set just above, may be clobbered by successive unsuccessful
+ calls to "xxx_pton" or "ip_addr".
+
+Yang Tse (17 Jan 2011)
+- Makefile.msvc: add a couple of VS version strings
+
+- Makefile.msvc: add a couple of VS version strings
+
+- build: add install target to Makefile.msvc
+
+Daniel Stenberg (27 Dec 2010)
+- ares_set_servers_csv: remove unused variables
+
+- init_by_resolv_conf: fix compiler warnings
+
+ The code received the return codes in the 'status' variable without
+ using it. Instead we just ignore those particular errors.
+
+- getv4: Value stored to 'dst' is never read
+
+- advance_tcp_send_queue: avoid NULL ptr dereference
+
+ If given a too large 'num_bytes' value, it would cause a NULL ptr
+ dereference. Instead the code will now break out of the loop at the end
+ of the list.
+
+- [Peter Pentchev brought this change]
+
+ configure: fix a bashism
+
+- cleanup: avoid unsafe typecasts
+
+ Avoid the risk of reading 16bit data from an unaligned address by using
+ a macro that is adapted for this.
+
+- [Stefan Bühler brought this change]
+
+ ares_expand_name: Fix encoded length for indirect root
+
+Yang Tse (18 Dec 2010)
+- build: add some explicit file references to VS project files
+
+- config-win32: provide HAVE_ASSERT_H definition
+
+- build: include ares_nowarn in sample program VS project files
+
+- build: include ares_nowarn among SAMPLESOURCES and SAMPLEHEADERS
+
+- configure: temporarily disable detection of system's inet_ntop()
+
+ This is done to allow compilation of ares_inet_ntop() by some daily
+ builds picky compilers that otherwise do not need this function.
+
+- changes: mention last fix
+
+- ares_inet_ntop: remove definition and usage of macro SPRINTF
+
+ Existing definition of SPRINTF always resulted in sprintf() being used,
+ and sprintf() returning 'int' is already used throughout the library.
+
+- ares_inet_ntop: reapply changes from previous c-ares version (III)
+
+ - Replace 'u_char' with 'unsigned char'.
+ - Replace 'u_int' with 'unsigned int'.
+ - use macros ERRNO and SET_ERRNO() for errno handling.
+
+- ares_inet_ntop: reapply changes from previous c-ares version (II)
+
+ - Remove rcsid.
+ - Adjust header file inclusions.
+ - ares_inet_ntop used only on systems without a proper inet_ntop function.
+
+- ares_inet_ntop: reapply changes from previous c-ares version (I)
+
+ - Replace tabs with spaces.
+ - Use ANSI C style for function declarations and definitions.
+ - Use sizeof with parentheses.
+
+- ares_inet_ntop: fix off by one error triggering out of bounds write
+
+ ares_inet_ntop would trigger an out of bounds write when the representation
+ of the address required 15 characters, due to not taking in account null
+ termination character.
+
+ Full import of inet_ntop.c from bind-9.5.3rc1 to pull additional fixes.
+
+- ares_nowarn: add conditional inclusion of assert.h header
+
+- fix compiler warning: conversion may lose significant bits
+
+- ares_inet_net_pton: fix non-rejection of some malformed literals
+
+ ares_inet_net_pton would return wrong values when excessively large,
+ and invalid, netmasks are used. Fixes are from bind-9.5.3rc1,
+ issue also described in the WLB-2008080064 advisory.
+
+- setup_once: provide ISASCII macro
+
+- configure: inet_net_pton function check adjustments
+
+ Define HAVE_INET_NET_PTON only when system's inet_net_pton function is IPv6
+ capable and is not affected by the WLB-2008080064 advisory.
+
+ HAVE_INET_NET_PTON_IPV6 is no longer defined nor used.
+
+- ares_init: fix detection of semicolon comments in resolv.conf
+
+ File resolv.conf may either use a hash '#' or a semicolon ';' character as an
+ indication that the rest of the line is a comment. This fixes not recognizing
+ the semicolon as a valid comment indicator in resolv.conf.
+
+- version: start working on 1.7.5
+
+Version 1.7.4 (8 Dec 2010)
+
+Daniel Stenberg (8 Dec 2010)
+- release-preps: CHANGES and RELEASE-NOTES synced
+
+- ares_set_local_*: added in 1.7.4, not before
+
+Yang Tse (3 Dec 2010)
+- build: provide SIZEOF_SIZE_T definition for non-configure builds
+
+- build: config.dos renamed to config-dos.h
+
+- build: provide SIZEOF_SIZE_T netware definition
+
+- ares_gethostbyaddr: fix compiler warning: conversion may lose significant bits
+
+- configure: undo using autobuilds to temporarily verify strict aliasing warnings.
+
+- fix compiler warning: rounding, sign extension, or loss of accuracy may result
+
+Daniel Stenberg (2 Dec 2010)
+- [Ben Noordhuis brought this change]
+
+ ares_parse_a_reply: fix CNAME response parsing
+
+ Reply to a CNAME query doesn't contain addresses, causing
+ ares_parse_a_reply() to bail out with ARES_ENODATA
+
+ Bug: http://groups.google.com/group/nodejs/browse_thread/thread/a1268c9ea5e9ad9b
+
+Yang Tse (1 Dec 2010)
+- fix compiler warning: conversion may lose significant bits
+
+- atoi: remove atoi usage
+
+- ares_init: fix compiler warning: conversion may lose significant bits
+
+- configure: fix autoconf warning
+
+- inet_pton: fix compiler warning
+
+- configure: use autobuilds to temporarily verify strict aliasing warnings.
+
+ Temporarily, When cross-compiling with gcc 3.0 or later, enable strict aliasing
+ rules and warnings. Given that cross-compiled targets autobuilds do not run the
+ test-suite, there is no risk of running code that violates strict aliasing rules
+
+- ares_getnameinfo: Partially revert commit 85520d66e0ac7ac73411bc25e98769a88b2f
+
+ Upon socket address family and length validation failure return ARES_ENOTIMP
+ in callback again, this is the error code documented in man page and used
+ mostly all over the library.
+
+- ares_getnameinfo: Validate socket address family and length.
+
+ Validate socket address family and that the socket address length is appropriate
+ for the specified family. Failure is reported with ARES_EBADFAMILY in callback.
+
+- ares_getnameinfo: fix two compiler warnings
+
+- Added another VS10 version string
+
+- Fix GCC 4 compiler warning 'dereferencing type-punned pointer might break strict-aliasing rules'.
+
+- Revert commit 494274e653936335c255a47599970de3df21e7c4
+
+- configure: fix autoconf 2.68 warning: no AC_LANG_SOURCE call detected in body
+
+- Fix compiler warning: array subscript has type 'char'
+
+- Fix GCC 4 compiler warning 'dereferencing type-punned pointer might break strict-aliasing rules'.
+
+- Revert following commits:
+ 07bc7ea79509bcc9ef6e09151e81766ed00d3392
+ 3392a50ea3f8573ea4b7a9d82b9833dab60cb0e9
+ 9912637d32c9987719a1ea12db591aee2941891c
+
+ The purpose of the whole patch was to silence a compiler warning triggered
+ with GCC 4 on file ares_process.c The specific compiler warning was
+ 'dereferencing type-punned pointer might break strict-aliasing rules'.
+
+ A simpler patch will follow to equally silence the warning.
+
+- ares_options: reorder header inclusions to make inclusion of
+ ares_private.h the last included one again.
+
+Daniel Stenberg (12 Nov 2010)
+- [Patrik Thunstrom brought this change]
+
+ adig: fix NAPTR parsing
+
+ I ran across a small "issue" in your adig example.
+
+ It is simply the last part of the NAPTR record, the replacement element,
+ which is not a string, as currently handled in adig, but a domain name.
+
+- ares_save_options: assignments instead of memcpy
+
+- init_by_options: don't copy an empty sortlist
+
+ If there aren't any sort items to copy, don't bother. Without this
+ little precaution it would do a malloc(0) which causes undefined
+ behaviors and is frowned upon by curl's memdebug-system.
+
+Guenter Knauf (3 Oct 2010)
+- Minor Watcom makefile tweaks.
+
+Daniel Stenberg (30 Sep 2010)
+- [Mike Crowe brought this change]
+
+ Fix lookup with HOSTALIASES set.
+
+ ares__read_line returns ARES_EOF when it reaches the end of the
+ file. This will happen every time when reading to the end of the
+ HOSTALIASES file. Unfortunately single_domain treats this error as
+ being fatal.
+
+ Signed-off-by: Mike Crowe <mac@mcrowe.com>
+
+Ben Greear (24 Aug 2010)
+- Add missing break that caused get_ares_servers to fail.
+
+ Reported-by: Ning Dong <flintning@163.com>
+ Signed-off-by: Ben Greear <greearb@candelatech.com>
+
+Yang Tse (11 Aug 2010)
+- configure: werror related adjustments
+
+Guenter Knauf (8 Aug 2010)
+- Added copyright string to ares_version.h and make use of it in other files.
+
+- Block created ares_build.h for NetWare to avoid usage from other platforms.
+
+- Fix to overwrite default libname.
+
+- Some more Watcom makefile massage ...
+
+- Some more Watcom makefile massage ...
+
+Ben Greear (4 Aug 2010)
+- sock-addr-storage: Detect and deal with lack of .ss_family member.
+
+ AIX, at least, does not have sockaddr_storage.ss_family member.
+ Detect this in the configure logic and use proper #ifdefs in the
+ ares_process logic.
+
+ Signed-off-by: Ben Greear <greearb@candelatech.com>
+ Tested-by: Tor Arntsen <tor@spacetec.no>
+
+Guenter Knauf (3 Aug 2010)
+- Added Watcom makefile based on libcurl's Makefile.Watcom.
+
+Ben Greear (31 Jul 2010)
+- typo: Fix compile bug for platforms that don't have sockaddr_storage.
+
+ Bug was introduced by me in previous commit.
+
+ Signed-off-by: Ben Greear <greearb@candelatech.com>
+
+- Fix aliasing warning in gcc 4.4.4 (at least).
+
+ Should be no functional change, though the code gets a bit
+ ugglier.
+
+ Signed-off-by: Ben Greear <greearb@candelatech.com>
+
+Daniel Stenberg (31 Jul 2010)
+- ares_set_servers_csv: use ISDIGIT
+
+ The IS*() set of macros are preferred to the regular is*() functions as
+ they help us avoid the most common pitfalls.
+
+Ben Greear (30 Jul 2010)
+- cast arg to isdigit to int
+
+ Looks like it might silence a warning on Netware build.
+
+ Signed-off-by: Ben Greear <greearb@candelatech.com>
+
+- remove all uses of uint32_t
+
+ Previous fix forgot a few.
+
+ Signed-off-by: Ben Greear <greearb@candelatech.com>
+
+- fix signed v/s unsigned casts warning in ares_gethostbyaddr.c
+
+ Signed-off-by: Ben Greear <greearb@candelatech.com>
+
+- local-bind-fixup: Fix inet_pton warning.
+
+ Conditionally include <arpa/inet.h> for inet_pton
+ headers.
+
+ Signed-off-by: Ben Greear <greearb@candelatech.com>
+
+- build: Enable compiling with -Werror.
+
+ This helps find compile warnings because they simply break
+ the build.
+
+ To use:
+ ./configure --enable-warnings --enable-werror
+
+ Signed-off-by: Ben Greear <greearb@candelatech.com>
+
+- ipv6: Fix some build issues related to the local-bind feature.
+
+ Signed-off-by: Ben Greear <greearb@candelatech.com>
+
+Guenter Knauf (29 Jul 2010)
+- Replaced uint32_t with unsigned int to fix broken builds on a couple of platforms.
+
+Daniel Stenberg (18 Jul 2010)
+- [Ben Greear brought this change]
+
+ local-bind: Support binding to local interface/IPs
+
+ Add 3 new functions to set the local binding for the out-going
+ socket connection, and add ares_set_servers_csv() to set a
+ list of servers at once as a comma-separated string.
+
+ Signed-off-by: Ben Greear <greearb@candelatech.com>
+
+- version: now start on 1.7.4
+
+- [Andrew C. Morrow brought this change]
+
+ fix memory leak in ares_getnameinfo
+
+Version 1.7.3 (11 Jun 2010)
+
+Daniel Stenberg (11 Jun 2010)
+- changelogs: updated for 1.7.3
+
+- [BogDan Vatra brought this change]
+
+ init: allow c-ares to work on Android OS
+
+- changelog: fill in the 1.7.2 changes
+
+- added another pdf to ignore
+
+Yang Tse (11 Jun 2010)
+- add ares_parse_mx_reply.c to VS dsp file
+
+Daniel Stenberg (10 Jun 2010)
+- tarball: add $(CSOURCES) $(HHEADERS) to EXTRA_DIST
+
+ It's not clear to me why we need this, but we apparently may
+ otherwise not get all files bundled in the dist tarball.
+
+- version: start working on 1.7.3
+
+Version 1.7.2 (10 Jun 2010)
+
+Daniel Stenberg (10 Jun 2010)
+- RELEASE-NOTES: 1.7.2 details added
+
+- [Jakub Hrozek brought this change]
+
+ ares_init: Last, not first instance of domain or search should win
+
+- style: make code less than 80 columns wide
+
+Yang Tse (31 May 2010)
+- [Tor Arntsen brought this change]
+
+ improve alternative definition of bool to use enum instead of unsigned char
+
+- fix VS2010 compiler warnings
+
+Daniel Stenberg (18 Apr 2010)
+- [Jérémy Lal brought this change]
+
+ added ares_parse_mx_reply
+
+- repair the file mode
+
+- remove all $Id$ lines
+
+- remove all .cvsignore files
+
+- spell fix
+
+ reported by Gregor Jasny on the mailing list
+
+- [Peter Pentchev brought this change]
+
+ Fix a couple of typos and grammar nits.
+
+- ignore the GPG signature files too
+
+- start the journey towards 1.7.2
+
+- no longer CVS tagging
+
+- ignore generated PDFs
+
+Version 1.7.1 (23 Mar 2010)
+
+Daniel Stenberg (23 Mar 2010)
+- 1.7.1
+
+- made README the primary readme file
+
+ ... and did README.cares to contain a historic reason etc.
+
+- s/CVS/git
+
+- git now, not CVS
+
+- ignore lots of generated files
+
+- [Daniel Johnson brought this change]
+
+ Fix warnings for clang
+
+Yang Tse (17 Mar 2010)
+- replaced intel compiler option -no-ansi-alias with -fno-strict-aliasing
+
+- update outdated serial number
+
+- fix compiler warning
+
+- watt32 compilation fix
+
+- Added another VS10 version string
+
+- fix line break
+
+- removed usage of 's6_addr', fixing compilation issue triggered with no
+ longer using 'in6_addr' but only our 'ares_in6_addr' struct
+
+Daniel Stenberg (5 Mar 2010)
+- Daniel Johnson provided fixes for building with the clang compiler
+
+Yang Tse (5 Mar 2010)
+- Added IPv6 name servers support
+
+Gisle Vanem (5 Mar 2010)
+- Ops!. Readded ares_nowarn.h.
+
+- Added ares_nowarn.c.
+
+Yang Tse (28 Feb 2010)
+- Added SIZEOF_INT and SIZEOF_SHORT definitions for non-configure systems
+
+- Added ares_nowarn.* to VC6 project file
+
+- Added SIZEOF_INT definition
+
+- fix compiler warning
+
+- fix compiler warning
+
+- fix compiler warning
+
+Daniel Stenberg (17 Feb 2010)
+- ares_reinit()
+
+ - To allow an app to force a re-read of /etc/resolv.conf etc, pretty much
+ like the res_init() resolver function offers
+
+- - 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.
+
+Yang Tse (30 Dec 2009)
+- VMS specific preprocessor symbol checking adjustments
+
+- Mention last changes
+
+- - Fix configure_socket() to use ares_socket_t instead of int data type.
+
+- - Where run-time error checks enabling compiler option /GZ was used it is now
+ replaced with equivalent /RTCsu for Visual Studio 2003 and newer versions.
+
+ - Compiler option /GX is now replaced with equivalent /EHsc for all versions.
+
+- - 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.
+
+Daniel Stenberg (30 Nov 2009)
+- start working on 1.7.1
+
+Version 1.7.0 (27 Nov 2009)
+
+Yang Tse (27 Nov 2009)
+- Preserve empty line following last target
+
+- - 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.
+
+- When using icc, compile with -fpic and link with intel dynamic libraries.
+
+- Added 'currently' in italics to insist on transient situation.
+
+- Fix language
+
+- Daniel wants upcoming release to be 1.7.0
+
+- Mention last changes
+
+- - Removed from external interface preprocessor symbol definition for
+ CARES_HAVE_ARES_FREE_DATA. Current functionality of ares_free_data()
+ makes it unnecessary.
+
+- Added README.msvc
+
+- Changed c-ares naming conventions when using MSVC as described in README.msvc
+
+- - Mention other recent changes
+
+- - 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.6.1.
+
+- - Jakub Hrozek fixed more function prototypes in man pages to sync them
+ with the ones declared in ares.h
+
+- Make configure remove the ares_build.h file included in distribution tarballs.
+
+- Fix macro redefinition.
+
+- Fix name space pollution.
+
+- Allow using different extra import libraries for debug and release builds.
+
+- Add manifest stuff to msvc makefile
+
+- Sync man page with reality
+
+- Add missing external API decoration for ares_set_socket_callback()
+
+- Add ares_free_data() man page.
+
+- - Provide in external interface preprocessor symbol definitions for
+ CARES_HAVE_ARES_FREE_DATA as an indication of function availability.
+
+- Remove typecast
+
+- Fix comment
+
+- Add ares_data.c and ares_data.h
+
+- Jakub Hrozek modified ares_parse_srv_reply() and ares_parse_txt_reply() API
+ to return a linked lists of results. These were also modified to internally
+ use the ares_data memory struct and as such its result must be free'ed with
+ ares_free_data().
+
+- Initial support for the generic ares_free_data() function that will allow
+ applications to free memory allocated and returned by some c-ares funtions.
+
+- Make usage of calloc()'s arguments consistent with rest of code base
+
+- workaround icc 9.1 optimizer issue
+
+- Add icc fvisibility bug test
+
+- Fix icc 9.0 compiler warning: external definition with no prior declaration
+
+- Fix three var names
+
+- Add check for assert.h header file
+
+- getaddrinfo is fully thread safe on solaris versions which
+ implement the function even when h_errno is not a macro.
+
+ The h_errno macro test now only done on systems for which there
+ is no hard coded knowledge about getaddrinfo's thread safeness.
+
+- Remove files generated on previous buildconf/configure run
+
+- Remove enable-thread / disable-thread configure option. These were only placebo
+ options. The library is always built as thread safe as possible on every system.
+
+- Refactor how preprocessor symbol _THREAD_SAFE definition is done.
+
+- Assume that getaddrinfo is thread safe, unless hard coded
+ knowledge says the contrary or h_errno is not defined.
+
+- Related with the threadsafe capability of getaddrinfo:
+
+ - Constantine Sapuntzakis reported that Darwin 6.0 a.k.a. MAC OS X 10.2
+ and newer have a threadsafe getaddrinfo.
+
+ - Fix Dragonfly BSD triplet detection.
+
+ - In case the hard-coded knowledge says that getaddrinfo is threadsafe,
+ an additional check is done to verify that h_errno is also defined.
+ If h_errno isn't defined, we finally assume that it isn't threadsafe.
+ Jamie Lokier provided the inspiration for this extra check.
+
+- AIX 5.2 and newer have threadsafe getaddrinfo.
+
+ Add some comments to better understand what the regex's pretend to achieve.
+
+- HP-UX 11.11 and later have threadsafe getaddrinfo
+
+- Check if getaddrinfo is threadsafe when function check allows it to be used
+
+- Renamed fpGetNetworkParams and fpSystemFunction036 to avoid namespace pollution with static library
+
+- Add kernel32.lib
+
+- Mention last changes
+
+- Reinstate copyright symbol lost in previous commit
+
+- Make some strings different in resource file for debug or release builds
+
+- Ignore more subdirs
+
+- Fix compiler warning: conditional expression is constant
+
+- Sync linker and resource compiler options with Makefile.msvc
+
+- Follow Makefile.msvc subdirectory naming scheme, and sync compiler options
+
+- Updated MSVC makefile 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.
+
+- Test for USE_WINSOCK since it is more restrictive than WIN32
+
+- Make header inclusion depend on HAVE_*_H definition
+
+- Remove unneeded preprocessor directives
+
+- Adjust c-ares include paths for memory tracking enabled (--enable-curldebug) builds
+
+- source files used by sample programs
+
+- Renamed c-ares setup.h to ares_setup.h
+
+- Adjust include paths to take in account that currently:
+
+ c-ares with --enable-curldebug uses memdebug.h from libcurl's lib subdirectory.
+
+ memdebug.h needs access to libcurl's setup.h from libcurl's lib subdirectory
+ and also needs access to libcurl's generated curl_config.h
+
+- Undo old temporary change once used for testing purposes
+
+- Mention many changes
+
+- Mention --enable-symbol-hiding configure option
+
+- Symbol hiding configure options renamed to the hopefully less ambiguous
+ --enable-symbol-hiding and --disable-symbol-hiding as well as related
+ macro names and some internal variables used for them.
+
+ Related configuration file preprocessor symbols named to
+ CARES_SYMBOL_HIDING and CARES_SYMBOL_SCOPE_EXTERN.
+
+- Header inclusion depending on HAVE_* symbol.
+ Fix two typos.
+
+- Comparison of the Initial revision of this file with ares_parse_a_reply.c
+ shows that this one is actually a modified copy of ares_parse_a_reply.c.
+
+ In order to comply with ares_parse_a_reply.c's M.I.T. license, the old
+ 1998 M.I.T. copyright notice is now also preserved in this file the same
+ as it is done in other ares_parse_*.c files.
+
+- Add CVS Id tag.
+ Fix identation of some license lines.
+
+- Add CVS Id tag.
+
+- Fix comment
+
+- In no particular order, changed/fixed all of the following in
+ ares_parse_txt_reply() current version:
+
+ - Fixed a couple of potential double free's.
+
+ - Fixed memory leaks upon out of memory condition.
+
+ - Fixed pointer arithmetic.
+
+ - Setting ntxtreply to zero upon entry for all failure cases.
+
+ - Changed data type to size_t for variables substr_len, str_len and
+ the length member of ares_txt_reply struct.
+
+ - Avoided a couple of memcpy() calls.
+
+ - Changed i data type to unsigned int to prevent compiler warnings.
+
+ - Adjusted a comment.
+
+ - Use ARES_SUCCESS literal for successfull completion.
+
+ - Added CVS Id tag.
+
+- Add c-ares DLL resource file to distribution archive
+
+- ignore files
+
+- Empty subdir
+
+- 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.
+
+Daniel Stenberg (29 Oct 2009)
+- no need to check for NULL pointers before dereferencing, as the pointers
+ MUST be valid and they are dereferenced further down in the function
+ unconditionally!
+
+- shorten the descriptions somewhat
+
+- update to the new struct name
+
+- Jakub Hrozek added ares_parse_txt_reply() for TXT parsing
+
+- use 'ares_srv_reply' for proper name-spacing
+
+Yang Tse (29 Oct 2009)
+- Add reference for ares_parse_srv_reply.pdf
+
+- Add reference for ares_parse_srv_reply docs
+
+- External API function linkage decoration adjustment
+
+- External API function linkage decoration adjustment
+
+- Initial step towards the ability to reduce c-ares exported symbols
+ based on the 'visibility' attribute for GNUC and __global for Sun
+ compilers, taking also in account __declspec function decoration
+ for Win32 and Symbian DLL's.
+
+ Introducing configure options --enable-hidden-symbols and
+ --disable-hidden-symbols following libcurl's naming.
+
+- Fix comment
+
+- Fix spelling
+
+- Fix Pelles C Win32 target compilation issues
+
+- John Engelhart noticed an unreleased problem relative to a duplicate
+ ARES_ECANCELLED error code value and missing error code description.
+
+- Fix compiler warning: local variable may be used without having been initialized
+
+- Use *_CHECK_PATH_SEPARATOR_REQUIRED to ensure that *_CHECK_PATH_SEPARATOR
+ is only expanded and included once in the configure script.
+
+- Our _AS_PATH_SEPARATOR_PREPARE override is now m4_defun'd instead of m4_define'd
+ due to autoconf 2.64 m4_require'ing it in _AS_SHELL_SANITIZE indirectly through
+ _AS_PATH_WALK.
+
+- Fix compiler warning: argument is incompatible with corresponding format string conversion
+
+- Fix potential out-of-bounds read
+
+- Fix compiler warning: loop without body
+
+- Fix compiler warning
+
+- Fix compiler warning
+
+- Fix compiler warning
+
+- Fix compiler warning: addition result could be truncated before cast to bigger sized type
+
+- 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.
+
+- Fix ssize_t redefinition errors on WIN64 reported by Alexey Simak
+
+- more files to ignore
+
+- Check if _REENTRANT definition is required to
+ make errno available as a preprocessor macro.
+
+- Attempt to silence bogus compiler warning: "Potential null pointer dereference"
+
+- ignore more files
+
+Gisle Vanem (7 Sep 2009)
+- Suppress warnings about unused prototypes in Watt32 and Win32 programs.
+
+- Update email address.
+
+- Update my email address. Add ares_config.h as dependency for 'make depend'.
+
+Yang Tse (6 Sep 2009)
+- T_SRV portability check
+
+Gunter Knauf (5 Sep 2009)
+- changed includes to match style how we do with all other *.c files.
+
+- changed u_int16_t to unsigned short because it is the only place within ares and curl where such a type would be used;
+ also it broke many autobuilds. We should probably introduce an ares_port_t if we want to use a type here.
+
+Gisle Vanem (5 Sep 2009)
+- Replace 'uint16_t' with 'u_int16_t' since the latter is used in ares.h.
+
+- Added 'ares_parse_srv_reply.obj'. Added definition of 'u_int16_t'. This is I don't like; we should not depend on such non-universal types in a public header. But this is just a quick fix.
+
+Daniel Stenberg (4 Sep 2009)
+- - Jakub Hrozek added ares_parse_srv_reply() for SRV parsing
+
+Steinar H. Gunderson (27 Aug 2009)
+- Support lookup of IPv4 literals in ares_gethostbyname(), even when the address family is set to AF_INET6.
+
+Gisle Vanem (3 Aug 2009)
+- Remove call to LoadLibrary(). (leftover from debugging).
+
+- Fix bad sentence.
+
+Daniel Stenberg (3 Aug 2009)
+- - 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.
+
+- - 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.
+
+Gunter Knauf (16 Jul 2009)
+- test if adding ../lib to includes can fix the current break ...
+
+- renamed generated config.h to ares_config.h in order to avoid clashes when libcurl is used with other projects which also have a config.h.
+
+Yang Tse (21 Jun 2009)
+- Refactor how libraries are checked for connect() function, follow-up.
+
+- Refactor how libraries are checked for connect() function,
+ and check for connect() as it is done for other functions.
+
+Gisle Vanem (20 Jun 2009)
+- Remove unneeded defines.
+
+- Use select_s() and not select().
+
+Yang Tse (19 Jun 2009)
+- sclose() function-like macro definition used to close a socket,
+ now solely based on HAVE_CLOSESOCKET and HAVE_CLOSESOCKET_CAMEL
+ config file preprocessor definitions.
+
+- add CloseSocket camel case function check
+
+- check for socket() and closesocket() as it is done for other functions
+
+- Remove HAVE_CONFIG_H definition from here,
+ CFLAGS from common.dj already defines it.
+
+- initial step towards decoupling c-ares from libcurl for DOS
+
+- don't ignore these subdirs, they must be removed first
+
+- Remove DEBUGBUILD symbol definition, is not required for programs using the library.
+
+- DEBUGBUILD symbol definition for debug builds
+
+- ignore some subdirs
+
+- fix comment
+
+- Try to make more clear that --enable-curldebug has nothing to do with --enable-debug for this library.
+
+- Revert last change, it is inappropriate.
+
+Gisle Vanem (12 Jun 2009)
+- Replace CURLDEBUG with DEBUGBUILD.
+
+Yang Tse (11 Jun 2009)
+- when running automake copy missing files instead of symlinking them
+
+- Adjusted to take in account that...
+
+ With the curl memory tracking feature decoupled from the debug build feature,
+ CURLDEBUG and DEBUGBUILD preprocessor symbol definitions are used as follows:
+
+ CURLDEBUG used for curl debug memory tracking specific code (--enable-curldebug)
+
+ DEBUGBUILD used for debug enabled specific code (--enable-debug)
+
+- c-ares' --enable-debug --enable-curldebug decoupling follow-up
+
+- mention last changes
+
+- Remove buildconf.bat from release and daily snapshot archives.
+
+ buildconf.bat is only for CVS tree builds.
+
+- Ensure that buildconf.bat does nothing unless it is used with a CVS checkout.
+
+- CVS-INFO file only present in CVS tree, never in release nor daily snapshot
+ archives. Used as a sentinel file in buildconf.bat to differentiate CVS builds.
+
+Gisle Vanem (8 Jun 2009)
+- Update comment about "ML". Removed "-D_USE_32BIT_TIME_T" (not a requirement).
+
+Yang Tse (8 Jun 2009)
+- just comment it out
+
+- For debugging purposes...
+
+ Disable the '-export-symbols-regex' to discard this as the origin
+ of link failures related with shared libraries and non-GNU linkers.
+
+- c-ares Makefile.am back to using $(top_builddir) for *_LDADD
+
+- c-ares' -no-undefined and --enable-curldebug adjustments
+
+- Use relative path to built c-ares tree libtool library
+
+- John E. Malmberg noticed that the configure script was failing to detect the
+ timeval struct on VMS when building with _XOPEN_SOURCE_EXTENDED undefined due
+ to definition taking place in socket.h instead of time.h
+
+- Fix compiler warning: out of bound access
+
+- fix compilation on AIX
+
+- c-ares' --enable-curldebug adjustments
+
+- Remove temporarily introduced memory leak.
+
+- Temporarily introduce a memory leak to verify curl debug memory tracking works.
+
+- Allow curl debug memory tracking when building a shared library on
+ systems which support external, undefined, symbols in shared libraries.
+
+Daniel Stenberg (26 May 2009)
+- language fix
+
+Yang Tse (26 May 2009)
+- Make ares_init(), ares_dup() and ares_init_options() return ARES_ENOTINITIALIZED
+ if library initialization has not been performed calling ares_library_init().
+
+- c-ares's --enable-curldebug configure option decoupled from c-ares's --enable-debug
+
+- Prevent copying 'sourced' manpages for build targets that don't use them.
+
+Daniel Stenberg (23 May 2009)
+- minor edits
+
+Yang Tse (21 May 2009)
+- Include .pdf versions of c-ares man pages in distribution tarball.
+
+- Allow generation of .html and .pdf versions of c-ares man pages.
+
+Gisle Vanem (21 May 2009)
+- $(OBJ_DIR)/ares_getopt.o must be cleaned explicitly.
+
+Yang Tse (20 May 2009)
+- Mention last changes
+
+- Initial ares_library_cleanup(3) man page
+
+- Update man page
+
+- Update man page
+
+- Initial ares_library_init(3) man page attempt
+
+- Force revision update, to force CVS to update the $Id date string format
+
+- Add same copyright notice as other c-ares files
+
+- Fix case
+
+- Remove run-time requirement for advapi32.dll since
+ c-ares can work even with no advapi32.dll at all.
+
+- Intentionally avoid checking if the address of SystemFunction036, a.k.a.
+ RtlGenRandom, has been located or not. This function is only available on
+ WinXP and later. When unavailable c-ares uses portable rand() function.
+
+- - Provide in external interface preprocessor symbol definitions for
+ CARES_HAVE_ARES_LIBRARY_INIT and CARES_HAVE_ARES_LIBRARY_CLEANUP
+ to ease the use of new capabilities.
+
+ - Move ares_version() prototype to ares.h
+
+- Introduction of ares_library_init() and ares_library_cleanup()
+
+- Introduction of ares_library_init() and ares_library_cleanup()
+
+- remove outdated comment
+
+- Fix preprocessor conditional expression
+
+- fiX *__SOCKLEN_T definitions for remaining targets
+
+- *__SOCKLEN_T definitions for OS400 already fixed
+
+- fIX *__SOCKLEN_T definitions for SYMBIAN32 and VMS targets
+
+Daniel Stenberg (11 May 2009)
+- - Gregor Jasny made c-ares link with libtool 's -export-symbols-regex option to
+ only expose functions starting with ares_.
+
+Yang Tse (11 May 2009)
+- Remove experimental check. Currently there's no need for it.
+
+- Fix an m4 overquoting triggering a spurious 'AS_TR_CPP' symbol definition
+ attempt in generated config.h
+
+- Proper naming for the experimental compiler test and moved to *-compilers.m4
+
+- Moved *_CHECK_COMPILER_HALT_ON_ERROR and *_CHECK_COMPILER_ARRAY_SIZE_NEGATIVE to *-compilers.m4 along with other *_CHECK_COMPILER_*
+
+- fIX *__SOCKLEN_T definitions for OS400 and generic GCC targets
+
+- fIX *__SOCKLEN_T definitions for MVS and 370 targets
+
+- fIX *__SOCKLEN_T definitions for several Windows target tool-chains
+
+- HP-UX's X/Open network library requirement check follow-up
+
+- HP-UX's X/Open network library requirement check follow-up
+
+- Use build-time configured ares_socklen_t instead of socklen_t
+
+- David McCreedy's "TPF-platform specific changes to various files" patch follow-up
+
+Daniel Stenberg (1 May 2009)
+- s/libcurl/c-ares
+
+- version number typo fix
+
+Yang Tse (1 May 2009)
+- David McCreedy's "TPF-platform specific changes to various files" patch
+
+- Check definition of _XOPEN_SOURCE_EXTENDED with the compiler
+
+- Check if X/Open network library is required
+
+- cope with ares_build.h and ares_rules.h follow-up
+
+- Added some notes regarding ares_build.h
+
+- fix EOL
+
+- fix EOL
+
+- cope with ares_build.h and ares_rules.h
+
+- buildconf.bat for CVS-tree c-ares
+
+- Use 'unsigned int' instead of size_t attempting to avoid header inclusion
+
+- NetWare LibC's getpeername() third argument data type is size_t
+
+- Remove temporary debug tracing for ares_socklen_t Windows targets
+
+- ares_socklen_t follow-up
+
+- ares_build.h Windows follow-up
+
+- Add temporary debug tracing for ares_socklen_t Windows targets
+
+- ares_build.h NetWare follow-up
+
+- ares_build.h NetWare attempt
+
+- Initial step towards a configure time ares_socklen_t definition
+
+- ignore stamp-h*
+
+- Added CARES_INCLUDES_SYS_TYPES
+
+- Initial step towards a configure time curl_socklen_t definition
+
+- avoid use of alloca()
+
+- 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.
+
+- ignore
+
+Gisle Vanem (18 Apr 2009)
+- Added '-DHAVE_LIMITS_H'.
+
+Yang Tse (17 Apr 2009)
+- remove compiler options used while debugging the icc 9.1 optimizer issue
+
+- moved HAVE_LIMITS_H to common defines
+
+- Set HP-UX compiler warning level back to the one that exposes
+ the socklen_t issue on this platform.
+
+- HAVE_LIMITS_H definition for NetWare CLIB
+
+- use HAVE_LIMITS_H symbol to protect limits.h inclusion
+
+- fix compiler warning: implicit conversion shortens 64-bit value into a 32-bit value
+
+- s/u_long/unsigned long/
+
+- Do not halt compilation when using VS2008 to build a Windows 2000 target
+
+- ignore
+
+Phil Blundell (3 Feb 2009)
+- * 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.
+
+Daniel Stenberg (31 Jan 2009)
+- - 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.
+
+Gisle Vanem (18 Jan 2009)
+- fopen() returns error in 'errno' even on Windows.
+ So don't use ERRNO (GetLastError()). Trimmed trailing
+ blanks.
+
+- Constified some arguments in local functions.
+
+Daniel Stenberg (14 Jan 2009)
+- - 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.
+
+Phil Blundell (13 Jan 2009)
+- - ares__send_query() now varies the retry timeout pseudo-randomly to avoid
+ packet storms when several queries were started at the same time.
+
+Daniel Stenberg (11 Jan 2009)
+- - 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.
+
+Gunter Knauf (30 Dec 2008)
+- added HAVE_SOCKADDR_IN6_SIN6_SCOPE_ID to ares Makefile.netware and sync'd with other Makefile.netware.
+
+Daniel Stenberg (9 Dec 2008)
+- use the new URL
+
+- start over on the 1.6.1 release...
+
+Version 1.6.0 (9 Dec 2008)
+
+Daniel Stenberg (9 Dec 2008)
+- add space
+
+Gisle Vanem (9 Dec 2008)
+- Fix for Win32 targets using Watt-32.
+
+Dan Fandrich (9 Dec 2008)
+- C89 compilers (like Minix' ACK) only need to handle 31 functions arguments
+ so split a long sprintf into two calls to get below that number.
+
+Gisle Vanem (8 Dec 2008)
+- Added needed defines for Watt-32 on Windows.
+
+- Undefine 'optarg', 'optind' and 'opterr' when using Watt-32
+ (to get correct linkage on Windows).
+
+- ares_writev() shall not be exported when using Watt-32 (has writev).
+ Added _USE_32BIT_TIME_T to avoid runtime warning. Applies to
+ VC-2008+ only.
+
+- Removed unneeded defines HAVE_SIGNAL_H, HAVE_SIG_ATOMIC_T,
+ RETSIGTYPE and HAVE_PROCESS_H.
+
+Daniel Stenberg (4 Dec 2008)
+- the initial version of the ares_set_socket_callback man page
+
+- Gregor Jasny provided the patch that introduces ares_set_socket_callback(),
+ and I edited it to also get duped by ares_dup().
+
+Dan Fandrich (4 Dec 2008)
+- Bring the sys/include.h include test in line with curl's.
+
+Daniel Stenberg (3 Dec 2008)
+- Let's not call ares_save_options() deprecated just yet
+
+- Introduce ares_dup(3) and new thoughts about API/ABI and how to move forwards.
+ Also discussed on the ml.
+
+Dan Fandrich (2 Dec 2008)
+- Make sure sys/socket.h is included before netinet/in.h (required by
+ OpenWatcom C, and condoned by SUS)
+
+Daniel Stenberg (1 Dec 2008)
+- minor indent fix
+
+- Convert the public config struct to the same binary size/construct as in the
+ latest releases to remain ABI compatible.
+
+Gisle Vanem (29 Nov 2008)
+- Added '-DHAVE_GETHOSTNAME'.
+
+Dan Fandrich (29 Nov 2008)
+- Make sure sys/socket.h is included before netinet/in.h (required by
+ OpenWatcom C)
+
+- Netware has gethostname()
+
+- Fixed a couple of typos
+
+- Don't tweak the HAVE_* macros when using autoconf
+
+- Make use of gethostname() conditional on it being available
+
+- Only set TCP_NODELAY when it exists
+
+Daniel Stenberg (28 Nov 2008)
+- updated with changes, preparing for a release soon
+
+Yang Tse (26 Nov 2008)
+- 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.
+
+- Brad Spencer provided changes to allow buildconf to work on OS X.
+
+- 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.
+
+Dan Fandrich (20 Nov 2008)
+- Make checking for struct ifreq a prerequisite for setting
+ HAVE_IOCTL_SIOCGIFADDR since it's needed to use SIOCGIFADDR and Watcom C
+ doesn't currently define it.
+
+Daniel Stenberg (20 Nov 2008)
+- use unsigned short better intead of mixing with ints to prevent compiler
+ warnings
+
+- please the picky compilers by staying with short as the data we get is short
+ only
+
+- - Brad Spencer brought the new function ares_gethostbyname_file() which simply
+ resolves a host name from the given file, using the regular hosts syntax.
+
+Yang Tse (19 Nov 2008)
+- user provided PATH_SEPARATOR always overrides auto-detected one
+
+- attempting to keep lines below 80 chars
+
+- provide a common PATH_SEPARATOR check method which is required by
+ upcomming work to support the broadest range of Autoconf versions
+
+- check for gethostbyaddr and gethostbyname as it is done for other functions
+
+- Make configure script check if ioctl with the SIOCGIFADDR command can be
+ used, and define HAVE_IOCTL_SIOCGIFADDR if appropriate.
+
+- fix leftover from previous commit
+
+- fix inet_pton() runtime configure check
+
+- trim down configure script size
+
+Daniel Stenberg (15 Nov 2008)
+- Fixed an OOM condition reported by Jim Meyering
+
+Yang Tse (14 Nov 2008)
+- fix typo affecting inclusion of <arpa/inet.h> in configure
+ checks for inet_ntoa_r() inet_ntop() and inet_pton()
+
+- #include <string.h> in the getaddrinfo() runtime check for the memset() prototype
+
+- fix symbol definition check for fcntl.h inclusion
+
+- Refactor configure script detection of functions used to set sockets into
+ non-blocking mode, and decouple function detection from function capability.
+
+Daniel Stenberg (1 Nov 2008)
+- Added a TODO file to list things we want changed, added or fixed.
+
+- - 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
+
+Yang Tse (1 Nov 2008)
+- Adjust WIN32 freeaddrinfo, getaddrinfo and getnameinfo availability
+
+- WIN32 availability of freeaddrinfo, getaddrinfo and getnameinfo functions is quite
+ convoluted, compiler dependant and in some cases even build target dependat.
+
+- check for freeaddrinfo() at configuration phase
+
+- update aclocal file serial number
+
+- remove verification of the freeability of the addrinfo struct pointer members
+
+- fix comment
+
+- make CHECK_FUNC_GETADDRINFO_UNFREEABLE_AI_ADDR
+ and CHECK_FUNC_GETADDRINFO_UNFREEABLE_AI_CANONNAME
+ internal to CHECK_FUNC_GETADDRINFO
+
+- fix leftover
+
+- Initial attempt to detect at configuration time if the getaddrinfo()
+ function returns an addrinfo with an unfreeable ai_canonname member ptr.
+
+- Initial attempt to detect at configuration time if the getaddrinfo()
+ function returns an addrinfo with an unfreeable ai_addr member ptr.
+
+- icc adjustments:
+
+ Select ANSI C89 dialect plus GNU extensions, again.
+
+- some more temporary magic for the icc seg-fault issue
+
+- icc permanent adjustment:
+
+ Select precise floating-point model, otherwise doubles are less than 64-bit wide
+
+ icc test adjustment:
+
+ Select c89 dialect
+
+- icc adjustments:
+
+ Enable more icc warnings.
+
+ Optimization disabling options used only for icc 9.1
+
+- #include <stdlib.h> for exit() prototype
+
+- some more temporary magic for the icc seg-fault issue
+
+- remove from configure.ac temporary magic for the icc seg-fault issue
+
+- some more temporary magic for the icc seg-fault issue
+
+- Charles Hardin patch:
+
+ - handles the EINPROGRESS for UDP connects
+ - uses closesocket instead of close on some paths that were noticed
+
+- some more temporary magic for the icc seg-fault issue
+
+- messages initially intended only for debug purposes, now become permanent
+ since these are extremely useful when compiler rejects a set of options.
+
+- fix compiler warning
+
+- fix missing double-quotes
+
+Daniel Stenberg (17 Oct 2008)
+- Charles Hardin made adig support a regular numerical dotted IP address for the
+ -s option as well.
+
+Yang Tse (16 Oct 2008)
+- some more temporary magic for the icc seg-fault issue
+
+- Ensure that shell variable contents which have active meaning
+ to the shell echo command are not interpreted when trying to
+ remove extra whitespace from shell variable content.
+
+- Adjust Watcom C warnings:
+
+ Disable warnings on structure members padding.
+
+- With this change Solaris target builds will now be done with _REENTRANT defined.
+
+- Adjust Tiny C basic options:
+
+ Remove -b from debug-enabled configuration, as Tiny C might have
+ been built without the memory and bounds checker support.
+
+- Adjust GCC warnings:
+
+ Better disable following warnings when cross-compiling with a gcc older
+ than 3.0, to avoid warnings from third party system headers:
+
+ -Wmissing-declarations
+ -Wmissing-prototypes
+ -Wunused
+ -Wshadow
+
+- fix syntax error
+
+- Initial attempt to detect Watcom C compiler
+
+- make naming scheme more consistent across whole file
+
+- Adjust GCC warnings:
+
+ Disable following warnings when cross-compiling with a gcc older
+ than 3.0, to avoid warnings from third party system headers:
+
+ -Wmissing-prototypes
+ -Wunused
+ -Wshadow
+
+- Adjust GCC --enable-warnings:
+
+ Do not enable -pedantic when cross-compiling with a gcc older
+ than 3.0, to avoid warnings from third party system headers.
+
+- adjust SGI MIPSpro C detection
+
+- LCC compiler adjustments:
+
+ Highest warning level is double -A, next is single -A.
+ Due to the big number of warnings these trigger on third
+ party header files it is impratical for us to use any of
+ them here. If you want them simply define it in CPPFLAGS.
+
+- remove extra space
+
+- split SGI compiler check. One for MIPS C and another for MIPSpro C
+
+- LCC compiler adjustments:
+
+ Warning level reduced from double -A to single -A
+
+- Initial attempt to detect Tiny C compiler
+
+- Initial attempt to detect LCC compiler
+
+- 1) fix bug in CONVERT_INCLUDE_TO_ISYSTEM
+
+ 2) Disable SGI remark: controlling expression is constant
+
+- simplify SGI C compiler check
+
+- HP C adjustments:
+
+ Due to the HP-UX socklen_t issue it is insane to use the +w1 warning level.
+ It generates more than 1100 warnings on socklen_t related statements.
+
+ Until the issue is somehow fixed we will just use the +w2 warning level.
+
+- Add debug tracing for COMPILER_WORKS_IFELSE
+
+- configure will also warn on 'strict compiler warning' rejected options
+
+- convert rejected compiler options messages into a warnings
+
+- remove extra whitespace from string in SGI C check
+
+- oops
+
+- Initial attempt to detect SGI C compiler
+
+- HP C adjustments:
+
+ Disallow run-time dereferencing of null pointers.
+
+ Disable some remarks:
+
+ #4227: padding struct with n bytes to align member.
+
+ #4255: padding size of struct with n bytes to alignment boundary.
+
+- improve presentation of accepted/rejected debug/optimizer options
+
+- refactoring of COMPILER_BASIC_OPTS
+
+- Initial attempt to detect SUN C compiler
+
+- Initial attempt to detect HP C compiler
+
+- fix compiler warning: 'dot_4' may be used uninitialized in this function
+
+- adjust ICC_windows settings
+
+- fix VAR_STRIP
+
+- Sync up with reality
+
+- Initial attempt to support configure's --(dis|en)able-optimize
+ option to specify dis(activation) of compiler optimizations.
+
+ If option is specified, it will be honored independant of the
+ --(dis|en)able-debug option.
+
+- fix comment
+
+- Initial attempt to support configure's --(dis|en)able-warnings
+ option to specify dis(activation) of picky compiler warnings.
+
+ If option is specified, it will be honored independant of the
+ --(dis|en)able-debug option.
+
+ If option is not specified, it will follow --(dis|en)able-debug
+ setting, whose default is disabled if not specified.
+
+- fix compiler warning: dereferencing type-punned pointer will break strict-aliasing rules
+
+- now compiler warnings are activated for all gcc builds, not only debug ones.
+
+- Use CFLAGS for icc linker options instead of LDFLAGS,
+ otherwise gethostbyname() is not detected.
+
+- use ac_cv_compiler and ac_cv_compiler_num to keep compiler ID and version number
+
+- Temporary icc adjustment:
+
+ Disable floating point optimizations
+
+- HAVE_INET_PTON will only be defined when an IPv6 capable working
+ inet_pton function is available.
+
+- HAVE_INET_NTOP will only be defined when an IPv6 capable working
+ inet_ntop function is available.
+
+- ntoa() and inet_ntoa_r() no longer used
+
+- icc adjustments for icc 9.0 and prior versions:
+
+ Disable remark #279: controlling expression is constant
+
+ Remark triggered mostly on va_arg() and FD_ZERO() macros.
+
+- attempt to make work the gethostname function
+ check for winsock build target configurations
+
+Gisle Vanem (21 Sep 2008)
+- Added HAVE_NETDB_H, HAVE_ARPA_INET_H, HAVE_STRCASECMP
+ and HAVE_STRNCASECMP.
+
+Yang Tse (19 Sep 2008)
+- icc adjustments:
+
+ Disable remark #981: operands are evaluated in unspecified order
+
+ Function calls which are triggering this remark, today, do not depend
+ on the order of evaluation of its arguments.
+
+ Disable remark #1469: "cc" clobber ignored
+
+ Remark triggered on htons() and ntohs() due to glibc header files.
+
+- icc adjustments
+
+- fix netdb.h prerequisite inclusion
+
+- improve detection of getservbyport_r()
+
+- On Linux Intel's icc uses gcc's header files, so
+ we select ANSI C89 dialect plus GNU extensions.
+
+- improve detection of gethostname()
+
+- NetWare builds include "nameser.h" from the c-ares subdir
+
+- include <strings.h>
+
+- Sync up with reality
+
+- adjust inclusion of "nameser.h"
+
+- reorder some lines in file
+
+- code cleanup
+
+- NetWare seems to have writev()
+
+- rearrange to allow internal/private use of ares_writev to any system
+ that lacks the writev function.
+
+- NetWare CLIB target has stricmp() and strnicmp()
+
+- include header file only when available
+
+- rearrange to allow internal/private use of ares_strcasecmp to any system that
+ lacks the strcasecmp function.
+
+- improve detection of:
+ strcasecmp()
+ strcmpi()
+ stricmp()
+ strncasecmp()
+ strncmpi()
+ strnicmp()
+
+- *** empty log message ***
+
+Gisle Vanem (12 Sep 2008)
+- djgpp does have strdup().
+
+Yang Tse (12 Sep 2008)
+- change CRLF into LF line endings
+
+- strdup() clone for systems/configurations which lack it
+
+- move inclusion of ares_private.h last
+
+- icc adjustments
+
+- icc adjustments
+
+- Select strict ANSI C89 conformance for icc
+
+- remove unnecessary typecasting of malloc()
+
+- remove unnecessary typecasting of realloc()
+
+Daniel Stenberg (29 Aug 2008)
+- we start over working towards 1.5.4
+
+Version 1.5.3 (29 Aug 2008)
+
+Daniel Stenberg (29 Aug 2008)
+- Version 1.5.3
+
+- added the three people from RELEASE-NOTES and sorted the list alphabetically
+
+Yang Tse (27 Aug 2008)
+- Don't abort configuration if recvfrom() is not available.
+
+- Functionality only possible if recvfrom() is available.
+
+- George Neill's fix acountry sample application compilation failure.
+
+- Brad House's validation that DNS response address matches the request address
+
+- fix the output name
+
+- Get rid of ENABLE_64BIT symbol definition and usage.
+
+ Improve HAVE_LONGLONG symbol description.
+
+- Export 'ares_process_fd' too.
+
+Gisle Vanem (16 Aug 2008)
+- Ops, remove 'use_vc'.
+
+- Support Watt-32 under Win32.
+
+Yang Tse (10 Aug 2008)
+- Fix: Remove now this SIZEOF_CURL_OFF_T symbol definition.
+
+ This should have been done with the initial 64-bit curl_off_t patch.
+
+- Improve CURL_CHECK_DEF
+
+- Fix IBM C and DEC/Compaq C compiler detection
+
+- Initial support of curlbuild.h and curlrules.h which allows
+ to have a curl_off_t data type no longer gated to off_t.
+
+- The minimum autoconf version required for this file is 2.50
+
+ Avoid dot notation in aclocal serial file number, use a single number now.
+
+Daniel Stenberg (4 Aug 2008)
+- - 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.
+
+Yang Tse (4 Aug 2008)
+- 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. But,
+ autoconf 2.62 version of AC_AIX defines _ALL_SOURCE along with other four
+ preprocessor symbols no matter if the system is AIX or not. To keep the
+ traditional behaviour, as well as an uniform one, across autoconf versions
+ AC_AIX is replaced with our own internal macro.
+
+- Adjust DEC/Compaq C compiler settings.
+
+- Another AC_TRY_LINK conversion to AC_LINK_IFELSE.
+ Proper definition of HAVE_function if function is found deeper.
+
+- Sync up with reality
+
+- Rename reentrant.m4 to avoid filename clash.
+
+- Add file version serial number that might be used by 'aclocal' and others.
+
+ Keep the '#' character as the first one on the line.
+
+- Update copyright year.
+
+- Sync comment with reality.
+
+- Reinstate the 'aclocal -I m4' in buildconf and 'ACLOCAL_AMFLAGS = -I m4' way of
+ including our local m4/reentrant.m4 file. This even takes care of including the
+ file in the distribution tarball.
+
+- Add quoting for the AC_DEFINE arguments.
+
+- Also remove the whitespace.
+
+- Also remove the extra quoting.
+
+- Replace some '@%:@' quadigraphs by its actual representation '#'.
+
+ This quadigraph used before a C preprocessor 'define' directive could
+ be fooling M4, when processing this file, and make it think that the
+ line contains a pure M4 'define' macro.
+
+- Tests done using 'aclocal -I m4' in buildconf and 'ACLOCAL_AMFLAGS = -I m4
+ in top Makefile.am triggered a problem that prevented aclocal from running
+ successfully on SunOS 5.10 with GNU m4 1.4.5 and GNU Autoconf 2.61
+
+ A tarball which reproduces mentioned problem is the one dated July-28-2008
+ http://cool.haxx.se/curl-daily/curl-7.19.0-20080728.tar.gz
+
+ We actually don't need all the bells and whistles that the above mechanism
+ provides. We only need to include our m4/reentrant.m4 file in acinclude.m4
+ so here we go with this simpler mechanism.
+
+- for debugging purposes show ACLOCAL_FLAGS
+
+- These lines were unintentionally removed in previous commit
+
+- Partially undo change that prevented SED, GREP, EGREP and AR from being changed by libtool or autoconf.
+
+- Assert that SED and GREP are set
+
+- Require autoconf 2.57 or newer
+
+- When calling aclocal, user defined ACLOCAL_FLAGS will now precede ours.
+
+- move ACLOCAL_AMFLAGS after AUTOMAKE_OPTIONS
+
+- setup.h handles definition of _REENTRANT based on NEED_REENTRANT
+ definition which might be defined in config.h or config-*.h files
+
+- Remove explicit inclusion of our m4 files first. It was interesting as a test,
+ but it breaks aclocal execution on some systems, with the following error:
+
+ Can't locate object method "rel2abs" via package "File::Spec" at /usr/local/bin/aclocal line 256.
+
+- Another step towards detecting if _REENTRANT is already defined or actually
+ needed, and being able to define it if appropriate for further configure tests
+ as well as for the generated config file.
+
+- Explicitly include our m4 files first. This might minimize the impact
+ that other package's underquoted m4 function definitions have on ours.
+
+- Add a 3 argument check for getprotobyname_r
diff --git a/CHANGES.0 b/CHANGES.0
deleted file mode 100644
index 73fe8c7..0000000
--- a/CHANGES.0
+++ /dev/null
@@ -1,1218 +0,0 @@
- 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
diff --git a/GIT-INFO b/GIT-INFO
deleted file mode 100644
index f7dc55a..0000000
--- a/GIT-INFO
+++ /dev/null
@@ -1,9 +0,0 @@
-
-GIT-INFO
-
-This file is only present in git - never in release archives. It is used as a
-sentinel file in buildconf.bat in order to differentiate a git checkout from
-release and daily snapshot archives.
-
-On *nix-like systems, run the ./buildconf script first to generate a fresh
-configure script.
diff --git a/INSTALL b/INSTALL
index 4db2baf..c78487d 100644
--- a/INSTALL
+++ b/INSTALL
@@ -321,7 +321,7 @@ PORTS
Useful URLs
===========
-c-ares http://c-ares.haxx.se/
+c-ares https://c-ares.haxx.se/
MingW http://www.mingw.org/
MinGW-w64 http://mingw-w64.sourceforge.net/
diff --git a/LICENSE b/LICENSE.md
index e3f5b64..86b520b 100644
--- a/LICENSE
+++ b/LICENSE.md
@@ -1,3 +1,8 @@
+# c-ares license
+
+Copyright (c) 2007 - 2016, Daniel Stenberg with many contributors, see AUTHORS
+file.
+
Copyright 1998 by the Massachusetts Institute of Technology.
Permission to use, copy, modify, and distribute this software and its
diff --git a/LICENSE.mit b/LICENSE.mit
deleted file mode 100644
index c6e52bc..0000000
--- a/LICENSE.mit
+++ /dev/null
@@ -1,21 +0,0 @@
-COPYRIGHT AND PERMISSION NOTICE
-
-Copyright (c)
-
-All rights reserved.
-
-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", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN
-NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
-DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
-OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
-OR OTHER DEALINGS IN THE SOFTWARE.
-
-Except as contained in this notice, the name of a copyright holder shall not
-be used in advertising or otherwise to promote the sale, use or other dealings
-in this Software without prior written authorization of the copyright holder.
diff --git a/Makefile.am b/Makefile.am
index 23059a1..d49d445 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -55,16 +55,19 @@ EXTRA_DIST = AUTHORS CHANGES README.cares Makefile.inc Makefile.dj \
Makefile.m32 Makefile.netware Makefile.msvc Makefile.Watcom $(man_MANS) \
config-win32.h RELEASE-NOTES libcares.pc.in buildconf get_ver.awk maketgz \
TODO ares_build.h.in $(PDFPAGES) cares.rc README.msvc $(MSVCFILES) \
- $(CSOURCES) $(HHEADERS) config-dos.h acountry.1 adig.1 ahost.1 INSTALL
+ $(CSOURCES) $(HHEADERS) config-dos.h acountry.1 adig.1 ahost.1 INSTALL \
+ README.md LICENSE.md
CLEANFILES = $(PDFPAGES) $(HTMLPAGES)
DISTCLEANFILES = ares_build.h
+#DIST_SUBDIRS = test
+
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = libcares.pc
-CARES_VERSION_INFO = -version-info 3:0:1
+CARES_VERSION_INFO = -version-info 4:0:2
# This flag accepts an argument of the form current[:revision[:age]]. So,
# passing -version-info 3:12:1 sets current to 3, revision to 12, and age to
# 1.
@@ -127,6 +130,10 @@ libcares_la_CFLAGS_EXTRA += $(CFLAG_CARES_SYMBOL_HIDING)
libcares_la_CPPFLAGS_EXTRA += -DCARES_SYMBOL_HIDING
endif
+@CODE_COVERAGE_RULES@
+libcares_la_LDFLAGS += $(CODE_COVERAGE_LDFLAGS)
+libcares_la_CFLAGS_EXTRA += $(CODE_COVERAGE_CFLAGS)
+
libcares_la_CFLAGS = $(AM_CFLAGS) $(libcares_la_CFLAGS_EXTRA)
libcares_la_CPPFLAGS = $(AM_CPPFLAGS) $(libcares_la_CPPFLAGS_EXTRA)
diff --git a/Makefile.dj b/Makefile.dj
index 799611f..f891f7f 100644
--- a/Makefile.dj
+++ b/Makefile.dj
@@ -1,6 +1,6 @@
#
# c-ares Makefile for djgpp/gcc/Watt-32.
-# By Gisle Vanem <gvanem@broadpark.no> 2004.
+# By Gisle Vanem <gvanem@yahoo.no> 2004.
#
diff --git a/Makefile.inc b/Makefile.inc
index c38c921..22580b7 100644
--- a/Makefile.inc
+++ b/Makefile.inc
@@ -82,6 +82,7 @@ MANPAGES = ares_cancel.3 \
ares_free_hostent.3 \
ares_free_string.3 \
ares_get_servers.3 \
+ ares_get_servers_ports.3 \
ares_gethostbyaddr.3 \
ares_gethostbyname.3 \
ares_gethostbyname_file.3 \
@@ -107,8 +108,16 @@ MANPAGES = ares_cancel.3 \
ares_save_options.3 \
ares_search.3 \
ares_send.3 \
+ ares_set_local_dev.3 \
+ ares_set_local_ip4.3 \
+ ares_set_local_ip6.3 \
ares_set_servers.3 \
+ ares_set_servers_csv.3 \
+ ares_set_servers_ports.3 \
+ ares_set_servers_ports_csv.3 \
ares_set_socket_callback.3 \
+ ares_set_socket_configure_callback.3 \
+ ares_set_sortlist.3 \
ares_strerror.3 \
ares_timeout.3 \
ares_version.3 \
@@ -126,6 +135,7 @@ HTMLPAGES = ares_cancel.html \
ares_free_hostent.html \
ares_free_string.html \
ares_get_servers.html \
+ ares_get_servers_ports.html \
ares_gethostbyaddr.html \
ares_gethostbyname.html \
ares_gethostbyname_file.html \
@@ -150,8 +160,16 @@ HTMLPAGES = ares_cancel.html \
ares_save_options.html \
ares_search.html \
ares_send.html \
+ ares_set_local_dev.html \
+ ares_set_local_ip4.html \
+ ares_set_local_ip6.html \
ares_set_servers.html \
+ ares_set_servers_csv.html \
+ ares_set_servers_ports.html \
+ ares_set_servers_ports_csv.html \
ares_set_socket_callback.html \
+ ares_set_socket_configure_callback.html \
+ ares_set_sortlist.html \
ares_strerror.html \
ares_timeout.html \
ares_version.html \
@@ -169,6 +187,7 @@ PDFPAGES = ares_cancel.pdf \
ares_free_hostent.pdf \
ares_free_string.pdf \
ares_get_servers.pdf \
+ ares_get_servers_ports.pdf \
ares_gethostbyaddr.pdf \
ares_gethostbyname.pdf \
ares_gethostbyname_file.pdf \
@@ -193,8 +212,16 @@ PDFPAGES = ares_cancel.pdf \
ares_save_options.pdf \
ares_search.pdf \
ares_send.pdf \
+ ares_set_local_dev.pdf \
+ ares_set_local_ip4.pdf \
+ ares_set_local_ip6.pdf \
ares_set_servers.pdf \
+ ares_set_servers_csv.pdf \
+ ares_set_servers_ports.pdf \
+ ares_set_servers_ports_csv.pdf \
ares_set_socket_callback.pdf \
+ ares_set_socket_configure_callback.pdf \
+ ares_set_sortlist.pdf \
ares_strerror.pdf \
ares_timeout.pdf \
ares_version.pdf \
diff --git a/Makefile.m32 b/Makefile.m32
index 42149f5..c27a597 100644
--- a/Makefile.m32
+++ b/Makefile.m32
@@ -10,16 +10,16 @@
LIB = libcares.a
-AR = ar
-CC = gcc
-LD = gcc
-RANLIB = ranlib
+AR = $(CROSSPREFIX)ar
+CC = $(CROSSPREFIX)gcc
+LD = $(CROSSPREFIX)gcc
+RANLIB = $(CROSSPREFIX)ranlib
#RM = rm -f
CP = cp -afv
-CFLAGS = -O2 -Wall -I.
+CFLAGS = $(CARES_CFLAG_EXTRAS) -O2 -Wall -I.
CFLAGS += -DCARES_STATICLIB
-LDFLAGS = -s
+LDFLAGS = $(CARES_LDFLAG_EXTRAS) -s
LIBS = -lwsock32
# Makefile.inc provides the CSOURCES and HHEADERS defines
@@ -74,4 +74,3 @@ distclean: clean
ifeq "$(wildcard ares_build.h.dist)" "ares_build.h.dist"
$(RM) ares_build.h
endif
-
diff --git a/Makefile.msvc b/Makefile.msvc
index c83dd91..e05e317 100644
--- a/Makefile.msvc
+++ b/Makefile.msvc
@@ -18,12 +18,12 @@
# Makefile for building c-ares libraries and sample programs with MSVC.
#
# Usage: nmake /f makefile.msvc CFG=<config> <target>
-#
+#
# <config> must be one of: [ lib-release | lib-debug | dll-release | dll-debug }
# <target> must be one of: [ ALL | c-ares | acountry | adig | ahost | clean }
-#
+#
# If a <target> other than ALL or clean is given, <config> becomes mandatory.
-#
+#
# If neither <config> nor <target> are specified this results in
# all targets being built for all <config> c-ares library types.
#
@@ -71,68 +71,10 @@ RTLIBD = /MTd
USE_WATT32 = 0
-# -------------------------------------------
-# Detect NMAKE version deducing MSVC version
-# -------------------------------------------
-
-!IFNDEF _NMAKE_VER
-! MESSAGE Macro _NMAKE_VER not defined.
-! MESSAGE Use MSVC's NMAKE to process this makefile.
-! ERROR See previous message.
-!ENDIF
-
-!IF "$(_NMAKE_VER)" == "6.00.8168.0"
-CC_VERS_NUM = 60
-!ELSEIF "$(_NMAKE_VER)" == "6.00.9782.0"
-CC_VERS_NUM = 60
-!ELSEIF "$(_NMAKE_VER)" == "7.00.8882"
-CC_VERS_NUM = 70
-!ELSEIF "$(_NMAKE_VER)" == "7.00.9466"
-CC_VERS_NUM = 70
-!ELSEIF "$(_NMAKE_VER)" == "7.00.9955"
-CC_VERS_NUM = 70
-!ELSEIF "$(_NMAKE_VER)" == "7.10.2240.8"
-CC_VERS_NUM = 71
-!ELSEIF "$(_NMAKE_VER)" == "7.10.3077"
-CC_VERS_NUM = 71
-!ELSEIF "$(_NMAKE_VER)" == "8.00.40607.16"
-CC_VERS_NUM = 80
-!ELSEIF "$(_NMAKE_VER)" == "8.00.50727.42"
-CC_VERS_NUM = 80
-!ELSEIF "$(_NMAKE_VER)" == "8.00.50727.762"
-CC_VERS_NUM = 80
-!ELSEIF "$(_NMAKE_VER)" == "9.00.20706.01"
-CC_VERS_NUM = 90
-!ELSEIF "$(_NMAKE_VER)" == "9.00.21022.08"
-CC_VERS_NUM = 90
-!ELSEIF "$(_NMAKE_VER)" == "9.00.30729.01"
-CC_VERS_NUM = 90
-!ELSEIF "$(_NMAKE_VER)" == "10.00.20506.01"
-CC_VERS_NUM = 100
-!ELSEIF "$(_NMAKE_VER)" == "10.00.21003.01"
-CC_VERS_NUM = 100
-!ELSEIF "$(_NMAKE_VER)" == "10.00.30128.01"
-CC_VERS_NUM = 100
-!ELSEIF "$(_NMAKE_VER)" == "10.00.30319.01"
-CC_VERS_NUM = 100
-!ELSEIF "$(_NMAKE_VER)" == "10.00.40219.01"
-CC_VERS_NUM = 100
-!ELSEIF "$(_NMAKE_VER)" == "11.00.50522.1"
-CC_VERS_NUM = 110
-!ELSEIF "$(_NMAKE_VER)" == "11.00.50727.1"
-CC_VERS_NUM = 110
-!ELSEIF "$(_NMAKE_VER)" == "11.00.51106.1"
-CC_VERS_NUM = 110
-!ELSEIF "$(_NMAKE_VER)" == "11.00.60315.1"
-CC_VERS_NUM = 110
-!ELSE
-! MESSAGE Unknown value for _NMAKE_VER macro: "$(_NMAKE_VER)"
-! MESSAGE Please, report this condition on the c-ares development
-! MESSAGE mailing list: http://cool.haxx.se/mailman/listinfo/c-ares/
-! ERROR See previous message.
-!ENDIF
-
-CC_VERS_STR = msvc$(CC_VERS_NUM)
+# --------------------------------------------------------
+# Detect compiler version.
+# --------------------------------------------------------
+!INCLUDE .\msvc_ver.inc
# ----------------------------------------------------
# Verify that current subdir is the c-ares source one
diff --git a/Makefile.netware b/Makefile.netware
index 653efb0..fa8f831 100644
--- a/Makefile.netware
+++ b/Makefile.netware
@@ -306,7 +306,6 @@ ifeq ($(LIBARCH),CLIB)
@echo $(DL)#define SEND_TYPE_ARG3 int$(DL) >> $@
@echo $(DL)#define SEND_TYPE_ARG4 int$(DL) >> $@
@echo $(DL)#define SEND_TYPE_RETV int$(DL) >> $@
- @echo $(DL)#define SIZEOF_SIZE_T 4$(DL) >> $@
else
@echo $(DL)#define OS "i586-pc-libc-NetWare"$(DL) >> $@
@echo $(DL)#define HAVE_DLFCN_H 1$(DL) >> $@
@@ -349,8 +348,6 @@ else
@echo $(DL)#define SEND_TYPE_ARG3 size_t$(DL) >> $@
@echo $(DL)#define SEND_TYPE_ARG4 int$(DL) >> $@
@echo $(DL)#define SEND_TYPE_RETV ssize_t$(DL) >> $@
- @echo $(DL)#define SIZEOF_SIZE_T 8$(DL) >> $@
- @echo $(DL)#define SIZEOF_STRUCT_IN6_ADDR 16$(DL) >> $@
endif
@echo $(DL)#define HAVE_ARPA_INET_H 1$(DL) >> $@
@echo $(DL)#define HAVE_ASSERT_H 1$(DL) >> $@
@@ -397,9 +394,6 @@ endif
@echo $(DL)#define HAVE_UTIME_H 1$(DL) >> $@
@echo $(DL)#define HAVE_WRITEV 1$(DL) >> $@
@echo $(DL)#define RETSIGTYPE void$(DL) >> $@
- @echo $(DL)#define SIZEOF_INT 4$(DL) >> $@
- @echo $(DL)#define SIZEOF_SHORT 2$(DL) >> $@
- @echo $(DL)#define SIZEOF_STRUCT_IN_ADDR 4$(DL) >> $@
@echo $(DL)#define STDC_HEADERS 1$(DL) >> $@
@echo $(DL)#define TIME_WITH_SYS_TIME 1$(DL) >> $@
ifdef NW_WINSOCK
@@ -431,11 +425,8 @@ ares_build.h: Makefile.netware FORCE
@echo $(DL)#define __CARES_BUILD_H$(DL) >> $@
ifeq ($(LIBARCH),CLIB)
@echo $(DL)#define CARES_TYPEOF_ARES_SOCKLEN_T int$(DL) >> $@
- @echo $(DL)#define CARES_SIZEOF_ARES_SOCKLEN_T 4$(DL) >> $@
else
@echo $(DL)#define CARES_TYPEOF_ARES_SOCKLEN_T unsigned int$(DL) >> $@
- @echo $(DL)#define CARES_SIZEOF_ARES_SOCKLEN_T 4$(DL) >> $@
endif
- @echo $(DL)#define CARES_SIZEOF_LONG 4$(DL) >> $@
@echo $(DL)typedef CARES_TYPEOF_ARES_SOCKLEN_T ares_socklen_t;$(DL) >> $@
@echo $(DL)#endif /* __CARES_BUILD_H */$(DL) >> $@
diff --git a/README.cares b/README.cares
index aca54c8..4dee46e 100644
--- a/README.cares
+++ b/README.cares
@@ -1,13 +1,15 @@
c-ares
======
-This package is based on ares 1.1.1 (written by Greg Hudson). I decided to
-fork and release a separate project since the ares author didn't want the
-improvements that were vital for our use of it.
+This package is based on ares 1.1.1 (written by Greg Hudson). Daniel Stenberg
+decided to fork and release a separate project since the original ares author
+didn't want the improvements that were vital for our use of it.
-This package is dubbed 'c-ares' since I (Daniel Stenberg) wanted this for use
-within the curl project (hence the letter C) and it makes a nice pun. Also,
-c-ares is not API compatible with ares: a new name makes that more obvious to
-the public.
+This package is dubbed 'c-ares' since Daniel wanted this for use within the
+curl project (hence the letter C) and it makes a nice pun. c-ares is not API
+compatible with ares: a new name makes that more obvious to the public.
-The original libares was distributed at athena-dist.mit.edu:pub/ATHENA/ares.
+The original libares was distributed at
+ftp://athena-dist.mit.edu:pub/ATHENA/ares (which seems to not be alive
+anymore). A local copy of the original ares package is kept here:
+https://c-ares.haxx.se/download/ares-1.1.1.tar.gz
diff --git a/README b/README.md
index 2c128c8..fdf3a71 100644
--- a/README
+++ b/README.md
@@ -1,6 +1,11 @@
c-ares
======
+[![Build Status](https://travis-ci.org/c-ares/c-ares.svg?branch=master)](https://travis-ci.org/c-ares/c-ares)
+[![Windows Build Status](https://ci.appveyor.com/api/projects/status/03i7151772eq3wn3/branch/master?svg=true)](https://ci.appveyor.com/project/c-ares/c-ares)
+[![Coverage Status](https://coveralls.io/repos/c-ares/c-ares/badge.svg?branch=master&service=github)](https://coveralls.io/github/c-ares/c-ares?branch=master)
+[![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/291/badge)](https://bestpractices.coreinfrastructure.org/projects/291)
+
This is c-ares, an asynchronous resolver library. It is intended for
applications which need to perform DNS queries without blocking, or need to
perform multiple DNS queries in parallel. The primary examples of such
@@ -8,7 +13,7 @@ applications are servers which communicate with multiple clients and programs
with graphical user interfaces.
The full source code is available in the 'c-ares' release archives, and in a
-git repository: http://github.com/bagder/c-ares
+git repository: http://github.com/c-ares/c-ares
If you find bugs, correct flaws, have questions or have comments in general in
regard to c-ares (or by all means the original ares too), get in touch with us
@@ -18,34 +23,34 @@ c-ares is of course distributed under the same MIT-style license as the
original ares.
You'll find all c-ares details and news here:
-
- http://c-ares.haxx.se/
+ https://c-ares.haxx.se/
-NOTES FOR C-ARES HACKERS
+Notes for c-ares hackers
+------------------------
-* The distributed ares_build.h file is only intended to be used on systems
+* The distributed `ares_build.h` file is only intended to be used on systems
which can not run the also distributed configure script.
-* The distributed ares_build.h file is generated as a copy of ares_build.h.dist
+* The distributed `ares_build.h` file is generated as a copy of `ares_build.h.dist`
when the c-ares source code distribution archive file is originally created.
* If you check out from git on a non-configure platform, you must run the
- appropriate buildconf* script to set up ares_build.h and other local files
- before being able of compiling the library.
+ appropriate `buildconf*` script to set up `ares_build.h` and other local files
+ before being able to compile the library.
-* On systems capable of running the configure script, the configure process
- will overwrite the distributed ares_build.h file with one that is suitable
+* On systems capable of running the `configure` script, the `configure` process
+ will overwrite the distributed `ares_build.h` file with one that is suitable
and specific to the library being configured and built, this new file is
- generated from the ares_build.h.in template file.
+ generated from the `ares_build.h.in` template file.
-* If you intend to distribute an already compiled c-ares library you _MUST_
- also distribute along with it the generated ares_build.h which has been
+* If you intend to distribute an already compiled c-ares library you **MUST**
+ also distribute along with it the generated `ares_build.h` which has been
used to compile it. Otherwise the library will be of no use for the users of
- the library that you have built. It is _your_ responsibility to provide this
+ the library that you have built. It is **your** responsibility to provide this
file. No one at the c-ares project can know how you have built the library.
-* File ares_build.h includes platform and configuration dependent info,
+* File `ares_build.h` includes platform and configuration dependent info,
and must not be modified by anyone. Configure script generates it for you.
* We cannot assume anything else but very basic compiler features being
@@ -56,3 +61,4 @@ NOTES FOR C-ARES HACKERS
* Comments must be written in the old-style /* unnested C-fashion */
+* Try to keep line lengths below 80 columns.
diff --git a/RELEASE-NOTES b/RELEASE-NOTES
index 1f3f0ef..dffb023 100644
--- a/RELEASE-NOTES
+++ b/RELEASE-NOTES
@@ -1,35 +1,46 @@
-c-ares version 1.10.0
+c-ares version 1.12.0
Changes:
- o Added ares_create_query(), to be used instead of ares_mkquery()
- o ares_inet_ntop() and ares_inet_pton() are now recognized c-ares functions
-
+ o api: add ARES_OPT_NOROTATE optmask value
+
Bug fixes:
- o include the ares_parse_soa_reply.* files in the tarball
- o read_udp_packets: bail out loop on bad sockets
- o get_DNS_AdaptersAddresses: fix IPv6 parsing
- o adig: perror() doesn't work for socket errors on windows
- o ares_parse_aaaa_reply: fix memory leak
- o setup_once.h: HP-UX <sys/socket.h> issue workaround
- o configure: several fixes
- o config-dos.h: define strerror() to strerror_s_() for High-C
- o config-dos.h: define HAVE_CLOSE_S for MSDOS/Watt-32
- o ares_build.h.dist: enhance non-configure GCC ABI detection logic
- o ares.h: stricter CARES_EXTERN linkage decorations logic
- o ares_cancel(): cancel requests safely
- o protocol parsing: check input data stricter
- o library init: be recursive, reference count inits/cleanups
- o ares_parse_txt_reply: return a ares_txt_reply node for each sub-string
- o ares_set_servers_csv: fixed IPv6 address parsing
- o build: fix build on msvc11
+ o CVE-2016-5180: ares_create_query single byte out of buffer write [4]
+ o configure: acknowledge --disable-tests [1]
+ o man pages: fix typos detected by Lintian
+ o test: add missing #includes for dns-proto.cc
+ o test: avoid in6addr_* constants
+ o test: Build with MinGW on AppVeyor
+ o Makefile.m32: add support for extra flags
+ o Makefile.m32: add support for CROSSPREFIX
+ o configure: check if tests can get built before enabled
+ o ares_library_cleanup: reset ares_realloc too
+ o ahost.c: add cast to fix C++ compile
+ o test: Only pass unused args to GoogleTest
+ o build: commonize MSVC version detection
+ o msvc_ver.inc: support Visual Studio 2015 Update 1, 2, 3
+ o test: for AF_UNSPEC, return CNAME only for AAAA, but valid A record
+ o ares_getnameinfo: explicitly clear struct servent before use
+ o test: Update fuzzing function prototype
+ o init: fix nsort initialization
+ o test: add fuzzing check script to tests
+ o web: http => https
+ o read_tcp_data: remove superfluous NULL check
+ o LICENSE.md: add a stand-alone license file
+ o SECURITY.md: suggested "security process" for the project
+ o ares_init_options: only propagate init failures from options [2]
+ o headers: remove checks for and defines of variable sizes
+ o test: fix gMock to work with gcc >= 6.x [3]
Thanks go to these friendly people for their efforts and contributions:
- Eugeny Gladkih, Yang Tse, Gisle Vanem, Guenter Knauf, Horatiu Popescu,
- Alexander Klauer, Patrick Valsecchi, Paul Saab, Keith Shaw,
- Alex Loukissas
-
+ Alexander Drachevskiy, Brad House, Chris Araman, Daniel Stenberg,
+ David Drysdale, Gregor Jasny, Svante Karlsson, Viktor Szakats
+
+References to bug reports and discussions on issues:
-Have fun!
+ [1] = https://github.com/c-ares/c-ares/issues/44
+ [2] = https://github.com/c-ares/c-ares/issues/60
+ [3] = https://github.com/google/googletest/issues/705#issuecomment-235067917
+ [4] = https://c-ares.haxx.se/adv_20160929.html
diff --git a/acinclude.m4 b/acinclude.m4
index ec7b0b2..c255198 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -1743,24 +1743,6 @@ cat >>confdefs.h <<_EOF
_EOF
])
-
-dnl CARES_CONFIGURE_LONG
-dnl -------------------------------------------------
-dnl Find out the size of long as reported by sizeof() and define
-dnl CARES_SIZEOF_LONG as appropriate to be used in template file
-dnl ares_build.h.in to properly configure the library.
-dnl The size of long is a build time characteristic and as such
-dnl must be recorded in ares_build.h
-
-AC_DEFUN([CARES_CONFIGURE_LONG], [
- if test -z "$ac_cv_sizeof_long" ||
- test "$ac_cv_sizeof_long" -eq "0"; then
- AC_MSG_ERROR([cannot find out size of long.])
- fi
- CARES_DEFINE_UNQUOTED([CARES_SIZEOF_LONG], [$ac_cv_sizeof_long])
-])
-
-
dnl CARES_CONFIGURE_ARES_SOCKLEN_T
dnl -------------------------------------------------
dnl Find out suitable ares_socklen_t data type definition and size, making
diff --git a/acountry.c b/acountry.c
index 210ef84..aea22c8 100644
--- a/acountry.c
+++ b/acountry.c
@@ -15,7 +15,7 @@
*
* Ref: http://countries.nerd.dk/more.html
*
- * Written by G. Vanem <gvanem@broadpark.no> 2006, 2007
+ * Written by G. Vanem <gvanem@yahoo.no> 2006, 2007
*
* NB! This program may not be big-endian aware.
*
@@ -71,8 +71,8 @@
static const char *usage = "acountry [-vh?] {host|addr} ...\n";
static const char nerd_fmt[] = "%u.%u.%u.%u.zz.countries.nerd.dk";
-static const char *nerd_ver1 = nerd_fmt + 14;
-static const char *nerd_ver2 = nerd_fmt + 11;
+static const char *nerd_ver1 = nerd_fmt + 14; /* .countries.nerd.dk */
+static const char *nerd_ver2 = nerd_fmt + 11; /* .zz.countries.nerd.dk */
static int verbose = 0;
#define TRACE(fmt) do { \
@@ -200,7 +200,9 @@ static void wait_ares(ares_channel channel)
if (nfds == 0)
break;
tvp = ares_timeout(channel, NULL, &tv);
- select(nfds, &read_fds, &write_fds, NULL, tvp);
+ nfds = select(nfds, &read_fds, &write_fds, NULL, tvp);
+ if (nfds < 0)
+ continue;
ares_process(channel, &read_fds, &write_fds);
}
}
@@ -559,9 +561,10 @@ static void find_country_from_cname(const char *cname, struct in_addr addr)
if (ver_1)
{
const char *dot = strchr(cname, '.');
- if ((z0 != 'z' && z1 != 'z') || dot != cname+4)
+ if (dot != cname+4)
{
printf("Unexpected CNAME %s (ver_1)\n", cname);
+ free(ccopy);
return;
}
}
@@ -572,12 +575,14 @@ static void find_country_from_cname(const char *cname, struct in_addr addr)
if (z0 != 'z' && z1 != 'z')
{
printf("Unexpected CNAME %s (ver_2)\n", cname);
+ free(ccopy);
return;
}
}
else
{
printf("Unexpected CNAME %s (ver?)\n", cname);
+ free(ccopy);
return;
}
@@ -614,4 +619,3 @@ static void find_country_from_cname(const char *cname, struct in_addr addr)
}
free(ccopy);
}
-
diff --git a/ahost.1 b/ahost.1
index 892e9e1..c83cfcf 100644
--- a/ahost.1
+++ b/ahost.1
@@ -21,8 +21,18 @@ Print some extra debugging output.
Display this help and exit.
.TP
\fB\-t\fR type
-If type is "aa", print the A record (default).
+If type is "a", print the A record (default).
If type is "aaaa", print the AAAA record.
+If type is "u", look for either AAAA or A record (in that order).
+.TP
+\fB\-s\fR \fIdomain\fP
+Specify the \fIdomain\fP to search instead of using the default values from
+.br
+/etc/resolv.conf. This option only has an effect on platforms that use
+.br
+/etc/resolv.conf
+for DNS configuration; it has no effect on other platforms (such as Win32
+or Android).
.SH "REPORTING BUGS"
Report bugs to the c-ares mailing list:
\fBhttp://cool.haxx.se/mailman/listinfo/c-ares\fR
diff --git a/ahost.c b/ahost.c
index fd6e50d..7fbfd64 100644
--- a/ahost.c
+++ b/ahost.c
@@ -52,6 +52,8 @@ static void usage(void);
int main(int argc, char **argv)
{
+ struct ares_options options;
+ int optmask = 0;
ares_channel channel;
int status, nfds, c, addr_family = AF_INET;
fd_set read_fds, write_fds;
@@ -65,6 +67,8 @@ int main(int argc, char **argv)
WSAStartup(wVersionRequested, &wsaData);
#endif
+ memset(&options, 0, sizeof(options));
+
status = ares_library_init(ARES_LIB_INIT_ALL);
if (status != ARES_SUCCESS)
{
@@ -72,7 +76,7 @@ int main(int argc, char **argv)
return 1;
}
- while ((c = ares_getopt(argc,argv,"dt:h")) != -1)
+ while ((c = ares_getopt(argc,argv,"dt:hs:")) != -1)
{
switch (c)
{
@@ -81,11 +85,20 @@ int main(int argc, char **argv)
dbug_init();
#endif
break;
+ case 's':
+ optmask |= ARES_OPT_DOMAINS;
+ options.ndomains++;
+ options.domains = (char **)realloc(options.domains,
+ options.ndomains * sizeof(char *));
+ options.domains[options.ndomains - 1] = strdup(optarg);
+ break;
case 't':
if (!strcasecmp(optarg,"a"))
addr_family = AF_INET;
else if (!strcasecmp(optarg,"aaaa"))
addr_family = AF_INET6;
+ else if (!strcasecmp(optarg,"u"))
+ addr_family = AF_UNSPEC;
else
usage();
break;
@@ -101,7 +114,7 @@ int main(int argc, char **argv)
if (argc < 1)
usage();
- status = ares_init(&channel);
+ status = ares_init_options(&channel, &options, optmask);
if (status != ARES_SUCCESS)
{
fprintf(stderr, "ares_init: %s\n", ares_strerror(status));
@@ -130,13 +143,16 @@ int main(int argc, char **argv)
/* Wait for all queries to complete. */
for (;;)
{
+ int res;
FD_ZERO(&read_fds);
FD_ZERO(&write_fds);
nfds = ares_fds(channel, &read_fds, &write_fds);
if (nfds == 0)
break;
tvp = ares_timeout(channel, NULL, &tv);
- select(nfds, &read_fds, &write_fds, NULL, tvp);
+ res = select(nfds, &read_fds, &write_fds, NULL, tvp);
+ if (-1 == res)
+ break;
ares_process(channel, &read_fds, &write_fds);
}
@@ -185,6 +201,6 @@ static void callback(void *arg, int status, int timeouts, struct hostent *host)
static void usage(void)
{
- fprintf(stderr, "usage: ahost [-t {a|aaaa}] {host|addr} ...\n");
+ fprintf(stderr, "usage: ahost [-t {a|aaaa|u}] {host|addr} ...\n");
exit(1);
}
diff --git a/ares.h b/ares.h
index 9b3f376..cbd30f6 100644
--- a/ares.h
+++ b/ares.h
@@ -158,6 +158,7 @@ extern "C" {
#define ARES_OPT_TIMEOUTMS (1 << 13)
#define ARES_OPT_ROTATE (1 << 14)
#define ARES_OPT_EDNSPSZ (1 << 15)
+#define ARES_OPT_NOROTATE (1 << 16)
/* Nameinfo flag values */
#define ARES_NI_NOFQDN (1 << 0)
@@ -294,8 +295,19 @@ typedef int (*ares_sock_create_callback)(ares_socket_t socket_fd,
int type,
void *data);
+typedef int (*ares_sock_config_callback)(ares_socket_t socket_fd,
+ int type,
+ void *data);
+
CARES_EXTERN int ares_library_init(int flags);
+CARES_EXTERN int ares_library_init_mem(int flags,
+ void *(*amalloc)(size_t size),
+ void (*afree)(void *ptr),
+ void *(*arealloc)(void *ptr, size_t size));
+
+CARES_EXTERN int ares_library_initialized(void);
+
CARES_EXTERN void ares_library_cleanup(void);
CARES_EXTERN const char *ares_version(int *version);
@@ -337,6 +349,13 @@ CARES_EXTERN void ares_set_socket_callback(ares_channel channel,
ares_sock_create_callback callback,
void *user_data);
+CARES_EXTERN void ares_set_socket_configure_callback(ares_channel channel,
+ ares_sock_config_callback callback,
+ void *user_data);
+
+CARES_EXTERN int ares_set_sortlist(ares_channel channel,
+ const char *sortstr);
+
CARES_EXTERN void ares_send(ares_channel channel,
const unsigned char *qbuf,
int qlen,
@@ -474,6 +493,17 @@ struct ares_txt_reply {
size_t length; /* length excludes null termination */
};
+/* NOTE: This structure is a superset of ares_txt_reply
+ */
+struct ares_txt_ext {
+ struct ares_txt_ext *next;
+ unsigned char *txt;
+ size_t length;
+ /* 1 - if start of new record
+ * 0 - if a chunk in the same record */
+ unsigned char record_start;
+};
+
struct ares_naptr_reply {
struct ares_naptr_reply *next;
unsigned char *flags;
@@ -537,6 +567,10 @@ CARES_EXTERN int ares_parse_txt_reply(const unsigned char* abuf,
int alen,
struct ares_txt_reply** txt_out);
+CARES_EXTERN int ares_parse_txt_reply_ext(const unsigned char* abuf,
+ int alen,
+ struct ares_txt_ext** txt_out);
+
CARES_EXTERN int ares_parse_naptr_reply(const unsigned char* abuf,
int alen,
struct ares_naptr_reply** naptr_out);
@@ -553,7 +587,6 @@ CARES_EXTERN void ares_free_data(void *dataptr);
CARES_EXTERN const char *ares_strerror(int code);
-/* TODO: Hold port here as well. */
struct ares_addr_node {
struct ares_addr_node *next;
int family;
@@ -563,15 +596,32 @@ struct ares_addr_node {
} addr;
};
+struct ares_addr_port_node {
+ struct ares_addr_port_node *next;
+ int family;
+ union {
+ struct in_addr addr4;
+ struct ares_in6_addr addr6;
+ } addr;
+ int udp_port;
+ int tcp_port;
+};
+
CARES_EXTERN int ares_set_servers(ares_channel channel,
struct ares_addr_node *servers);
+CARES_EXTERN int ares_set_servers_ports(ares_channel channel,
+ struct ares_addr_port_node *servers);
/* Incomming string format: host[:port][,host[:port]]... */
CARES_EXTERN int ares_set_servers_csv(ares_channel channel,
const char* servers);
+CARES_EXTERN int ares_set_servers_ports_csv(ares_channel channel,
+ const char* servers);
CARES_EXTERN int ares_get_servers(ares_channel channel,
struct ares_addr_node **servers);
+CARES_EXTERN int ares_get_servers_ports(ares_channel channel,
+ struct ares_addr_port_node **servers);
CARES_EXTERN const char *ares_inet_ntop(int af, const void *src, char *dst,
ares_socklen_t size);
diff --git a/ares__close_sockets.c b/ares__close_sockets.c
index d3d85ff..6c66483 100644
--- a/ares__close_sockets.c
+++ b/ares__close_sockets.c
@@ -30,14 +30,14 @@ void ares__close_sockets(ares_channel channel, struct server_state *server)
sendreq = server->qhead;
server->qhead = sendreq->next;
if (sendreq->data_storage != NULL)
- free(sendreq->data_storage);
- free(sendreq);
+ ares_free(sendreq->data_storage);
+ ares_free(sendreq);
}
server->qtail = NULL;
/* Reset any existing input buffer. */
if (server->tcp_buffer)
- free(server->tcp_buffer);
+ ares_free(server->tcp_buffer);
server->tcp_buffer = NULL;
server->tcp_lenbuf_pos = 0;
diff --git a/ares__get_hostent.c b/ares__get_hostent.c
index 4497d60..d2f9503 100644
--- a/ares__get_hostent.c
+++ b/ares__get_hostent.c
@@ -94,7 +94,7 @@ int ares__get_hostent(FILE *fp, int family, struct hostent **host)
p++;
if (!*p)
/* Ignore line if reached end of line. */
- continue;
+ continue; /* LCOV_EXCL_LINE: trailing whitespace already stripped */
/* Pointer to start of host name. */
txthost = p;
@@ -164,7 +164,7 @@ int ares__get_hostent(FILE *fp, int family, struct hostent **host)
*/
/* Allocate memory for the hostent structure. */
- hostent = malloc(sizeof(struct hostent));
+ hostent = ares_malloc(sizeof(struct hostent));
if (!hostent)
break;
@@ -173,16 +173,16 @@ int ares__get_hostent(FILE *fp, int family, struct hostent **host)
hostent->h_addr_list = NULL;
/* Copy official host name. */
- hostent->h_name = strdup(txthost);
+ hostent->h_name = ares_strdup(txthost);
if (!hostent->h_name)
break;
/* Copy network address. */
- hostent->h_addr_list = malloc(2 * sizeof(char *));
+ hostent->h_addr_list = ares_malloc(2 * sizeof(char *));
if (!hostent->h_addr_list)
break;
hostent->h_addr_list[1] = NULL;
- hostent->h_addr_list[0] = malloc(addrlen);
+ hostent->h_addr_list[0] = ares_malloc(addrlen);
if (!hostent->h_addr_list[0])
break;
if (addr.family == AF_INET)
@@ -191,7 +191,7 @@ int ares__get_hostent(FILE *fp, int family, struct hostent **host)
memcpy(hostent->h_addr_list[0], &addr.addrV6, sizeof(addr.addrV6));
/* Copy aliases. */
- hostent->h_aliases = malloc((naliases + 1) * sizeof(char *));
+ hostent->h_aliases = ares_malloc((naliases + 1) * sizeof(char *));
if (!hostent->h_aliases)
break;
alias = hostent->h_aliases;
@@ -207,7 +207,7 @@ int ares__get_hostent(FILE *fp, int family, struct hostent **host)
while (*q && ISSPACE(*q))
q++;
*p = '\0';
- if ((*alias = strdup(txtalias)) == NULL)
+ if ((*alias = ares_strdup(txtalias)) == NULL)
break;
alias++;
txtalias = *q ? q : NULL;
@@ -221,7 +221,7 @@ int ares__get_hostent(FILE *fp, int family, struct hostent **host)
hostent->h_length = aresx_uztoss(addrlen);
/* Free line buffer. */
- free(line);
+ ares_free(line);
/* Return hostent successfully */
*host = hostent;
@@ -231,7 +231,7 @@ int ares__get_hostent(FILE *fp, int family, struct hostent **host)
/* If allocated, free line buffer. */
if (line)
- free(line);
+ ares_free(line);
if (status == ARES_SUCCESS)
{
@@ -239,20 +239,20 @@ int ares__get_hostent(FILE *fp, int family, struct hostent **host)
if (hostent)
{
if (hostent->h_name)
- free((char *) hostent->h_name);
+ ares_free((char *) hostent->h_name);
if (hostent->h_aliases)
{
for (alias = hostent->h_aliases; *alias; alias++)
- free(*alias);
- free(hostent->h_aliases);
+ ares_free(*alias);
+ ares_free(hostent->h_aliases);
}
if (hostent->h_addr_list)
{
if (hostent->h_addr_list[0])
- free(hostent->h_addr_list[0]);
- free(hostent->h_addr_list);
+ ares_free(hostent->h_addr_list[0]);
+ ares_free(hostent->h_addr_list);
}
- free(hostent);
+ ares_free(hostent);
}
return ARES_ENOMEM;
}
diff --git a/ares__read_line.c b/ares__read_line.c
index bd9504f..c62ad2a 100644
--- a/ares__read_line.c
+++ b/ares__read_line.c
@@ -36,7 +36,7 @@ int ares__read_line(FILE *fp, char **buf, size_t *bufsize)
if (*buf == NULL)
{
- *buf = malloc(128);
+ *buf = ares_malloc(128);
if (!*buf)
return ARES_ENOMEM;
*bufsize = 128;
@@ -59,9 +59,13 @@ int ares__read_line(FILE *fp, char **buf, size_t *bufsize)
continue;
/* Allocate more space. */
- newbuf = realloc(*buf, *bufsize * 2);
+ newbuf = ares_realloc(*buf, *bufsize * 2);
if (!newbuf)
- return ARES_ENOMEM;
+ {
+ ares_free(*buf);
+ *buf = NULL;
+ return ARES_ENOMEM;
+ }
*buf = newbuf;
*bufsize *= 2;
}
diff --git a/ares__timeval.c b/ares__timeval.c
index f7aa788..94efb7d 100644
--- a/ares__timeval.c
+++ b/ares__timeval.c
@@ -56,7 +56,7 @@ struct timeval ares__tvnow(void)
*/
#ifdef HAVE_GETTIMEOFDAY
else
- (void)gettimeofday(&now, NULL);
+ (void)gettimeofday(&now, NULL); /* LCOV_EXCL_LINE */
#else
else {
now.tv_sec = (long)time(NULL);
diff --git a/ares_build.h.in b/ares_build.h.in
index 227782c..e582523 100644
--- a/ares_build.h.in
+++ b/ares_build.h.in
@@ -50,21 +50,11 @@
/* DEFINITION OF THESE SYMBOLS SHALL NOT TAKE PLACE ANYWHERE ELSE */
/* ================================================================ */
-#ifdef CARES_SIZEOF_LONG
-# error "CARES_SIZEOF_LONG shall not be defined except in ares_build.h"
- Error Compilation_aborted_CARES_SIZEOF_LONG_already_defined
-#endif
-
#ifdef CARES_TYPEOF_ARES_SOCKLEN_T
# error "CARES_TYPEOF_ARES_SOCKLEN_T shall not be defined except in ares_build.h"
Error Compilation_aborted_CARES_TYPEOF_ARES_SOCKLEN_T_already_defined
#endif
-#ifdef CARES_SIZEOF_ARES_SOCKLEN_T
-# error "CARES_SIZEOF_ARES_SOCKLEN_T shall not be defined except in ares_build.h"
- Error Compilation_aborted_CARES_SIZEOF_ARES_SOCKLEN_T_already_defined
-#endif
-
/* ================================================================ */
/* EXTERNAL INTERFACE SETTINGS FOR CONFIGURE CAPABLE SYSTEMS ONLY */
/* ================================================================ */
@@ -95,15 +85,9 @@
# include <sys/socket.h>
#endif
-/* The size of `long', as computed by sizeof. */
-#undef CARES_SIZEOF_LONG
-
/* Integral data type used for ares_socklen_t. */
#undef CARES_TYPEOF_ARES_SOCKLEN_T
-/* The size of `ares_socklen_t', as computed by sizeof. */
-#undef CARES_SIZEOF_ARES_SOCKLEN_T
-
/* Data type definition of ares_socklen_t. */
typedef CARES_TYPEOF_ARES_SOCKLEN_T ares_socklen_t;
diff --git a/ares_cancel.3 b/ares_cancel.3
index 0bf6281..e534e3f 100644
--- a/ares_cancel.3
+++ b/ares_cancel.3
@@ -23,14 +23,15 @@ ares_cancel \- Cancel a resolve
.B void ares_cancel(ares_channel \fIchannel\fP)
.fi
.SH DESCRIPTION
-The \fBares_cancel\fP function cancels all lookups/requests made on the the
-name service channel identified by \fIchannel\fP. \fBares_cancel\fP invokes
-the callbacks for each pending query on the channel, passing a status of
+The \fBares_cancel(3)\fP function cancels all lookups/requests made on the the
+name service channel identified by \fIchannel\fP. \fBares_cancel(3)\fP
+invokes the callbacks for each pending query on the channel, passing a status
+of
.BR ARES_ECANCELLED .
-These calls give the callbacks a chance to clean up any state which
-might have been stored in their arguments. If such a callback invocation adds
-a new request to the channel, that request will \fInot\fP be cancelled by the
-current invocation of \fBares_cancel\fP.
+These calls give the callbacks a chance to clean up any state which might have
+been stored in their arguments. If such a callback invocation adds a new
+request to the channel, that request will \fInot\fP be cancelled by the
+current invocation of \fBares_cancel(3)\fP.
.SH SEE ALSO
.BR ares_init (3)
.BR ares_destroy (3)
diff --git a/ares_create_query.3 b/ares_create_query.3
index 5fd94fc..59af0f0 100644
--- a/ares_create_query.3
+++ b/ares_create_query.3
@@ -18,45 +18,39 @@
ares_create_query \- Compose a single-question DNS query buffer
.SH SYNOPSIS
.nf
-.B #include <ares.h>
-.PP
-.B int ares_create_query(const char *\fIname\fP, int \fIdnsclass\fP,\
- int \fItype\fP,
-.B unsigned short \fIid\fP, int \fIrd\fP,\
- unsigned char **\fIbuf\fP,
-.B int *\fIbuflen\fP, int \fImax_udp_size\fP)
+#include <ares.h>
+
+int ares_create_query(const char *\fIname\fP,
+ int \fIdnsclass\fP,
+ int \fItype\fP,
+ unsigned short \fIid\fP,
+ int \fIrd\fP,
+ unsigned char **\fIbuf\fP,
+ int *\fIbuflen\fP,
+ int \fImax_udp_size\fP)
.fi
.SH DESCRIPTION
-The
-.B ares_create_query
-function composes a DNS query with a single question.
-The parameter
-.I name
-gives the query name as a NUL-terminated C string of period-separated
-labels optionally ending with a period; periods and backslashes within
-a label must be escaped with a backlash. The parameters
-.I dnsclass
-and
-.I type
-give the class and type of the query using the values defined in
-.BR <arpa/nameser.h> .
-The parameter
-.I id
-gives a 16-bit identifier for the query. The parameter
-.I rd
-should be nonzero if recursion is desired, zero if not. The query
-will be placed in an allocated buffer, a pointer to which will be
-stored in the variable pointed to by
-.IR buf ,
-and the length of which will be stored in the variable pointed to by
-.IR buflen .
+The \fIares_create_query(3)\fP function composes a DNS query with a single
+question. The parameter \fIname\fP gives the query name as a NUL-terminated C
+string of period-separated labels optionally ending with a period; periods and
+backslashes within a label must be escaped with a backlash.
+
+The parameters \fIdnsclass\fP and \fItype\fP give the class and type of the
+query using the values defined in \fB<arpa/nameser.h>\fP.
+
+The parameter \fIid\fP gives a 16-bit identifier for the query.
+
+The parameter \fIrd\fP should be nonzero if recursion is desired, zero if not.
+
+The query will be placed in an allocated buffer, a pointer to which will be
+stored in the variable pointed to by \fIbuf\fP, and the length of which will
+be stored in the variable pointed to by \fIbuflen\fP.
+
It is the caller's responsibility to free this buffer using
-\fIares_free_string(3)\fP when it is no longer needed.
-The parameter
-.I max_udp_size
-should be nonzero to activate EDNS. Usage of \fIares_create_query(3)\fP\ with
-.I max_udp_size
-set to zero is equivalent to \fIares_mkquery(3)\fP.
+\fIares_free_string(3)\fP when it is no longer needed. The parameter
+\fImax_udp_size\fP should be nonzero to activate EDNS. Usage of
+\fIares_create_query(3)\fP\ with \fImax_udp_size\fP set to zero is equivalent
+to using \fIares_mkquery(3)\fP.
.SH RETURN VALUES
.B ares_create_query
can return any of the following values:
@@ -77,5 +71,6 @@ Memory was exhausted.
Added in c-ares 1.10.0
.SH SEE ALSO
.BR ares_expand_name (3),
-.BR ares_free_string (3)
+.BR ares_free_string (3),
+.BR ares_mkquery (3)
.SH AUTHOR
diff --git a/ares_create_query.c b/ares_create_query.c
index b9204e6..7f4c52d 100755..100644
--- a/ares_create_query.c
+++ b/ares_create_query.c
@@ -103,10 +103,10 @@ int ares_create_query(const char *name, int dnsclass, int type,
* used.
*/
len = strlen(name) + 2 + HFIXEDSZ + QFIXEDSZ +
- (max_udp_size ? EDNSFIXEDSZ : 0);
+ (max_udp_size ? EDNSFIXEDSZ : 0);
buf = ares_malloc(len);
if (!buf)
- return ARES_ENOMEM;
+ return ARES_ENOMEM;
/* Set up the header. */
q = buf;
@@ -134,7 +134,7 @@ int ares_create_query(const char *name, int dnsclass, int type,
while (*name)
{
if (*name == '.') {
- free(buf);
+ free (buf);
return ARES_EBADNAME;
}
@@ -147,7 +147,7 @@ int ares_create_query(const char *name, int dnsclass, int type,
len++;
}
if (len > MAXLABEL) {
- free(buf);
+ free (buf);
return ARES_EBADNAME;
}
@@ -180,7 +180,7 @@ int ares_create_query(const char *name, int dnsclass, int type,
q++;
DNS_RR_SET_TYPE(q, T_OPT);
DNS_RR_SET_CLASS(q, max_udp_size);
- q += (EDNSFIXEDSZ-1);
+ q += (EDNSFIXEDSZ-1);
}
buflen = (q - buf);
@@ -190,8 +190,8 @@ int ares_create_query(const char *name, int dnsclass, int type,
* to 255 octets or less."). */
if (buflen > (MAXCDNAME + HFIXEDSZ + QFIXEDSZ +
(max_udp_size ? EDNSFIXEDSZ : 0))) {
- free (buf);
- return ARES_EBADNAME;
+ free (buf);
+ return ARES_EBADNAME;
}
/* we know this fits in an int at this point */
diff --git a/ares_data.c b/ares_data.c
index b86ca90..f891113 100644
--- a/ares_data.c
+++ b/ares_data.c
@@ -67,7 +67,7 @@ void ares_free_data(void *dataptr)
if (ptr->data.mx_reply.next)
ares_free_data(ptr->data.mx_reply.next);
if (ptr->data.mx_reply.host)
- free(ptr->data.mx_reply.host);
+ ares_free(ptr->data.mx_reply.host);
break;
case ARES_DATATYPE_SRV_REPLY:
@@ -75,15 +75,16 @@ void ares_free_data(void *dataptr)
if (ptr->data.srv_reply.next)
ares_free_data(ptr->data.srv_reply.next);
if (ptr->data.srv_reply.host)
- free(ptr->data.srv_reply.host);
+ ares_free(ptr->data.srv_reply.host);
break;
case ARES_DATATYPE_TXT_REPLY:
+ case ARES_DATATYPE_TXT_EXT:
if (ptr->data.txt_reply.next)
ares_free_data(ptr->data.txt_reply.next);
if (ptr->data.txt_reply.txt)
- free(ptr->data.txt_reply.txt);
+ ares_free(ptr->data.txt_reply.txt);
break;
case ARES_DATATYPE_ADDR_NODE:
@@ -92,32 +93,38 @@ void ares_free_data(void *dataptr)
ares_free_data(ptr->data.addr_node.next);
break;
+ case ARES_DATATYPE_ADDR_PORT_NODE:
+
+ if (ptr->data.addr_port_node.next)
+ ares_free_data(ptr->data.addr_port_node.next);
+ break;
+
case ARES_DATATYPE_NAPTR_REPLY:
if (ptr->data.naptr_reply.next)
ares_free_data(ptr->data.naptr_reply.next);
if (ptr->data.naptr_reply.flags)
- free(ptr->data.naptr_reply.flags);
+ ares_free(ptr->data.naptr_reply.flags);
if (ptr->data.naptr_reply.service)
- free(ptr->data.naptr_reply.service);
+ ares_free(ptr->data.naptr_reply.service);
if (ptr->data.naptr_reply.regexp)
- free(ptr->data.naptr_reply.regexp);
+ ares_free(ptr->data.naptr_reply.regexp);
if (ptr->data.naptr_reply.replacement)
- free(ptr->data.naptr_reply.replacement);
+ ares_free(ptr->data.naptr_reply.replacement);
break;
case ARES_DATATYPE_SOA_REPLY:
if (ptr->data.soa_reply.nsname)
- free(ptr->data.soa_reply.nsname);
+ ares_free(ptr->data.soa_reply.nsname);
if (ptr->data.soa_reply.hostmaster)
- free(ptr->data.soa_reply.hostmaster);
+ ares_free(ptr->data.soa_reply.hostmaster);
break;
default:
return;
}
- free(ptr);
+ ares_free(ptr);
}
@@ -136,7 +143,7 @@ void *ares_malloc_data(ares_datatype type)
{
struct ares_data *ptr;
- ptr = malloc(sizeof(struct ares_data));
+ ptr = ares_malloc(sizeof(struct ares_data));
if (!ptr)
return NULL;
@@ -156,6 +163,10 @@ void *ares_malloc_data(ares_datatype type)
ptr->data.srv_reply.port = 0;
break;
+ case ARES_DATATYPE_TXT_EXT:
+ ptr->data.txt_ext.record_start = 0;
+ /* FALLTHROUGH */
+
case ARES_DATATYPE_TXT_REPLY:
ptr->data.txt_reply.next = NULL;
ptr->data.txt_reply.txt = NULL;
@@ -169,6 +180,15 @@ void *ares_malloc_data(ares_datatype type)
sizeof(ptr->data.addr_node.addrV6));
break;
+ case ARES_DATATYPE_ADDR_PORT_NODE:
+ ptr->data.addr_port_node.next = NULL;
+ ptr->data.addr_port_node.family = 0;
+ ptr->data.addr_port_node.udp_port = 0;
+ ptr->data.addr_port_node.tcp_port = 0;
+ memset(&ptr->data.addr_port_node.addrV6, 0,
+ sizeof(ptr->data.addr_port_node.addrV6));
+ break;
+
case ARES_DATATYPE_NAPTR_REPLY:
ptr->data.naptr_reply.next = NULL;
ptr->data.naptr_reply.flags = NULL;
@@ -190,7 +210,7 @@ void *ares_malloc_data(ares_datatype type)
break;
default:
- free(ptr);
+ ares_free(ptr);
return NULL;
}
diff --git a/ares_data.h b/ares_data.h
index 12e3b67..ffee2be 100644
--- a/ares_data.h
+++ b/ares_data.h
@@ -18,6 +18,7 @@ typedef enum {
ARES_DATATYPE_UNKNOWN = 1, /* unknown data type - introduced in 1.7.0 */
ARES_DATATYPE_SRV_REPLY, /* struct ares_srv_reply - introduced in 1.7.0 */
ARES_DATATYPE_TXT_REPLY, /* struct ares_txt_reply - introduced in 1.7.0 */
+ ARES_DATATYPE_TXT_EXT, /* struct ares_txt_ext - introduced in 1.11.0 */
ARES_DATATYPE_ADDR_NODE, /* struct ares_addr_node - introduced in 1.7.1 */
ARES_DATATYPE_MX_REPLY, /* struct ares_mx_reply - introduced in 1.7.2 */
ARES_DATATYPE_NAPTR_REPLY,/* struct ares_naptr_reply - introduced in 1.7.6 */
@@ -28,6 +29,7 @@ typedef enum {
ARES_DATATYPE_HOSTENT, /* struct hostent */
ARES_DATATYPE_OPTIONS, /* struct ares_options */
#endif
+ ARES_DATATYPE_ADDR_PORT_NODE, /* struct ares_addr_port_node - introduced in 1.11.0 */
ARES_DATATYPE_LAST /* not used - introduced in 1.7.0 */
} ares_datatype;
@@ -55,12 +57,14 @@ struct ares_data {
ares_datatype type; /* Actual data type identifier. */
unsigned int mark; /* Private ares_data signature. */
union {
- struct ares_txt_reply txt_reply;
- struct ares_srv_reply srv_reply;
- struct ares_addr_node addr_node;
- struct ares_mx_reply mx_reply;
- struct ares_naptr_reply naptr_reply;
- struct ares_soa_reply soa_reply;
+ struct ares_txt_reply txt_reply;
+ struct ares_txt_ext txt_ext;
+ struct ares_srv_reply srv_reply;
+ struct ares_addr_node addr_node;
+ struct ares_addr_port_node addr_port_node;
+ struct ares_mx_reply mx_reply;
+ struct ares_naptr_reply naptr_reply;
+ struct ares_soa_reply soa_reply;
} data;
};
diff --git a/ares_destroy.3 b/ares_destroy.3
index 3724df1..7af7fe3 100644
--- a/ares_destroy.3
+++ b/ares_destroy.3
@@ -23,18 +23,14 @@ ares_destroy \- Destroy a resolver channel
.B void ares_destroy(ares_channel \fIchannel\fP)
.fi
.SH DESCRIPTION
-The
-.B ares_destroy
-function destroys the name service channel identified by
-.IR channel ,
-freeing all memory and closing all sockets used by the channel.
-.B ares_destroy
-invokes the callbacks for each pending query on the channel, passing a
-status of
-.BR ARES_EDESTRUCTION .
-These calls give the callbacks a chance to clean up any state which
-might have been stored in their arguments. A callback must not add new
-requests to a channel being destroyed.
+The \fBares_destroy(3)\fP function destroys the name service channel
+identified by \fIchannel\fP, freeing all memory and closing all sockets used
+by the channel.
+
+\fBares_destroy(3)\fP invokes the callbacks for each pending query on the
+channel, passing a status of \IARES_EDESTRUCTION\fP. These calls give the
+callbacks a chance to clean up any state which might have been stored in their
+arguments. A callback must not add new requests to a channel being destroyed.
.SH SEE ALSO
.BR ares_init (3),
.BR ares_cancel (3)
diff --git a/ares_destroy.c b/ares_destroy.c
index 6c1f324..8aa4223 100644
--- a/ares_destroy.c
+++ b/ares_destroy.c
@@ -27,15 +27,15 @@ void ares_destroy_options(struct ares_options *options)
int i;
if(options->servers)
- free(options->servers);
+ ares_free(options->servers);
for (i = 0; i < options->ndomains; i++)
- free(options->domains[i]);
+ ares_free(options->domains[i]);
if(options->domains)
- free(options->domains);
+ ares_free(options->domains);
if(options->sortlist)
- free(options->sortlist);
+ ares_free(options->sortlist);
if(options->lookups)
- free(options->lookups);
+ ares_free(options->lookups);
}
void ares_destroy(ares_channel channel)
@@ -75,17 +75,17 @@ void ares_destroy(ares_channel channel)
if (channel->domains) {
for (i = 0; i < channel->ndomains; i++)
- free(channel->domains[i]);
- free(channel->domains);
+ ares_free(channel->domains[i]);
+ ares_free(channel->domains);
}
if(channel->sortlist)
- free(channel->sortlist);
+ ares_free(channel->sortlist);
if (channel->lookups)
- free(channel->lookups);
+ ares_free(channel->lookups);
- free(channel);
+ ares_free(channel);
}
void ares__destroy_servers_state(ares_channel channel)
@@ -101,7 +101,7 @@ void ares__destroy_servers_state(ares_channel channel)
ares__close_sockets(channel, server);
assert(ares__is_list_empty(&server->queries_to_server));
}
- free(channel->servers);
+ ares_free(channel->servers);
channel->servers = NULL;
}
channel->nservers = -1;
diff --git a/ares_destroy_options.3 b/ares_destroy_options.3
index 3e564b2..31e346b 100644
--- a/ares_destroy_options.3
+++ b/ares_destroy_options.3
@@ -23,12 +23,9 @@ ares_destroy_options \- Destroy options initialized with ares_save_options
.B void ares_destroy_options(struct ares_options *\fIoptions\fP)
.fi
.SH DESCRIPTION
-The
-.B ares_destroy_options
-function destroys the options struct identified by
-.IR options ,
-freeing all memory allocated by ares_save_options.
-
+The \fBares_destroy_options(3)\fP function destroys the options struct
+identified by \Ioptions\fP, freeing all memory allocated by
+\fBares_save_options(3)\fP.
.SH SEE ALSO
.BR ares_save_options (3),
.BR ares_init_options (3)
diff --git a/ares_dup.3 b/ares_dup.3
index 935c5d9..e64c104 100644
--- a/ares_dup.3
+++ b/ares_dup.3
@@ -28,16 +28,12 @@ for name service lookups. If it returns successfully, \fBares_dup(3)\fP will
set the variable pointed to by \fIdest\fP to a handle used to identify the
name service channel. The caller should invoke \fIares_destroy(3)\fP on the
handle when the channel is no longer needed.
-
-The \fBares_dup_options\fP function also initializes a name service channel,
-with additional options set exactly as the \fIsource\fP channel has them
-configured.
.SH SEE ALSO
.BR ares_destroy(3),
.BR ares_init(3),
.BR ares_library_init(3)
.SH AVAILABILITY
-ares_dup(3) was added in c-ares 1.6.0
+\fIares_dup(3)\fP was added in c-ares 1.6.0
.SH AUTHOR
Daniel Stenberg
diff --git a/ares_expand_name.c b/ares_expand_name.c
index 2aa12bc..738be8d 100644
--- a/ares_expand_name.c
+++ b/ares_expand_name.c
@@ -74,7 +74,7 @@ int ares_expand_name(const unsigned char *encoded, const unsigned char *abuf,
if (nlen.sig < 0)
return ARES_EBADNAME;
- *s = malloc(nlen.uns + 1);
+ *s = ares_malloc(nlen.uns + 1);
if (!*s)
return ARES_ENOMEM;
q = *s;
@@ -129,7 +129,7 @@ int ares_expand_name(const unsigned char *encoded, const unsigned char *abuf,
if (q > *s)
*(q - 1) = 0;
else
- *q = 0; /* zero terminate */
+ *q = 0; /* zero terminate; LCOV_EXCL_LINE: empty names exit above */
return ARES_SUCCESS;
}
@@ -140,7 +140,7 @@ int ares_expand_name(const unsigned char *encoded, const unsigned char *abuf,
static int name_length(const unsigned char *encoded, const unsigned char *abuf,
int alen)
{
- int n = 0, offset, indir = 0;
+ int n = 0, offset, indir = 0, top;
/* Allow the caller to pass us abuf + alen and have us check for it. */
if (encoded >= abuf + alen)
@@ -148,7 +148,8 @@ static int name_length(const unsigned char *encoded, const unsigned char *abuf,
while (*encoded)
{
- if ((*encoded & INDIR_MASK) == INDIR_MASK)
+ top = (*encoded & INDIR_MASK);
+ if (top == INDIR_MASK)
{
/* Check the offset and go there. */
if (encoded + 1 >= abuf + alen)
@@ -164,7 +165,7 @@ static int name_length(const unsigned char *encoded, const unsigned char *abuf,
if (++indir > alen)
return -1;
}
- else
+ else if (top == 0x00)
{
offset = *encoded;
if (encoded + offset + 1 >= abuf + alen)
@@ -177,6 +178,13 @@ static int name_length(const unsigned char *encoded, const unsigned char *abuf,
}
n++;
}
+ else
+ {
+ /* RFC 1035 4.1.4 says other options (01, 10) for top 2
+ * bits are reserved.
+ */
+ return -1;
+ }
}
/* If there were any labels at all, then the number of dots is one
diff --git a/ares_expand_string.c b/ares_expand_string.c
index 96d1be3..ed5476b 100644
--- a/ares_expand_string.c
+++ b/ares_expand_string.c
@@ -54,7 +54,7 @@ int ares_expand_string(const unsigned char *encoded,
encoded++;
- *s = malloc(elen.uns+1);
+ *s = ares_malloc(elen.uns+1);
if (*s == NULL)
return ARES_ENOMEM;
q = *s;
diff --git a/ares_free_hostent.c b/ares_free_hostent.c
index 7f44882..cfc5f81 100644
--- a/ares_free_hostent.c
+++ b/ares_free_hostent.c
@@ -30,12 +30,12 @@ void ares_free_hostent(struct hostent *host)
if (!host)
return;
- free((char *)(host->h_name));
+ ares_free((char *)(host->h_name));
for (p = host->h_aliases; *p; p++)
- free(*p);
- free(host->h_aliases);
- free(host->h_addr_list[0]); /* no matter if there is one or many entries,
+ ares_free(*p);
+ ares_free(host->h_aliases);
+ ares_free(host->h_addr_list[0]); /* no matter if there is one or many entries,
there is only one malloc for all of them */
- free(host->h_addr_list);
- free(host);
+ ares_free(host->h_addr_list);
+ ares_free(host);
}
diff --git a/ares_free_string.3 b/ares_free_string.3
index 55af7d2..61d88aa 100644
--- a/ares_free_string.3
+++ b/ares_free_string.3
@@ -23,9 +23,8 @@ ares_free_string \- Free strings allocated by ares functions
.B void ares_free_string(void *\fIstr\fP)
.fi
.SH DESCRIPTION
-The
-.I ares_free_string
-function frees a string allocated by an ares function.
+The \fIares_free_string(3)\fP function frees a string allocated by an ares
+function.
.SH SEE ALSO
.BR ares_mkquery (3)
.BR ares_expand_string (3)
diff --git a/ares_free_string.c b/ares_free_string.c
index 9441089..024992e 100644
--- a/ares_free_string.c
+++ b/ares_free_string.c
@@ -21,5 +21,5 @@
void ares_free_string(void *str)
{
- free(str);
+ ares_free(str);
}
diff --git a/ares_get_servers.3 b/ares_get_servers.3
index feea3a0..d606428 100644
--- a/ares_get_servers.3
+++ b/ares_get_servers.3
@@ -16,12 +16,13 @@
.\"
.TH ARES_GET_SERVERS 3 "5 March 2010"
.SH NAME
-ares_get_servers \- Retrieve name servers from an initialized ares_channel
+ares_get_servers, ares_get_servers_ports \- Retrieve name servers from an initialized ares_channel
.SH SYNOPSIS
.nf
.B #include <ares.h>
.PP
.B int ares_get_servers(ares_channel \fIchannel\fP, struct ares_addr_node **\fIservers\fP)
+.B int ares_get_servers_ports(ares_channel \fIchannel\fP, struct ares_addr_port_node **\fIservers\fP)
.fi
.SH DESCRIPTION
The \fBares_get_servers(3)\fP function retrieves name servers configuration
@@ -32,8 +33,13 @@ as a linked list of ares_addr_node structs storing a pointer to the first
node at the address specified by
.IR servers .
+The \fBares_get_servers_ports(3)\fP function also retrieves any per-server
+port information that may have been previously configured, returning a linked
+list of ares_addr_port structures.
+
Function caller may traverse the returned name server linked list, or may use
-it directly as suitable input for the \fBares_set_servers(3)\fP function, but
+it directly as suitable input for the \fBares_set_servers(3)\fP /
+\fBares_set_servers_ports(3)\fP functions, but
shall not shrink or extend the list on its own.
Each node of the name server linked list is stored in memory dynamically
@@ -47,17 +53,16 @@ optmask \fBARES_OPT_SERVERS\fP functionally obsolete except for
IPv4-only name server usage.
.SH RETURN VALUES
-.B ares_get_servers(3)
-may return any of the following values:
+This function may return any of the following values:
.TP 15
.B ARES_SUCCESS
-The name servers configuration was successfuly retrieved
+The name servers configuration was successfully retrieved
.TP 15
.B ARES_ENOMEM
The memory was exhausted
.TP 15
.B ARES_ENODATA
-The channel data identified by
+The channel data identified by
.IR channel
was invalid.
.SH SEE ALSO
@@ -65,7 +70,8 @@ was invalid.
.BR ares_init_options (3),
.BR ares_save_options(3)
.SH AVAILABILITY
-ares_get_servers(3) was added in c-ares 1.7.1
+\fBares_get_servers(3)\fP was added in c-ares 1.7.1;
+\fBares_get_servers_ports(3)\fP was added in c-ares 1.11.0.
.SH AUTHOR
Implementation of this function and associated library internals are based
on code, comments and feedback provided in November and December of 2008 by
diff --git a/ares_get_servers_ports.3 b/ares_get_servers_ports.3
new file mode 100644
index 0000000..1f5d1f7
--- /dev/null
+++ b/ares_get_servers_ports.3
@@ -0,0 +1 @@
+.so man3/ares_get_servers.3
diff --git a/ares_gethostbyaddr.c b/ares_gethostbyaddr.c
index 0c832bb..9258919 100644
--- a/ares_gethostbyaddr.c
+++ b/ares_gethostbyaddr.c
@@ -79,7 +79,7 @@ void ares_gethostbyaddr(ares_channel channel, const void *addr, int addrlen,
return;
}
- aquery = malloc(sizeof(struct addr_query));
+ aquery = ares_malloc(sizeof(struct addr_query));
if (!aquery)
{
callback(arg, ARES_ENOMEM, 0, NULL);
@@ -169,7 +169,7 @@ static void end_aquery(struct addr_query *aquery, int status,
aquery->callback(aquery->arg, status, aquery->timeouts, host);
if (host)
ares_free_hostent(host);
- free(aquery);
+ ares_free(aquery);
}
static int file_lookup(struct ares_addr *addr, struct hostent **host)
@@ -215,7 +215,7 @@ static int file_lookup(struct ares_addr *addr, struct hostent **host)
return ARES_ENOTFOUND;
#endif
- fp = fopen(PATH_HOSTS, "re");
+ fp = fopen(PATH_HOSTS, "r");
if (!fp)
{
error = ERRNO;
diff --git a/ares_gethostbyname.c b/ares_gethostbyname.c
index 5bb0d35..caab6ae 100644
--- a/ares_gethostbyname.c
+++ b/ares_gethostbyname.c
@@ -99,18 +99,18 @@ void ares_gethostbyname(ares_channel channel, const char *name, int family,
return;
/* Allocate and fill in the host query structure. */
- hquery = malloc(sizeof(struct host_query));
+ hquery = ares_malloc(sizeof(struct host_query));
if (!hquery)
{
callback(arg, ARES_ENOMEM, 0, NULL);
return;
}
hquery->channel = channel;
- hquery->name = strdup(name);
+ hquery->name = ares_strdup(name);
hquery->want_family = family;
hquery->sent_family = -1; /* nothing is sent yet */
if (!hquery->name) {
- free(hquery);
+ ares_free(hquery);
callback(arg, ARES_ENOMEM, 0, NULL);
return;
}
@@ -188,11 +188,14 @@ static void host_callback(void *arg, int status, int timeouts,
else if (hquery->sent_family == AF_INET6)
{
status = ares_parse_aaaa_reply(abuf, alen, &host, NULL, NULL);
- if ((status == ARES_ENODATA || status == ARES_EBADRESP) &&
- hquery->want_family == AF_UNSPEC) {
+ if ((status == ARES_ENODATA || status == ARES_EBADRESP ||
+ (status == ARES_SUCCESS && host && host->h_addr_list[0] == NULL)) &&
+ 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. */
+ if (host)
+ ares_free_hostent(host);
hquery->sent_family = AF_INET;
ares_search(hquery->channel, hquery->name, C_IN, T_A,
host_callback, hquery);
@@ -224,8 +227,8 @@ static void end_hquery(struct host_query *hquery, int status,
hquery->callback(hquery->arg, status, hquery->timeouts, host);
if (host)
ares_free_hostent(host);
- free(hquery->name);
- free(hquery);
+ ares_free(hquery->name);
+ ares_free(hquery);
}
/* If the name looks like an IP address, fake up a host entry, end the
@@ -284,7 +287,7 @@ static int fake_hostent(const char *name, int family,
addrs[0] = (char *)&in6;
}
/* Duplicate the name, to avoid a constness violation. */
- hostent.h_name = strdup(name);
+ hostent.h_name = ares_strdup(name);
if (!hostent.h_name)
{
callback(arg, ARES_ENOMEM, 0, NULL);
@@ -298,7 +301,7 @@ static int fake_hostent(const char *name, int family,
hostent.h_addr_list = addrs;
callback(arg, ARES_SUCCESS, 0, &hostent);
- free((char *)(hostent.h_name));
+ ares_free((char *)(hostent.h_name));
return 1;
}
@@ -373,7 +376,7 @@ static int file_lookup(const char *name, int family, struct hostent **host)
return ARES_ENOTFOUND;
#endif
- fp = fopen(PATH_HOSTS, "re");
+ fp = fopen(PATH_HOSTS, "r");
if (!fp)
{
error = ERRNO;
diff --git a/ares_getnameinfo.3 b/ares_getnameinfo.3
index d227606..1017432 100644
--- a/ares_getnameinfo.3
+++ b/ares_getnameinfo.3
@@ -145,7 +145,6 @@ will be
.BR NULL .
.SH SEE ALSO
.BR ares_process (3),
-.BR ares_getaddrinfo (3)
.SH AUTHOR
Dominick Meglio
.br
diff --git a/ares_getnameinfo.c b/ares_getnameinfo.c
index 5b9f638..4516112 100644
--- a/ares_getnameinfo.c
+++ b/ares_getnameinfo.c
@@ -77,7 +77,7 @@ static char *lookup_service(unsigned short port, int flags,
static void append_scopeid(struct sockaddr_in6 *addr6, unsigned int scopeid,
char *buf, size_t buflen);
#endif
-static char *ares_striendstr(const char *s1, const char *s2);
+STATIC_TESTABLE char *ares_striendstr(const char *s1, const char *s2);
void ares_getnameinfo(ares_channel channel, const struct sockaddr *sa,
ares_socklen_t salen,
@@ -163,7 +163,7 @@ void ares_getnameinfo(ares_channel channel, const struct sockaddr *sa,
/* This is where a DNS lookup becomes necessary */
else
{
- niquery = malloc(sizeof(struct nameinfo_query));
+ niquery = ares_malloc(sizeof(struct nameinfo_query));
if (!niquery)
{
callback(arg, ARES_ENOMEM, 0, NULL, NULL);
@@ -234,7 +234,7 @@ static void nameinfo_callback(void *arg, int status, int timeouts,
niquery->callback(niquery->arg, ARES_SUCCESS, niquery->timeouts,
(char *)(host->h_name),
service);
- free(niquery);
+ ares_free(niquery);
return;
}
/* We couldn't find the host, but it's OK, we can use the IP */
@@ -265,11 +265,11 @@ static void nameinfo_callback(void *arg, int status, int timeouts,
}
niquery->callback(niquery->arg, ARES_SUCCESS, niquery->timeouts, ipbuf,
service);
- free(niquery);
+ ares_free(niquery);
return;
}
niquery->callback(niquery->arg, status, niquery->timeouts, NULL, NULL);
- free(niquery);
+ ares_free(niquery);
}
static char *lookup_service(unsigned short port, int flags,
@@ -281,6 +281,8 @@ static char *lookup_service(unsigned short port, int flags,
struct servent se;
#endif
char tmpbuf[4096];
+ char *name;
+ size_t name_len;
if (port)
{
@@ -297,12 +299,13 @@ static char *lookup_service(unsigned short port, int flags,
else
proto = "tcp";
#ifdef HAVE_GETSERVBYPORT_R
+ memset(&se, 0, sizeof(se));
sep = &se;
memset(tmpbuf, 0, sizeof(tmpbuf));
#if GETSERVBYPORT_R_ARGS == 6
if (getservbyport_r(port, proto, &se, (void *)tmpbuf,
sizeof(tmpbuf), &sep) != 0)
- sep = NULL;
+ sep = NULL; /* LCOV_EXCL_LINE: buffer large so this never fails */
#elif GETSERVBYPORT_R_ARGS == 5
sep = getservbyport_r(port, proto, &se, (void *)tmpbuf,
sizeof(tmpbuf));
@@ -323,17 +326,23 @@ static char *lookup_service(unsigned short port, int flags,
#endif
}
if (sep && sep->s_name)
- /* get service name */
- strcpy(tmpbuf, sep->s_name);
+ {
+ /* get service name */
+ name = sep->s_name;
+ }
else
- /* get port as a string */
- sprintf(tmpbuf, "%u", (unsigned int)ntohs(port));
- if (strlen(tmpbuf) < buflen)
+ {
+ /* get port as a string */
+ sprintf(tmpbuf, "%u", (unsigned int)ntohs(port));
+ name = tmpbuf;
+ }
+ name_len = strlen(name);
+ if (name_len < buflen)
/* return it if buffer big enough */
- strcpy(buf, tmpbuf);
+ memcpy(buf, name, name_len + 1);
else
/* avoid reusing previous one */
- buf[0] = '\0';
+ buf[0] = '\0'; /* LCOV_EXCL_LINE: no real service names are too big */
return buf;
}
buf[0] = '\0';
@@ -383,7 +392,7 @@ static void append_scopeid(struct sockaddr_in6 *addr6, unsigned int flags,
#endif
/* Determines if s1 ends with the string in s2 (case-insensitive) */
-static char *ares_striendstr(const char *s1, const char *s2)
+STATIC_TESTABLE char *ares_striendstr(const char *s1, const char *s2)
{
const char *c1, *c2, *c1_begin;
int lo1, lo2;
@@ -409,7 +418,5 @@ static char *ares_striendstr(const char *s1, const char *s2)
c2++;
}
}
- if (c2 == c1 && c2 == NULL)
- return (char *)c1_begin;
- return NULL;
+ return (char *)c1_begin;
}
diff --git a/ares_getsock.c b/ares_getsock.c
index 07d2854..22d3446 100644
--- a/ares_getsock.c
+++ b/ares_getsock.c
@@ -30,9 +30,7 @@ int ares_getsock(ares_channel channel,
/* Are there any active queries? */
int active_queries = !ares__is_list_empty(&(channel->all_queries));
- for (i = 0;
- (i < channel->nservers) && (sockindex < ARES_GETSOCK_MAXNUM);
- i++)
+ for (i = 0; i < channel->nservers; i++)
{
server = &channel->servers[i];
/* We only need to register interest in UDP sockets if we have
@@ -40,7 +38,7 @@ int ares_getsock(ares_channel channel,
*/
if (active_queries && server->udp_socket != ARES_SOCKET_BAD)
{
- if(sockindex >= numsocks)
+ if(sockindex >= numsocks || sockindex >= ARES_GETSOCK_MAXNUM)
break;
socks[sockindex] = server->udp_socket;
bitmap |= ARES_GETSOCK_READABLE(setbits, sockindex);
@@ -52,7 +50,7 @@ int ares_getsock(ares_channel channel,
*/
if (server->tcp_socket != ARES_SOCKET_BAD)
{
- if(sockindex >= numsocks)
+ if(sockindex >= numsocks || sockindex >= ARES_GETSOCK_MAXNUM)
break;
socks[sockindex] = server->tcp_socket;
bitmap |= ARES_GETSOCK_READABLE(setbits, sockindex);
diff --git a/ares_init.3 b/ares_init.3
index fb25306..0baf4b7 100644
--- a/ares_init.3
+++ b/ares_init.3
@@ -16,167 +16,24 @@
.\"
.TH ARES_INIT 3 "5 March 2010"
.SH NAME
-ares_init, ares_init_options \- Initialize a resolver channel
+ares_init \- Initialize a resolver channel
.SH SYNOPSIS
.nf
-.B #include <ares.h>
-.PP
-.B int ares_init(ares_channel *\fIchannelptr\fP)
-.B int ares_init_options(ares_channel *\fIchannelptr\fP,
-.B struct ares_options *\fIoptions\fP, int \fIoptmask\fP)
-.PP
-.B cc file.c -lcares
+#include <ares.h>
+
+int ares_init(ares_channel *\fIchannelptr\fP)
.fi
.SH DESCRIPTION
-The \fBares_init\fP function initializes a communications channel for name
-service lookups. If it returns successfully, \fBares_init\fP will set the
+The \fBares_init(3)\fP function initializes a communications channel for name
+service lookups. If it returns successfully, \fBares_init(3)\fP will set the
variable pointed to by \fIchannelptr\fP to a handle used to identify the name
-service channel. The caller should invoke
-.BR ares_destroy (3)
-on the handle when the channel is no longer needed.
-.PP
-The \fBares_init_options\fP function also initializes a name service channel,
-with additional options useful for applications requiring more control over
-name service configuration. The \fIoptmask\fP parameter specifies which fields
-in the structure pointed to by \fIoptions\fP are set, as follows:
-.TP 18
-.B ARES_OPT_FLAGS
-.B int \fIflags\fP;
-.br
-Flags controlling the behavior of the resolver. See below for a
-description of possible flag values.
-.TP 18
-.B ARES_OPT_TIMEOUT
-.B int \fItimeout\fP;
-.br
-The number of seconds each name server is given to respond to a query on the
-first try. (After the first try, the timeout algorithm becomes more
-complicated, but scales linearly with the value of \fItimeout\fP.) The
-default is five seconds. This option is being deprecated by
-\fIARES_OPT_TIMEOUTMS\fP starting in c-ares 1.5.2.
-.TP 18
-.B ARES_OPT_TIMEOUTMS
-.B int \fItimeout\fP;
-.br
-The number of milliseconds each name server is given to respond to a query on
-the first try. (After the first try, the timeout algorithm becomes more
-complicated, but scales linearly with the value of \fItimeout\fP.) The
-default is five seconds. Note that this option is specified with the same
-struct field as the former \fIARES_OPT_TIMEOUT\fP, it is but the option bits
-that tell c-ares how to interpret the number. This option was added in c-ares
-1.5.2.
-.TP 18
-.B ARES_OPT_TRIES
-.B int \fItries\fP;
-.br
-The number of tries the resolver will try contacting each name server
-before giving up. The default is four tries.
-.TP 18
-.B ARES_OPT_NDOTS
-.B int \fIndots\fP;
-.br
-The number of dots which must be present in a domain name for it to be
-queried for "as is" prior to querying for it with the default domain
-extensions appended. The default value is 1 unless set otherwise by
-resolv.conf or the RES_OPTIONS environment variable.
-.TP 18
-.B ARES_OPT_PORT
-.B unsigned short \fIport\fP;
-.br
-The port to use for queries (both TCP and UDP), in network byte order.
-The default value is 53 (in network byte order), the standard name
-service port.
-.TP 18
-.B ARES_OPT_SERVERS
-.B struct in_addr *\fIservers\fP;
-.br
-.B int \fInservers\fP;
-.br
-The list of IPv4 servers to contact, instead of the servers specified in
-resolv.conf or the local named. In order to allow specification of either
-IPv4 or IPv6 name servers, the
-.BR ares_set_servers(3)
-function must be used instead.
-.TP 18
-.B ARES_OPT_DOMAINS
-.B char **\fIdomains\fP;
-.br
-.B int \fIndomains\fP;
-.br
-The domains to search, instead of the domains specified in resolv.conf
-or the domain derived from the kernel hostname variable.
-.TP 18
-.B ARES_OPT_LOOKUPS
-.B char *\fIlookups\fP;
-.br
-The lookups to perform for host queries.
-.I lookups
-should be set to a string of the characters "b" or "f", where "b"
-indicates a DNS lookup and "f" indicates a lookup in the hosts file.
-.TP 18
-.B ARES_OPT_SOCK_STATE_CB
-.B void (*\fIsock_state_cb\fP)(void *data, int s, int read, int write);
-.br
-.B void *\fIsock_state_cb_data\fP;
-.br
-A callback function to be invoked when a socket changes state.
-.I s
-will be passed the socket whose state has changed;
-.I read
-will be set to true if the socket should listen for read events, and
-.I write
-will be set to true if the socket should listen for write events.
-The value of
-.I sock_state_cb_data
-will be passed as the
-.I data
-argument.
-.PP
-The
-.I flags
-field should be the bitwise or of some subset of the following values:
-.TP 23
-.B ARES_FLAG_USEVC
-Always use TCP queries (the "virtual circuit") instead of UDP
-queries. Normally, TCP is only used if a UDP query yields a truncated
-result.
-.TP 23
-.B ARES_FLAG_PRIMARY
-Only query the first server in the list of servers to query.
-.TP 23
-.B ARES_FLAG_IGNTC
-If a truncated response to a UDP query is received, do not fall back
-to TCP; simply continue on with the truncated response.
-.TP 23
-.B ARES_FLAG_NORECURSE
-Do not set the "recursion desired" bit on outgoing queries, so that the name
-server being contacted will not try to fetch the answer from other servers if
-it doesn't know the answer locally. Be aware that ares will not do the
-recursion for you. Recursion must be handled by the application calling ares
-if \fIARES_FLAG_NORECURSE\fP is set.
-.TP 23
-.B ARES_FLAG_STAYOPEN
-Do not close communications sockets when the number of active queries
-drops to zero.
-.TP 23
-.B ARES_FLAG_NOSEARCH
-Do not use the default search domains; only query hostnames as-is or
-as aliases.
-.TP 23
-.B ARES_FLAG_NOALIASES
-Do not honor the HOSTALIASES environment variable, which normally
-specifies a file of hostname translations.
-.TP 23
-.B ARES_FLAG_NOCHECKRESP
-Do not discard responses with the SERVFAIL, NOTIMP, or REFUSED
-response code or responses whose questions don't match the questions
-in the request. Primarily useful for writing clients which might be
-used to test or debug name servers.
+service channel. The caller should invoke \fIares_destroy(3)\fP on the handle
+when the channel is no longer needed.
+
+The \fIares_init_options(3)\fP function is provide to offer more init
+alternatives.
.SH RETURN VALUES
-.I ares_init
-or
-.I ares_init_options
-can return any of the following values:
+\fIares_init(3)\fP can return any of the following values:
.TP 14
.B ARES_SUCCESS
Initialization succeeded.
@@ -206,11 +63,12 @@ directives override one another. If more that one instance of either
.I domain
or
.I search
-directives is specified, the last occurence wins. For more information,
+directives is specified, the last occurrence wins. For more information,
please see the
.BR resolv.conf (5)
manual page.
.SH SEE ALSO
+.BR ares_init_options(3),
.BR ares_destroy(3),
.BR ares_dup(3),
.BR ares_library_init(3),
diff --git a/ares_init.c b/ares_init.c
index 9a0b6d2..f557947 100644
--- a/ares_init.c
+++ b/ares_init.c
@@ -49,6 +49,10 @@
#define MAX_DNS_PROPERTIES 8
#endif
+#if defined(CARES_USE_LIBRESOLV)
+#include <resolv.h>
+#endif
+
#include "ares.h"
#include "ares_inet_net_pton.h"
#include "ares_library_init.h"
@@ -76,17 +80,18 @@ static int set_options(ares_channel channel, const char *str);
static const char *try_option(const char *p, const char *q, const char *opt);
static int init_id_key(rc4_key* key,int key_data_len);
-#if !defined(WIN32) && !defined(WATT32) && \
- !defined(ANDROID) && !defined(__ANDROID__)
+static int config_sortlist(struct apattern **sortlist, int *nsort,
+ const char *str);
static int sortlist_alloc(struct apattern **sortlist, int *nsort,
struct apattern *pat);
static int ip_addr(const char *s, ssize_t len, struct in_addr *addr);
static void natural_mask(struct apattern *pat);
+#if !defined(WIN32) && !defined(WATT32) && \
+ !defined(ANDROID) && !defined(__ANDROID__) && !defined(CARES_USE_LIBRESOLV)
static int config_domain(ares_channel channel, char *str);
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);
+ const char *bindch, const char *altbindch,
+ const char *filech);
static char *try_config(char *s, const char *opt, char scc);
#endif
@@ -124,9 +129,9 @@ int ares_init_options(ares_channel *channelptr, struct ares_options *options,
#endif
if (ares_library_initialized() != ARES_SUCCESS)
- return ARES_ENOTINITIALIZED;
+ return ARES_ENOTINITIALIZED; /* LCOV_EXCL_LINE: n/a on non-WinSock */
- channel = malloc(sizeof(struct ares_channeldata));
+ channel = ares_malloc(sizeof(struct ares_channeldata));
if (!channel) {
*channelptr = NULL;
return ARES_ENOMEM;
@@ -159,6 +164,8 @@ int ares_init_options(ares_channel *channelptr, struct ares_options *options,
channel->sock_state_cb_data = NULL;
channel->sock_create_cb = NULL;
channel->sock_create_cb_data = NULL;
+ channel->sock_config_cb = NULL;
+ channel->sock_config_cb_data = NULL;
channel->last_server = 0;
channel->last_timeout_processed = (time_t)now.tv_sec;
@@ -182,18 +189,17 @@ int ares_init_options(ares_channel *channelptr, struct ares_options *options,
* precedence to lowest.
*/
- if (status == ARES_SUCCESS) {
- status = init_by_options(channel, options, optmask);
- if (status != ARES_SUCCESS)
- DEBUGF(fprintf(stderr, "Error: init_by_options failed: %s\n",
- ares_strerror(status)));
- }
- if (status == ARES_SUCCESS) {
- status = init_by_environment(channel);
- if (status != ARES_SUCCESS)
- DEBUGF(fprintf(stderr, "Error: init_by_environment failed: %s\n",
- ares_strerror(status)));
+ status = init_by_options(channel, options, optmask);
+ if (status != ARES_SUCCESS) {
+ DEBUGF(fprintf(stderr, "Error: init_by_options failed: %s\n",
+ ares_strerror(status)));
+ /* If we fail to apply user-specified options, fail the whole init process */
+ goto done;
}
+ status = init_by_environment(channel);
+ if (status != ARES_SUCCESS)
+ DEBUGF(fprintf(stderr, "Error: init_by_environment failed: %s\n",
+ ares_strerror(status)));
if (status == ARES_SUCCESS) {
status = init_by_resolv_conf(channel);
if (status != ARES_SUCCESS)
@@ -221,22 +227,23 @@ int ares_init_options(ares_channel *channelptr, struct ares_options *options,
ares_strerror(status)));
}
+done:
if (status != ARES_SUCCESS)
{
/* Something failed; clean up memory we may have allocated. */
if (channel->servers)
- free(channel->servers);
+ ares_free(channel->servers);
if (channel->domains)
{
for (i = 0; i < channel->ndomains; i++)
- free(channel->domains[i]);
- free(channel->domains);
+ ares_free(channel->domains[i]);
+ ares_free(channel->domains);
}
if (channel->sortlist)
- free(channel->sortlist);
+ ares_free(channel->sortlist);
if(channel->lookups)
- free(channel->lookups);
- free(channel);
+ ares_free(channel->lookups);
+ ares_free(channel);
return status;
}
@@ -255,8 +262,8 @@ int ares_init_options(ares_channel *channelptr, struct ares_options *options,
int ares_dup(ares_channel *dest, ares_channel src)
{
struct ares_options opts;
- struct ares_addr_node *servers;
- int ipv6_nservers = 0;
+ struct ares_addr_port_node *servers;
+ int non_v4_default_port = 0;
int i, rc;
int optmask;
@@ -266,7 +273,10 @@ int ares_dup(ares_channel *dest, ares_channel src)
which is most of them */
rc = ares_save_options(src, &opts, &optmask);
if(rc)
+ {
+ ares_destroy_options(&opts);
return rc;
+ }
/* Then create the new channel with those options */
rc = ares_init_options(dest, &opts, optmask);
@@ -280,28 +290,38 @@ int ares_dup(ares_channel *dest, ares_channel src)
/* Now clone the options that ares_save_options() doesn't support. */
(*dest)->sock_create_cb = src->sock_create_cb;
(*dest)->sock_create_cb_data = src->sock_create_cb_data;
+ (*dest)->sock_config_cb = src->sock_config_cb;
+ (*dest)->sock_config_cb_data = src->sock_config_cb_data;
strncpy((*dest)->local_dev_name, src->local_dev_name,
sizeof(src->local_dev_name));
(*dest)->local_ip4 = src->local_ip4;
memcpy((*dest)->local_ip6, src->local_ip6, sizeof(src->local_ip6));
- /* Full name server cloning required when not all are IPv4 */
+ /* Full name server cloning required if there is a non-IPv4, or non-default port, nameserver */
for (i = 0; i < src->nservers; i++)
{
- if (src->servers[i].addr.family != AF_INET) {
- ipv6_nservers++;
+ if ((src->servers[i].addr.family != AF_INET) ||
+ (src->servers[i].addr.udp_port != 0) ||
+ (src->servers[i].addr.tcp_port != 0)) {
+ non_v4_default_port++;
break;
}
}
- if (ipv6_nservers) {
- rc = ares_get_servers(src, &servers);
- if (rc != ARES_SUCCESS)
+ if (non_v4_default_port) {
+ rc = ares_get_servers_ports(src, &servers);
+ if (rc != ARES_SUCCESS) {
+ ares_destroy(*dest);
+ *dest = NULL;
return rc;
- rc = ares_set_servers(*dest, servers);
+ }
+ rc = ares_set_servers_ports(*dest, servers);
ares_free_data(servers);
- if (rc != ARES_SUCCESS)
+ if (rc != ARES_SUCCESS) {
+ ares_destroy(*dest);
+ *dest = NULL;
return rc;
+ }
}
return ARES_SUCCESS; /* everything went fine */
@@ -326,8 +346,8 @@ int ares_save_options(ares_channel channel, struct ares_options *options,
(*optmask) = (ARES_OPT_FLAGS|ARES_OPT_TRIES|ARES_OPT_NDOTS|
ARES_OPT_UDP_PORT|ARES_OPT_TCP_PORT|ARES_OPT_SOCK_STATE_CB|
ARES_OPT_SERVERS|ARES_OPT_DOMAINS|ARES_OPT_LOOKUPS|
- ARES_OPT_SORTLIST|ARES_OPT_TIMEOUTMS) |
- (channel->optmask & ARES_OPT_ROTATE);
+ ARES_OPT_SORTLIST|ARES_OPT_TIMEOUTMS);
+ (*optmask) |= (channel->rotate ? ARES_OPT_ROTATE : ARES_OPT_NOROTATE);
/* Copy easy stuff */
options->flags = channel->flags;
@@ -342,20 +362,24 @@ int ares_save_options(ares_channel channel, struct ares_options *options,
options->sock_state_cb = channel->sock_state_cb;
options->sock_state_cb_data = channel->sock_state_cb_data;
- /* Copy IPv4 servers */
+ /* Copy IPv4 servers that use the default port */
if (channel->nservers) {
for (i = 0; i < channel->nservers; i++)
{
- if (channel->servers[i].addr.family == AF_INET)
+ if ((channel->servers[i].addr.family == AF_INET) &&
+ (channel->servers[i].addr.udp_port == 0) &&
+ (channel->servers[i].addr.tcp_port == 0))
ipv4_nservers++;
}
if (ipv4_nservers) {
- options->servers = malloc(ipv4_nservers * sizeof(struct in_addr));
+ options->servers = ares_malloc(ipv4_nservers * sizeof(struct in_addr));
if (!options->servers)
return ARES_ENOMEM;
for (i = j = 0; i < channel->nservers; i++)
{
- if (channel->servers[i].addr.family == AF_INET)
+ if ((channel->servers[i].addr.family == AF_INET) &&
+ (channel->servers[i].addr.udp_port == 0) &&
+ (channel->servers[i].addr.tcp_port == 0))
memcpy(&options->servers[j++],
&channel->servers[i].addr.addrV4,
sizeof(channel->servers[i].addr.addrV4));
@@ -366,14 +390,14 @@ int ares_save_options(ares_channel channel, struct ares_options *options,
/* copy domains */
if (channel->ndomains) {
- options->domains = malloc(channel->ndomains * sizeof(char *));
+ options->domains = ares_malloc(channel->ndomains * sizeof(char *));
if (!options->domains)
return ARES_ENOMEM;
for (i = 0; i < channel->ndomains; i++)
{
options->ndomains = i;
- options->domains[i] = strdup(channel->domains[i]);
+ options->domains[i] = ares_strdup(channel->domains[i]);
if (!options->domains[i])
return ARES_ENOMEM;
}
@@ -382,14 +406,14 @@ int ares_save_options(ares_channel channel, struct ares_options *options,
/* copy lookups */
if (channel->lookups) {
- options->lookups = strdup(channel->lookups);
+ options->lookups = ares_strdup(channel->lookups);
if (!options->lookups && channel->lookups)
return ARES_ENOMEM;
}
/* copy sortlist */
if (channel->nsort) {
- options->sortlist = malloc(channel->nsort * sizeof(struct apattern));
+ options->sortlist = ares_malloc(channel->nsort * sizeof(struct apattern));
if (!options->sortlist)
return ARES_ENOMEM;
for (i = 0; i < channel->nsort; i++)
@@ -419,6 +443,8 @@ static int init_by_options(ares_channel channel,
channel->ndots = options->ndots;
if ((optmask & ARES_OPT_ROTATE) && channel->rotate == -1)
channel->rotate = 1;
+ if ((optmask & ARES_OPT_NOROTATE) && channel->rotate == -1)
+ channel->rotate = 0;
if ((optmask & ARES_OPT_UDP_PORT) && channel->udp_port == -1)
channel->udp_port = htons(options->udp_port);
if ((optmask & ARES_OPT_TCP_PORT) && channel->tcp_port == -1)
@@ -445,12 +471,14 @@ static int init_by_options(ares_channel channel,
if (options->nservers > 0)
{
channel->servers =
- malloc(options->nservers * sizeof(struct server_state));
+ ares_malloc(options->nservers * sizeof(struct server_state));
if (!channel->servers)
return ARES_ENOMEM;
for (i = 0; i < options->nservers; i++)
{
channel->servers[i].addr.family = AF_INET;
+ channel->servers[i].addr.udp_port = 0;
+ channel->servers[i].addr.tcp_port = 0;
memcpy(&channel->servers[i].addr.addrV4,
&options->servers[i],
sizeof(channel->servers[i].addr.addrV4));
@@ -467,13 +495,13 @@ static int init_by_options(ares_channel channel,
/* Avoid zero size allocations at any cost */
if (options->ndomains > 0)
{
- channel->domains = malloc(options->ndomains * sizeof(char *));
+ channel->domains = ares_malloc(options->ndomains * sizeof(char *));
if (!channel->domains)
return ARES_ENOMEM;
for (i = 0; i < options->ndomains; i++)
{
channel->ndomains = i;
- channel->domains[i] = strdup(options->domains[i]);
+ channel->domains[i] = ares_strdup(options->domains[i]);
if (!channel->domains[i])
return ARES_ENOMEM;
}
@@ -484,19 +512,20 @@ static int init_by_options(ares_channel channel,
/* Set lookups, if given. */
if ((optmask & ARES_OPT_LOOKUPS) && !channel->lookups)
{
- channel->lookups = strdup(options->lookups);
+ channel->lookups = ares_strdup(options->lookups);
if (!channel->lookups)
return ARES_ENOMEM;
}
/* copy sortlist */
- if ((optmask & ARES_OPT_SORTLIST) && (channel->nsort == -1) &&
- (options->nsort>0)) {
- channel->sortlist = malloc(options->nsort * sizeof(struct apattern));
- if (!channel->sortlist)
- return ARES_ENOMEM;
- for (i = 0; i < options->nsort; i++)
- channel->sortlist[i] = options->sortlist[i];
+ if ((optmask & ARES_OPT_SORTLIST) && (channel->nsort == -1)) {
+ if (options->nsort > 0) {
+ channel->sortlist = ares_malloc(options->nsort * sizeof(struct apattern));
+ if (!channel->sortlist)
+ return ARES_ENOMEM;
+ for (i = 0; i < options->nsort; i++)
+ channel->sortlist[i] = options->sortlist[i];
+ }
channel->nsort = options->nsort;
}
@@ -523,7 +552,7 @@ static int init_by_environment(ares_channel channel)
{
status = set_options(channel, res_options);
if (status != ARES_SUCCESS)
- return status;
+ return status; /* LCOV_EXCL_LINE: set_options() never fails */
}
return ARES_SUCCESS;
@@ -558,7 +587,7 @@ static int get_REG_SZ(HKEY hKey, const char *leafKeyName, char **outptr)
/* Allocate buffer of indicated size plus one given that string
might have been stored without null termination */
- *outptr = malloc(size+1);
+ *outptr = ares_malloc(size+1);
if (!*outptr)
return 0;
@@ -567,7 +596,7 @@ static int get_REG_SZ(HKEY hKey, const char *leafKeyName, char **outptr)
(unsigned char *)*outptr, &size);
if ((res != ERROR_SUCCESS) || (size == 1))
{
- free(*outptr);
+ ares_free(*outptr);
*outptr = NULL;
return 0;
}
@@ -600,7 +629,7 @@ static int get_REG_SZ_9X(HKEY hKey, const char *leafKeyName, char **outptr)
/* Allocate buffer of indicated size plus one given that string
might have been stored without null termination */
- *outptr = malloc(size+1);
+ *outptr = ares_malloc(size+1);
if (!*outptr)
return 0;
@@ -609,7 +638,7 @@ static int get_REG_SZ_9X(HKEY hKey, const char *leafKeyName, char **outptr)
(unsigned char *)*outptr, &size);
if ((res != ERROR_SUCCESS) || (size == 1))
{
- free(*outptr);
+ ares_free(*outptr);
*outptr = NULL;
return 0;
}
@@ -810,16 +839,16 @@ static void commajoin(char **dst, const char *src)
if (*dst)
{
- tmp = malloc(strlen(*dst) + strlen(src) + 2);
+ tmp = ares_malloc(strlen(*dst) + strlen(src) + 2);
if (!tmp)
return;
sprintf(tmp, "%s,%s", *dst, src);
- free(*dst);
+ ares_free(*dst);
*dst = tmp;
}
else
{
- *dst = malloc(strlen(src) + 1);
+ *dst = ares_malloc(strlen(src) + 1);
if (!*dst)
return;
strcpy(*dst, src);
@@ -857,7 +886,7 @@ static int get_DNS_NetworkParams(char **outptr)
if (ares_fpGetNetworkParams == ZERO_NULL)
return 0;
- fi = malloc(size);
+ fi = ares_malloc(size);
if (!fi)
return 0;
@@ -865,7 +894,7 @@ static int get_DNS_NetworkParams(char **outptr)
if ((res != ERROR_BUFFER_OVERFLOW) && (res != ERROR_SUCCESS))
goto done;
- newfi = realloc(fi, size);
+ newfi = ares_realloc(fi, size);
if (!newfi)
goto done;
@@ -902,7 +931,7 @@ static int get_DNS_NetworkParams(char **outptr)
done:
if (fi)
- free(fi);
+ ares_free(fi);
if (!*outptr)
return 0;
@@ -950,7 +979,7 @@ static int get_DNS_AdaptersAddresses(char **outptr)
if (ares_fpGetAdaptersAddresses == ZERO_NULL)
return 0;
- ipaa = malloc(Bufsz);
+ ipaa = ares_malloc(Bufsz);
if (!ipaa)
return 0;
@@ -964,7 +993,7 @@ static int get_DNS_AdaptersAddresses(char **outptr)
{
if (Bufsz < ReqBufsz)
{
- newipaa = realloc(ipaa, ReqBufsz);
+ newipaa = ares_realloc(ipaa, ReqBufsz);
if (!newipaa)
goto done;
Bufsz = ReqBufsz;
@@ -980,6 +1009,9 @@ static int get_DNS_AdaptersAddresses(char **outptr)
for (ipaaEntry = ipaa; ipaaEntry; ipaaEntry = ipaaEntry->Next)
{
+ if(ipaaEntry->OperStatus != IfOperStatusUp)
+ continue;
+
for (ipaDNSAddr = ipaaEntry->FirstDnsServerAddress;
ipaDNSAddr;
ipaDNSAddr = ipaDNSAddr->Next)
@@ -1016,7 +1048,7 @@ static int get_DNS_AdaptersAddresses(char **outptr)
done:
if (ipaa)
- free(ipaa);
+ ares_free(ipaa);
if (!*outptr)
return 0;
@@ -1040,14 +1072,20 @@ done:
*/
static int get_DNS_Windows(char **outptr)
{
- /* Try using IP helper API GetAdaptersAddresses() */
- if (get_DNS_AdaptersAddresses(outptr))
- return 1;
-
+ /*
+ Use GetNetworkParams First in case of
+ multiple adapter is enabled on this machine.
+ GetAdaptersAddresses will retrive dummy dns servers.
+ That will slowing DNS lookup.
+ */
/* Try using IP helper API GetNetworkParams() */
if (get_DNS_NetworkParams(outptr))
return 1;
+ /* Try using IP helper API GetAdaptersAddresses() */
+ if (get_DNS_AdaptersAddresses(outptr))
+ return 1;
+
/* Fall-back to registry information */
return get_DNS_Registry(outptr);
}
@@ -1055,7 +1093,8 @@ static int get_DNS_Windows(char **outptr)
static int init_by_resolv_conf(ares_channel channel)
{
-#if !defined(ANDROID) && !defined(__ANDROID__) && !defined(WATT32)
+#if !defined(ANDROID) && !defined(__ANDROID__) && !defined(WATT32) && \
+ !defined(CARES_USE_LIBRESOLV)
char *line = NULL;
#endif
int status = -1, nservers = 0, nsort = 0;
@@ -1070,7 +1109,7 @@ static int init_by_resolv_conf(ares_channel channel)
if (get_DNS_Windows(&line))
{
status = config_nameserver(&servers, &nservers, line);
- free(line);
+ ares_free(line);
}
if (status == ARES_SUCCESS)
@@ -1088,7 +1127,7 @@ static int init_by_resolv_conf(ares_channel channel)
line = getenv("Inet$Resolvers");
status = ARES_EOF;
if (line) {
- char *resolvers = strdup(line), *pos, *space;
+ char *resolvers = ares_strdup(line), *pos, *space;
if (!resolvers)
return ARES_ENOMEM;
@@ -1107,7 +1146,7 @@ static int init_by_resolv_conf(ares_channel channel)
if (status == ARES_SUCCESS)
status = ARES_EOF;
- free(resolvers);
+ ares_free(resolvers);
}
#elif defined(WATT32)
@@ -1120,14 +1159,17 @@ static int init_by_resolv_conf(ares_channel channel)
return ARES_SUCCESS; /* use localhost DNS server */
nservers = i;
- servers = calloc(i, sizeof(struct server_state));
+ servers = ares_malloc(sizeof(struct server_state));
if (!servers)
return ARES_ENOMEM;
+ memset(servers, 0, sizeof(struct server_state));
for (i = 0; def_nameservers[i]; i++)
{
servers[i].addr.addrV4.s_addr = htonl(def_nameservers[i]);
servers[i].addr.family = AF_INET;
+ servers[i].addr.udp_port = 0;
+ servers[i].addr.tcp_port = 0;
}
status = ARES_EOF;
@@ -1147,26 +1189,87 @@ static int init_by_resolv_conf(ares_channel channel)
break;
status = ARES_EOF;
}
+#elif defined(CARES_USE_LIBRESOLV)
+ struct __res_state res;
+ memset(&res, 0, sizeof(res));
+ int result = res_ninit(&res);
+ if (result == 0 && (res.options & RES_INIT)) {
+ status = ARES_EOF;
+
+ if (channel->nservers == -1) {
+ union res_sockaddr_union addr[MAXNS];
+ int nscount = res_getservers(&res, addr, MAXNS);
+ for (int i = 0; i < nscount; ++i) {
+ char str[INET6_ADDRSTRLEN];
+ int config_status;
+ sa_family_t family = addr[i].sin.sin_family;
+ if (family == AF_INET) {
+ ares_inet_ntop(family, &addr[i].sin.sin_addr, str, sizeof(str));
+ } else if (family == AF_INET6) {
+ ares_inet_ntop(family, &addr[i].sin6.sin6_addr, str, sizeof(str));
+ } else {
+ continue;
+ }
+
+ config_status = config_nameserver(&servers, &nservers, str);
+ if (config_status != ARES_SUCCESS) {
+ status = config_status;
+ break;
+ }
+ }
+ }
+ if (channel->ndomains == -1) {
+ int entries = 0;
+ while ((entries < MAXDNSRCH) && res.dnsrch[entries])
+ entries++;
+
+ channel->domains = ares_malloc(entries * sizeof(char *));
+ if (!channel->domains) {
+ status = ARES_ENOMEM;
+ } else {
+ channel->ndomains = entries;
+ for (int i = 0; i < channel->ndomains; ++i) {
+ channel->domains[i] = ares_strdup(res.dnsrch[i]);
+ if (!channel->domains[i])
+ status = ARES_ENOMEM;
+ }
+ }
+ }
+ if (channel->ndots == -1)
+ channel->ndots = res.ndots;
+ if (channel->tries == -1)
+ channel->tries = res.retry;
+ if (channel->rotate == -1)
+ channel->rotate = res.options & RES_ROTATE;
+ if (channel->timeout == -1)
+ channel->timeout = res.retrans * 1000;
+
+ res_ndestroy(&res);
+ }
#else
{
char *p;
FILE *fp;
size_t linesize;
int error;
+ int update_domains;
/* Don't read resolv.conf and friends if we don't have to */
if (ARES_CONFIG_CHECK(channel))
return ARES_SUCCESS;
- fp = fopen(PATH_RESOLV_CONF, "re");
+ /* Only update search domains if they're not already specified */
+ update_domains = (channel->ndomains == -1);
+
+ fp = fopen(PATH_RESOLV_CONF, "r");
if (fp) {
while ((status = ares__read_line(fp, &line, &linesize)) == ARES_SUCCESS)
{
- if ((p = try_config(line, "domain", ';')))
+ if ((p = try_config(line, "domain", ';')) && update_domains)
status = config_domain(channel, p);
else if ((p = try_config(line, "lookup", ';')) && !channel->lookups)
- status = config_lookup(channel, p, "bind", "file");
- else if ((p = try_config(line, "search", ';')))
+ status = config_lookup(channel, p, "bind", NULL, "file");
+ else if ((p = try_config(line, "search", ';')) && update_domains)
status = set_search(channel, p);
else if ((p = try_config(line, "nameserver", ';')) &&
channel->nservers == -1)
@@ -1200,14 +1303,13 @@ static int init_by_resolv_conf(ares_channel channel)
if ((status == ARES_EOF) && (!channel->lookups)) {
/* Many systems (Solaris, Linux, BSD's) use nsswitch.conf */
- fp = fopen("/etc/nsswitch.conf", "re");
+ fp = fopen("/etc/nsswitch.conf", "r");
if (fp) {
while ((status = ares__read_line(fp, &line, &linesize)) ==
ARES_SUCCESS)
{
if ((p = try_config(line, "hosts:", '\0')) && !channel->lookups)
- /* ignore errors */
- (void)config_lookup(channel, p, "dns", "files");
+ (void)config_lookup(channel, p, "dns", "resolve", "files");
}
fclose(fp);
}
@@ -1216,28 +1318,29 @@ static int init_by_resolv_conf(ares_channel channel)
switch(error) {
case ENOENT:
case ESRCH:
- status = ARES_EOF;
break;
default:
DEBUGF(fprintf(stderr, "fopen() failed with error: %d %s\n",
error, strerror(error)));
DEBUGF(fprintf(stderr, "Error opening file: %s\n",
"/etc/nsswitch.conf"));
- status = ARES_EFILE;
}
+
+ /* ignore error, maybe we will get luck in next if clause */
+ status = ARES_EOF;
}
}
if ((status == ARES_EOF) && (!channel->lookups)) {
/* Linux / GNU libc 2.x and possibly others have host.conf */
- fp = fopen("/etc/host.conf", "re");
+ fp = fopen("/etc/host.conf", "r");
if (fp) {
while ((status = ares__read_line(fp, &line, &linesize)) ==
ARES_SUCCESS)
{
if ((p = try_config(line, "order", '\0')) && !channel->lookups)
/* ignore errors */
- (void)config_lookup(channel, p, "bind", "hosts");
+ (void)config_lookup(channel, p, "bind", NULL, "hosts");
}
fclose(fp);
}
@@ -1246,28 +1349,29 @@ static int init_by_resolv_conf(ares_channel channel)
switch(error) {
case ENOENT:
case ESRCH:
- status = ARES_EOF;
break;
default:
DEBUGF(fprintf(stderr, "fopen() failed with error: %d %s\n",
error, strerror(error)));
DEBUGF(fprintf(stderr, "Error opening file: %s\n",
"/etc/host.conf"));
- status = ARES_EFILE;
}
+
+ /* ignore error, maybe we will get luck in next if clause */
+ status = ARES_EOF;
}
}
if ((status == ARES_EOF) && (!channel->lookups)) {
/* Tru64 uses /etc/svc.conf */
- fp = fopen("/etc/svc.conf", "re");
+ fp = fopen("/etc/svc.conf", "r");
if (fp) {
while ((status = ares__read_line(fp, &line, &linesize)) ==
ARES_SUCCESS)
{
if ((p = try_config(line, "hosts=", '\0')) && !channel->lookups)
/* ignore errors */
- (void)config_lookup(channel, p, "bind", "local");
+ (void)config_lookup(channel, p, "bind", NULL, "local");
}
fclose(fp);
}
@@ -1276,19 +1380,20 @@ static int init_by_resolv_conf(ares_channel channel)
switch(error) {
case ENOENT:
case ESRCH:
- status = ARES_EOF;
break;
default:
DEBUGF(fprintf(stderr, "fopen() failed with error: %d %s\n",
error, strerror(error)));
DEBUGF(fprintf(stderr, "Error opening file: %s\n", "/etc/svc.conf"));
- status = ARES_EFILE;
}
+
+ /* ignore error, default value will be chosen for `channel->lookups` */
+ status = ARES_EOF;
}
}
if(line)
- free(line);
+ ares_free(line);
}
#endif
@@ -1297,9 +1402,9 @@ static int init_by_resolv_conf(ares_channel channel)
if (status != ARES_EOF)
{
if (servers != NULL)
- free(servers);
+ ares_free(servers);
if (sortlist != NULL)
- free(sortlist);
+ ares_free(sortlist);
return status;
}
@@ -1348,13 +1453,15 @@ static int init_by_defaults(ares_channel channel)
if (channel->nservers == -1) {
/* If nobody specified servers, try a local named. */
- channel->servers = malloc(sizeof(struct server_state));
+ channel->servers = ares_malloc(sizeof(struct server_state));
if (!channel->servers) {
rc = ARES_ENOMEM;
goto error;
}
channel->servers[0].addr.family = AF_INET;
channel->servers[0].addr.addrV4.s_addr = htonl(INADDR_LOOPBACK);
+ channel->servers[0].addr.udp_port = 0;
+ channel->servers[0].addr.tcp_port = 0;
channel->nservers = 1;
}
@@ -1379,7 +1486,7 @@ static int init_by_defaults(ares_channel channel)
int res;
channel->ndomains = 0; /* default to none */
- hostname = malloc(len);
+ hostname = ares_malloc(len);
if(!hostname) {
rc = ARES_ENOMEM;
goto error;
@@ -1392,7 +1499,7 @@ static int init_by_defaults(ares_channel channel)
char *p;
len *= 2;
lenv *= 2;
- p = realloc(hostname, len);
+ p = ares_realloc(hostname, len);
if(!p) {
rc = ARES_ENOMEM;
goto error;
@@ -1405,17 +1512,17 @@ static int init_by_defaults(ares_channel channel)
goto error;
}
- } WHILE_FALSE;
+ } while (res != 0);
dot = strchr(hostname, '.');
if (dot) {
/* a dot was found */
- channel->domains = malloc(sizeof(char *));
+ channel->domains = ares_malloc(sizeof(char *));
if (!channel->domains) {
rc = ARES_ENOMEM;
goto error;
}
- channel->domains[0] = strdup(dot + 1);
+ channel->domains[0] = ares_strdup(dot + 1);
if (!channel->domains[0]) {
rc = ARES_ENOMEM;
goto error;
@@ -1431,7 +1538,7 @@ static int init_by_defaults(ares_channel channel)
}
if (!channel->lookups) {
- channel->lookups = strdup("fb");
+ channel->lookups = ares_strdup("fb");
if (!channel->lookups)
rc = ARES_ENOMEM;
}
@@ -1439,31 +1546,31 @@ static int init_by_defaults(ares_channel channel)
error:
if(rc) {
if(channel->servers) {
- free(channel->servers);
+ ares_free(channel->servers);
channel->servers = NULL;
}
if(channel->domains && channel->domains[0])
- free(channel->domains[0]);
+ ares_free(channel->domains[0]);
if(channel->domains) {
- free(channel->domains);
+ ares_free(channel->domains);
channel->domains = NULL;
}
if(channel->lookups) {
- free(channel->lookups);
+ ares_free(channel->lookups);
channel->lookups = NULL;
}
}
if(hostname)
- free(hostname);
+ ares_free(hostname);
return rc;
}
#if !defined(WIN32) && !defined(WATT32) && \
- !defined(ANDROID) && !defined(__ANDROID__)
+ !defined(ANDROID) && !defined(__ANDROID__) && !defined(CARES_USE_LIBRESOLV)
static int config_domain(ares_channel channel, char *str)
{
char *q;
@@ -1485,11 +1592,15 @@ static int config_domain(ares_channel channel, char *str)
#endif
static int config_lookup(ares_channel channel, const char *str,
- const char *bindch, const char *filech)
+ const char *bindch, const char *altbindch,
+ const char *filech)
{
char lookups[3], *l;
const char *vqualifier p;
+ if (altbindch == NULL)
+ altbindch = bindch;
+
/* Set the lookup order. Only the first letter of each work
* is relevant, and it has to be "b" for DNS or "f" for the
* host file. Ignore everything else.
@@ -1498,8 +1609,8 @@ static int config_lookup(ares_channel channel, const char *str,
p = str;
while (*p)
{
- if ((*p == *bindch || *p == *filech) && l < lookups + 2) {
- if (*p == *bindch) *l++ = 'b';
+ if ((*p == *bindch || *p == *altbindch || *p == *filech) && l < lookups + 2) {
+ if (*p == *bindch || *p == *altbindch) *l++ = 'b';
else *l++ = 'f';
}
while (*p && !ISSPACE(*p) && (*p != ','))
@@ -1508,10 +1619,10 @@ static int config_lookup(ares_channel channel, const char *str,
p++;
}
*l = '\0';
- channel->lookups = strdup(lookups);
+ channel->lookups = ares_strdup(lookups);
return (channel->lookups) ? ARES_SUCCESS : ARES_ENOMEM;
}
-#endif /* !WIN32 & !WATT32 & !ANDROID & !__ANDROID__ */
+#endif /* !WIN32 & !WATT32 & !ANDROID & !__ANDROID__ & !CARES_USE_LIBRESOLV */
#ifndef WATT32
static int config_nameserver(struct server_state **servers, int *nservers,
@@ -1554,13 +1665,15 @@ static int config_nameserver(struct server_state **servers, int *nservers,
continue;
/* Resize servers state array. */
- newserv = realloc(*servers, (*nservers + 1) *
- sizeof(struct server_state));
+ newserv = ares_realloc(*servers, (*nservers + 1) *
+ sizeof(struct server_state));
if (!newserv)
return ARES_ENOMEM;
/* Store address data. */
newserv[*nservers].addr.family = host.family;
+ newserv[*nservers].addr.udp_port = 0;
+ newserv[*nservers].addr.tcp_port = 0;
if (host.family == AF_INET)
memcpy(&newserv[*nservers].addr.addrV4, &host.addrV4,
sizeof(host.addrV4));
@@ -1575,8 +1688,8 @@ static int config_nameserver(struct server_state **servers, int *nservers,
return ARES_SUCCESS;
}
+#endif /* !WATT32 */
-#if !defined(WIN32) && !defined(ANDROID) && !defined(__ANDROID__)
static int config_sortlist(struct apattern **sortlist, int *nsort,
const char *str)
{
@@ -1615,8 +1728,11 @@ static int config_sortlist(struct apattern **sortlist, int *nsort,
pat.type = PATTERN_CIDR;
pat.mask.bits = (unsigned short)bits;
pat.family = AF_INET6;
- if (!sortlist_alloc(sortlist, nsort, &pat))
+ if (!sortlist_alloc(sortlist, nsort, &pat)) {
+ ares_free(*sortlist);
+ *sortlist = NULL;
return ARES_ENOMEM;
+ }
}
else if (ipbufpfx[0] &&
(bits = ares_inet_net_pton(AF_INET, ipbufpfx, &pat.addrV4,
@@ -1625,8 +1741,11 @@ static int config_sortlist(struct apattern **sortlist, int *nsort,
pat.type = PATTERN_CIDR;
pat.mask.bits = (unsigned short)bits;
pat.family = AF_INET;
- if (!sortlist_alloc(sortlist, nsort, &pat))
+ if (!sortlist_alloc(sortlist, nsort, &pat)) {
+ ares_free(*sortlist);
+ *sortlist = NULL;
return ARES_ENOMEM;
+ }
}
/* See if it is just a regular IP */
else if (ip_addr(ipbuf, q-str, &pat.addrV4) == 0)
@@ -1642,8 +1761,11 @@ static int config_sortlist(struct apattern **sortlist, int *nsort,
natural_mask(&pat);
pat.family = AF_INET;
pat.type = PATTERN_MASK;
- if (!sortlist_alloc(sortlist, nsort, &pat))
+ if (!sortlist_alloc(sortlist, nsort, &pat)) {
+ ares_free(*sortlist);
+ *sortlist = NULL;
return ARES_ENOMEM;
+ }
}
else
{
@@ -1657,8 +1779,6 @@ static int config_sortlist(struct apattern **sortlist, int *nsort,
return ARES_SUCCESS;
}
-#endif /* !WIN32 & !ANDROID & !__ANDROID__ */
-#endif /* !WATT32 */
static int set_search(ares_channel channel, const char *str)
{
@@ -1666,13 +1786,14 @@ static int set_search(ares_channel channel, const char *str)
const char *p, *q;
if(channel->ndomains != -1) {
+ /* LCOV_EXCL_START: all callers check ndomains == -1 */
/* if we already have some domains present, free them first */
for(n=0; n < channel->ndomains; n++)
- free(channel->domains[n]);
- free(channel->domains);
+ ares_free(channel->domains[n]);
+ ares_free(channel->domains);
channel->domains = NULL;
channel->ndomains = -1;
- }
+ } /* LCOV_EXCL_STOP */
/* Count the domains given. */
n = 0;
@@ -1692,7 +1813,7 @@ static int set_search(ares_channel channel, const char *str)
return ARES_SUCCESS;
}
- channel->domains = malloc(n * sizeof(char *));
+ channel->domains = ares_malloc(n * sizeof(char *));
if (!channel->domains)
return ARES_ENOMEM;
@@ -1705,7 +1826,7 @@ static int set_search(ares_channel channel, const char *str)
q = p;
while (*q && !ISSPACE(*q))
q++;
- channel->domains[n] = malloc(q - p + 1);
+ channel->domains[n] = ares_malloc(q - p + 1);
if (!channel->domains[n])
return ARES_ENOMEM;
memcpy(channel->domains[n], p, q - p);
@@ -1757,7 +1878,7 @@ static const char *try_option(const char *p, const char *q, const char *opt)
}
#if !defined(WIN32) && !defined(WATT32) && \
- !defined(ANDROID) && !defined(__ANDROID__)
+ !defined(ANDROID) && !defined(__ANDROID__) && !defined(CARES_USE_LIBRESOLV)
static char *try_config(char *s, const char *opt, char scc)
{
size_t len;
@@ -1766,7 +1887,7 @@ static char *try_config(char *s, const char *opt, char scc)
if (!s || !opt)
/* no line or no option */
- return NULL;
+ return NULL; /* LCOV_EXCL_LINE */
/* Hash '#' character is always used as primary comment char, additionally
a not-NUL secondary comment char will be considered when specified. */
@@ -1798,7 +1919,7 @@ static char *try_config(char *s, const char *opt, char scc)
if ((len = strlen(opt)) == 0)
/* empty option */
- return NULL;
+ return NULL; /* LCOV_EXCL_LINE */
if (strncmp(p, opt, len) != 0)
/* line and option do not match */
@@ -1809,7 +1930,7 @@ static char *try_config(char *s, const char *opt, char scc)
if (!*p)
/* no option value */
- return NULL;
+ return NULL; /* LCOV_EXCL_LINE */
if ((opt[len-1] != ':') && (opt[len-1] != '=') && !ISSPACE(*p))
/* whitespace between option name and value is mandatory
@@ -1827,19 +1948,7 @@ static char *try_config(char *s, const char *opt, char scc)
/* return pointer to option value */
return p;
}
-
-static int sortlist_alloc(struct apattern **sortlist, int *nsort,
- struct apattern *pat)
-{
- struct apattern *newsort;
- newsort = realloc(*sortlist, (*nsort + 1) * sizeof(struct apattern));
- if (!newsort)
- return 0;
- newsort[*nsort] = *pat;
- *sortlist = newsort;
- (*nsort)++;
- return 1;
-}
+#endif /* !WIN32 & !WATT32 & !ANDROID & !__ANDROID__ */
static int ip_addr(const char *ipbuf, ssize_t len, struct in_addr *addr)
{
@@ -1873,7 +1982,19 @@ static void natural_mask(struct apattern *pat)
else
pat->mask.addr4.s_addr = htonl(IN_CLASSC_NET);
}
-#endif /* !WIN32 & !WATT32 & !ANDROID & !__ANDROID__ */
+
+static int sortlist_alloc(struct apattern **sortlist, int *nsort,
+ struct apattern *pat)
+{
+ struct apattern *newsort;
+ newsort = ares_realloc(*sortlist, (*nsort + 1) * sizeof(struct apattern));
+ if (!newsort)
+ return 0;
+ newsort[*nsort] = *pat;
+ *sortlist = newsort;
+ (*nsort)++;
+ return 1;
+}
/* initialize an rc4 key. If possible a cryptographically secure random key
is generated using a suitable function (for example win32's RtlGenRandom as
@@ -1896,7 +2017,7 @@ static void randomize_key(unsigned char* key,int key_data_len)
}
#else /* !WIN32 */
#ifdef RANDOM_FILE
- FILE *f = fopen(RANDOM_FILE, "rbe");
+ FILE *f = fopen(RANDOM_FILE, "rb");
if(f) {
counter = aresx_uztosi(fread(key, 1, key_data_len, f));
fclose(f);
@@ -1906,7 +2027,7 @@ static void randomize_key(unsigned char* key,int key_data_len)
if (!randomized) {
for (;counter<key_data_len;counter++)
- key[counter]=(unsigned char)(rand() % 256);
+ key[counter]=(unsigned char)(rand() % 256); /* LCOV_EXCL_LINE */
}
}
@@ -1918,9 +2039,10 @@ static int init_id_key(rc4_key* key,int key_data_len)
short counter;
unsigned char *key_data_ptr = 0;
- key_data_ptr = calloc(1,key_data_len);
+ key_data_ptr = ares_malloc(key_data_len);
if (!key_data_ptr)
return ARES_ENOMEM;
+ memset(key_data_ptr, 0, key_data_len);
state = &key->state[0];
for(counter = 0; counter < 256; counter++)
@@ -1939,7 +2061,7 @@ static int init_id_key(rc4_key* key,int key_data_len)
index1 = (unsigned char)((index1 + 1) % key_data_len);
}
- free(key_data_ptr);
+ ares_free(key_data_ptr);
return ARES_SUCCESS;
}
@@ -1973,6 +2095,33 @@ void ares_set_socket_callback(ares_channel channel,
channel->sock_create_cb_data = data;
}
+void ares_set_socket_configure_callback(ares_channel channel,
+ ares_sock_config_callback cb,
+ void *data)
+{
+ channel->sock_config_cb = cb;
+ channel->sock_config_cb_data = data;
+}
+
+int ares_set_sortlist(ares_channel channel, const char *sortstr)
+{
+ int nsort = 0;
+ struct apattern *sortlist = NULL;
+ int status;
+
+ if (!channel)
+ return ARES_ENODATA;
+
+ status = config_sortlist(&sortlist, &nsort, sortstr);
+ if (status == ARES_SUCCESS && sortlist) {
+ if (channel->sortlist)
+ ares_free(channel->sortlist);
+ channel->sortlist = sortlist;
+ channel->nsort = nsort;
+ }
+ return status;
+}
+
void ares__init_servers_state(ares_channel channel)
{
struct server_state *server;
diff --git a/ares_init_options.3 b/ares_init_options.3
index 27b149b..ff677c9 100644
--- a/ares_init_options.3
+++ b/ares_init_options.3
@@ -1 +1,262 @@
-.so man3/ares_init.3
+.\"
+.\" Copyright 1998 by the Massachusetts Institute of Technology.
+.\" Copyright (C) 2004-2010 by Daniel Stenberg
+.\"
+.\" 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.
+.\"
+.TH ARES_INIT 3 "5 March 2010"
+.SH NAME
+ares_init_options \- Initialize a resolver channel
+.SH SYNOPSIS
+.nf
+#include <ares.h>
+
+int ares_init_options(ares_channel *\fIchannelptr\fP,
+ struct ares_options *\fIoptions\fP,
+ int \fIoptmask\fP)
+.fi
+.SH DESCRIPTION
+The \fBares_init_options(3)\fP function initializes a communications channel
+for name service lookups. If it returns successfully,
+\fBares_init_options(3)\fP will set the variable pointed to by
+\fIchannelptr\fP to a handle used to identify the name service channel. The
+caller should invoke \fIares_destroy(3)\fP on the handle when the channel is
+no longer needed.
+
+The \fIoptmask\fP parameter generally specifies which fields in the structure pointed to
+by \fIoptions\fP are set, as follows:
+.TP 18
+.B ARES_OPT_FLAGS
+.B int \fIflags\fP;
+.br
+Flags controlling the behavior of the resolver. See below for a
+description of possible flag values.
+.TP 18
+.B ARES_OPT_TIMEOUT
+.B int \fItimeout\fP;
+.br
+The number of seconds each name server is given to respond to a query on the
+first try. (After the first try, the timeout algorithm becomes more
+complicated, but scales linearly with the value of \fItimeout\fP.) The
+default is five seconds. This option is being deprecated by
+\fIARES_OPT_TIMEOUTMS\fP starting in c-ares 1.5.2.
+.TP 18
+.B ARES_OPT_TIMEOUTMS
+.B int \fItimeout\fP;
+.br
+The number of milliseconds each name server is given to respond to a query on
+the first try. (After the first try, the timeout algorithm becomes more
+complicated, but scales linearly with the value of \fItimeout\fP.) The
+default is five seconds. Note that this option is specified with the same
+struct field as the former \fIARES_OPT_TIMEOUT\fP, it is but the option bits
+that tell c-ares how to interpret the number. This option was added in c-ares
+1.5.2.
+.TP 18
+.B ARES_OPT_TRIES
+.B int \fItries\fP;
+.br
+The number of tries the resolver will try contacting each name server
+before giving up. The default is four tries.
+.TP 18
+.B ARES_OPT_NDOTS
+.B int \fIndots\fP;
+.br
+The number of dots which must be present in a domain name for it to be
+queried for "as is" prior to querying for it with the default domain
+extensions appended. The default value is 1 unless set otherwise by
+resolv.conf or the RES_OPTIONS environment variable.
+.TP 18
+.B ARES_OPT_UDP_PORT
+.B unsigned short \fIudp_port\fP;
+.br
+The port to use for queries over UDP, in network byte order.
+The default value is 53 (in network byte order), the standard name
+service port.
+.TP 18
+.B ARES_OPT_TCP_PORT
+.B unsigned short \fItcp_port\fP;
+.br
+The port to use for queries over TCP, in network byte order.
+The default value is 53 (in network byte order), the standard name
+service port.
+.TP 18
+.B ARES_OPT_SERVERS
+.B struct in_addr *\fIservers\fP;
+.br
+.B int \fInservers\fP;
+.br
+The list of IPv4 servers to contact, instead of the servers specified in
+resolv.conf or the local named. In order to allow specification of either
+IPv4 or IPv6 name servers, the
+.BR ares_set_servers(3)
+function must be used instead.
+.TP 18
+.B ARES_OPT_DOMAINS
+.B char **\fIdomains\fP;
+.br
+.B int \fIndomains\fP;
+.br
+The domains to search, instead of the domains specified in resolv.conf
+or the domain derived from the kernel hostname variable.
+.TP 18
+.B ARES_OPT_LOOKUPS
+.B char *\fIlookups\fP;
+.br
+The lookups to perform for host queries.
+.I lookups
+should be set to a string of the characters "b" or "f", where "b"
+indicates a DNS lookup and "f" indicates a lookup in the hosts file.
+.TP 18
+.B ARES_OPT_SOCK_STATE_CB
+.B void (*\fIsock_state_cb\fP)(void *data, int s, int read, int write);
+.br
+.B void *\fIsock_state_cb_data\fP;
+.br
+A callback function to be invoked when a socket changes state.
+.I s
+will be passed the socket whose state has changed;
+.I read
+will be set to true if the socket should listen for read events, and
+.I write
+will be set to true if the socket should listen for write events.
+The value of
+.I sock_state_cb_data
+will be passed as the
+.I data
+argument.
+.TP 18
+.B ARES_OPT_SORTLIST
+.B struct apattern *\fIsortlist\fP;
+.br
+.B int \fInsort\fP;
+.br
+A list of IP address ranges that specifies the order of preference that
+results from \fIares_gethostbyname\fP should be returned in. Note that
+this can only be used with a sortlist retrieved via
+\fBares_save_options(3)\fP (because
+.B struct apattern
+is opaque); to set a fresh sort list, use \fBares_set_sortlist(3)\fP.
+.TP 18
+.B ARES_OPT_SOCK_SNDBUF
+.B int \fIsocket_send_buffer_size\fP;
+.br
+The send buffer size to set for the socket.
+.TP 18
+.B ARES_OPT_SOCK_RCVBUF
+.B int \fIsocket_receive_buffer_size\fP;
+.br
+The receive buffer size to set for the socket.
+.TP 18
+.B ARES_OPT_EDNSPSZ
+.B int \fIednspsz\fP;
+.br
+The message size to be advertized in EDNS; only takes effect if the
+.B ARES_FLAG_EDNS
+flag is set.
+.br
+.PP
+The \fIoptmask\fP parameter also includes options without a corresponding
+field in the
+.B ares_options
+structure, as follows:
+.TP 23
+.B ARES_OPT_ROTATE
+Perform round-robin selection of the nameservers configured for the channel
+for each resolution.
+.TP 23
+.B ARES_OPT_NOROTATE
+Do not perform round-robin nameserver selection; always use the list of
+nameservers in the same order.
+.PP
+The
+.I flags
+field should be the bitwise or of some subset of the following values:
+.TP 23
+.B ARES_FLAG_USEVC
+Always use TCP queries (the "virtual circuit") instead of UDP
+queries. Normally, TCP is only used if a UDP query yields a truncated
+result.
+.TP 23
+.B ARES_FLAG_PRIMARY
+Only query the first server in the list of servers to query.
+.TP 23
+.B ARES_FLAG_IGNTC
+If a truncated response to a UDP query is received, do not fall back
+to TCP; simply continue on with the truncated response.
+.TP 23
+.B ARES_FLAG_NORECURSE
+Do not set the "recursion desired" bit on outgoing queries, so that the name
+server being contacted will not try to fetch the answer from other servers if
+it doesn't know the answer locally. Be aware that ares will not do the
+recursion for you. Recursion must be handled by the application calling ares
+if \fIARES_FLAG_NORECURSE\fP is set.
+.TP 23
+.B ARES_FLAG_STAYOPEN
+Do not close communications sockets when the number of active queries
+drops to zero.
+.TP 23
+.B ARES_FLAG_NOSEARCH
+Do not use the default search domains; only query hostnames as-is or
+as aliases.
+.TP 23
+.B ARES_FLAG_NOALIASES
+Do not honor the HOSTALIASES environment variable, which normally
+specifies a file of hostname translations.
+.TP 23
+.B ARES_FLAG_NOCHECKRESP
+Do not discard responses with the SERVFAIL, NOTIMP, or REFUSED
+response code or responses whose questions don't match the questions
+in the request. Primarily useful for writing clients which might be
+used to test or debug name servers.
+.TP 23
+.B ARES_FLAG_EDNS
+Include an EDNS pseudo-resource record (RFC 2671) in generated requests.
+.SH RETURN VALUES
+\fBares_init_options(3)\fP can return any of the following values:
+.TP 14
+.B ARES_SUCCESS
+Initialization succeeded.
+.TP 14
+.B ARES_EFILE
+A configuration file could not be read.
+.TP 14
+.B ARES_ENOMEM
+The process's available memory was exhausted.
+.TP 14
+.B ARES_ENOTINITIALIZED
+c-ares library initialization not yet performed.
+.SH NOTES
+When initializing from
+.B /etc/resolv.conf,
+\fBares_init_options(3)\fP reads the \fIdomain\fP and \fIsearch\fP directives
+to allow lookups of short names relative to the domains specified. The
+\fIdomain\fP and \fIsearch\fP directives override one another. If more that
+one instance of either \fIdomain\fP or \fIsearch\fP directives is specified,
+the last occurrence wins. For more information, please see the
+.BR resolv.conf (5)
+manual page.
+.SH SEE ALSO
+.BR ares_init(3),
+.BR ares_destroy(3),
+.BR ares_dup(3),
+.BR ares_library_init(3),
+.BR ares_save_options(3),
+.BR ares_set_servers(3),
+.BR ares_set_sortlist(3)
+.SH AUTHOR
+Greg Hudson, MIT Information Systems
+.br
+Copyright 1998 by the Massachusetts Institute of Technology.
+.br
+Copyright (C) 2004-2010 by Daniel Stenberg.
+
diff --git a/ares_ipv6.h b/ares_ipv6.h
index 6f1022a..b0017f1 100644
--- a/ares_ipv6.h
+++ b/ares_ipv6.h
@@ -47,16 +47,16 @@ struct addrinfo
#endif
#ifndef NS_IN6ADDRSZ
-#if SIZEOF_STRUCT_IN6_ADDR == 0
+#ifndef HAVE_STRUCT_IN6_ADDR
/* We cannot have it set to zero, so we pick a fixed value here */
#define NS_IN6ADDRSZ 16
#else
-#define NS_IN6ADDRSZ SIZEOF_STRUCT_IN6_ADDR
+#define NS_IN6ADDRSZ sizeof(struct in6_addr)
#endif
#endif
#ifndef NS_INADDRSZ
-#define NS_INADDRSZ SIZEOF_STRUCT_IN_ADDR
+#define NS_INADDRSZ sizeof(struct in_addr)
#endif
#ifndef NS_INT16SZ
@@ -71,7 +71,7 @@ struct addrinfo
#endif
#endif
-/* Defined in ares_net_pton.c for no particular reason. */
+/* Defined in inet_net_pton.c for no particular reason. */
extern const struct ares_in6_addr ares_in6addr_any; /* :: */
diff --git a/ares_library_init.3 b/ares_library_init.3
index 797476b..4734f92 100644
--- a/ares_library_init.3
+++ b/ares_library_init.3
@@ -19,11 +19,14 @@
ares_library_init \- c-ares library initialization
.SH SYNOPSIS
.nf
-.B #include <ares.h>
-.PP
-.B int ares_library_init(int \fIflags\fP)
-.PP
-.B cc file.c -lcares
+#include <ares.h>
+
+int ares_library_init(int \fIflags\fP)
+
+int ares_library_init_mem(int \fIflags\fP,
+ void *(*\fIamalloc\fP)(size_t),
+ void (*\fIafree\fP)(void *ptr),
+ void (*\fIarealloc\fP)(void *ptr, size_t size))
.fi
.SH DESCRIPTION
.PP
@@ -51,6 +54,12 @@ ORing the values together. In normal operation you should specify
\fIARES_LIB_INIT_ALL\fP. Don't use any other value unless you are
familiar with it and trying to control some internal c-ares feature.
.PP
+The
+.B ares_library_init_mem
+function allows the caller to provide memory management functions that the
+c-ares library will be use instead of \fImalloc(3)\fP, \fIfree(3)\fP and
+\fIrealloc(3)\fP.
+.PP
.B This function is not thread safe.
You have to call it once the program has started, but this call must be done
before the program starts any other thread. This is required to avoid
diff --git a/ares_library_init.c b/ares_library_init.c
index 770e7c2..c885a16 100644
--- a/ares_library_init.c
+++ b/ares_library_init.c
@@ -34,6 +34,11 @@ fpGetAdaptersAddresses_t ares_fpGetAdaptersAddresses = ZERO_NULL;
static unsigned int ares_initialized;
static int ares_init_flags;
+/* library-private global vars with visibility across the whole library */
+void *(*ares_malloc)(size_t size) = malloc;
+void *(*ares_realloc)(void *ptr, size_t size) = realloc;
+void (*ares_free)(void *ptr) = free;
+
#ifdef USE_WINSOCK
static HMODULE hnd_iphlpapi;
static HMODULE hnd_advapi32;
@@ -45,7 +50,7 @@ static int ares_win32_init(void)
#ifdef USE_WINSOCK
hnd_iphlpapi = 0;
- hnd_iphlpapi = LoadLibrary("iphlpapi.dll");
+ hnd_iphlpapi = LoadLibraryW(L"iphlpapi.dll");
if (!hnd_iphlpapi)
return ARES_ELOADIPHLPAPI;
@@ -73,7 +78,7 @@ static int ares_win32_init(void)
*/
hnd_advapi32 = 0;
- hnd_advapi32 = LoadLibrary("advapi32.dll");
+ hnd_advapi32 = LoadLibraryW(L"advapi32.dll");
if (hnd_advapi32)
{
ares_fpSystemFunction036 = (fpSystemFunction036_t)
@@ -111,7 +116,7 @@ int ares_library_init(int flags)
{
res = ares_win32_init();
if (res != ARES_SUCCESS)
- return res;
+ return res; /* LCOV_EXCL_LINE: can't test Win32 init failure */
}
ares_init_flags = flags;
@@ -119,6 +124,20 @@ int ares_library_init(int flags)
return ARES_SUCCESS;
}
+int ares_library_init_mem(int flags,
+ void *(*amalloc)(size_t size),
+ void (*afree)(void *ptr),
+ void *(*arealloc)(void *ptr, size_t size))
+{
+ if (amalloc)
+ ares_malloc = amalloc;
+ if (arealloc)
+ ares_realloc = arealloc;
+ if (afree)
+ ares_free = afree;
+ return ares_library_init(flags);
+}
+
void ares_library_cleanup(void)
{
@@ -132,6 +151,9 @@ void ares_library_cleanup(void)
ares_win32_cleanup();
ares_init_flags = ARES_LIB_INIT_NONE;
+ ares_malloc = malloc;
+ ares_realloc = realloc;
+ ares_free = free;
}
@@ -143,5 +165,3 @@ int ares_library_initialized(void)
#endif
return ARES_SUCCESS;
}
-
-
diff --git a/ares_nowarn.c b/ares_nowarn.c
index a4dce89..7f9035c 100644
--- a/ares_nowarn.c
+++ b/ares_nowarn.c
@@ -1,5 +1,5 @@
-/* Copyright (C) 2010-2012 by Daniel Stenberg
+/* Copyright (C) 2010-2013 by Daniel Stenberg
*
* Permission to use, copy, modify, and distribute this
* software and its documentation for any purpose and without
@@ -21,6 +21,10 @@
# include <assert.h>
#endif
+#ifdef HAVE_LIMITS_H
+#include <limits.h>
+#endif
+
#if defined(__INTEL_COMPILER) && defined(__unix__)
#ifdef HAVE_NETINET_IN_H
@@ -36,49 +40,22 @@
#include "ares_nowarn.h"
-#if (SIZEOF_SHORT == 2)
+#ifndef HAVE_LIMITS_H
+/* systems without <limits.h> we guess have 16 bit shorts, 32bit ints and
+ 32bit longs */
# define CARES_MASK_SSHORT 0x7FFF
# define CARES_MASK_USHORT 0xFFFF
-#elif (SIZEOF_SHORT == 4)
-# define CARES_MASK_SSHORT 0x7FFFFFFF
-# define CARES_MASK_USHORT 0xFFFFFFFF
-#elif (SIZEOF_SHORT == 8)
-# define CARES_MASK_SSHORT 0x7FFFFFFFFFFFFFFF
-# define CARES_MASK_USHORT 0xFFFFFFFFFFFFFFFF
-#else
-# error "SIZEOF_SHORT not defined"
-#endif
-
-#if (SIZEOF_INT == 2)
-# define CARES_MASK_SINT 0x7FFF
-# define CARES_MASK_UINT 0xFFFF
-#elif (SIZEOF_INT == 4)
-# define CARES_MASK_SINT 0x7FFFFFFF
-# define CARES_MASK_UINT 0xFFFFFFFF
-#elif (SIZEOF_INT == 8)
-# define CARES_MASK_SINT 0x7FFFFFFFFFFFFFFF
-# define CARES_MASK_UINT 0xFFFFFFFFFFFFFFFF
-#elif (SIZEOF_INT == 16)
-# define CARES_MASK_SINT 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
-# define CARES_MASK_UINT 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
-#else
-# error "SIZEOF_INT not defined"
-#endif
-
-#if (CARES_SIZEOF_LONG == 2)
-# define CARES_MASK_SLONG 0x7FFFL
-# define CARES_MASK_ULONG 0xFFFFUL
-#elif (CARES_SIZEOF_LONG == 4)
-# define CARES_MASK_SLONG 0x7FFFFFFFL
-# define CARES_MASK_ULONG 0xFFFFFFFFUL
-#elif (CARES_SIZEOF_LONG == 8)
-# define CARES_MASK_SLONG 0x7FFFFFFFFFFFFFFFL
-# define CARES_MASK_ULONG 0xFFFFFFFFFFFFFFFFUL
-#elif (CARES_SIZEOF_LONG == 16)
-# define CARES_MASK_SLONG 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFL
-# define CARES_MASK_ULONG 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFUL
+# define CARES_MASK_SINT 0x7FFFFFFF
+# define CARES_MASK_UINT 0xFFFFFFFF
+# define CARES_MASK_SLONG 0x7FFFFFFFL
+# define CARES_MASK_ULONG 0xFFFFFFFFUL
#else
-# error "CARES_SIZEOF_LONG not defined"
+# define CARES_MASK_SSHORT SHRT_MAX
+# define CARES_MASK_USHORT USHRT_MAX
+# define CARES_MASK_SINT INT_MAX
+# define CARES_MASK_UINT UINT_MAX
+# define CARES_MASK_SLONG LONG_MAX
+# define CARES_MASK_ULONG ULONG_MAX
#endif
/*
diff --git a/ares_options.c b/ares_options.c
index 76d82df..c3cbd1d 100644
--- a/ares_options.c
+++ b/ares_options.c
@@ -83,6 +83,62 @@ int ares_get_servers(ares_channel channel,
return status;
}
+int ares_get_servers_ports(ares_channel channel,
+ struct ares_addr_port_node **servers)
+{
+ struct ares_addr_port_node *srvr_head = NULL;
+ struct ares_addr_port_node *srvr_last = NULL;
+ struct ares_addr_port_node *srvr_curr;
+ int status = ARES_SUCCESS;
+ int i;
+
+ if (!channel)
+ return ARES_ENODATA;
+
+ for (i = 0; i < channel->nservers; i++)
+ {
+ /* Allocate storage for this server node appending it to the list */
+ srvr_curr = ares_malloc_data(ARES_DATATYPE_ADDR_PORT_NODE);
+ if (!srvr_curr)
+ {
+ status = ARES_ENOMEM;
+ break;
+ }
+ if (srvr_last)
+ {
+ srvr_last->next = srvr_curr;
+ }
+ else
+ {
+ srvr_head = srvr_curr;
+ }
+ srvr_last = srvr_curr;
+
+ /* Fill this server node data */
+ srvr_curr->family = channel->servers[i].addr.family;
+ srvr_curr->udp_port = ntohs((unsigned short)channel->servers[i].addr.udp_port);
+ srvr_curr->tcp_port = ntohs((unsigned short)channel->servers[i].addr.tcp_port);
+ if (srvr_curr->family == AF_INET)
+ memcpy(&srvr_curr->addrV4, &channel->servers[i].addr.addrV4,
+ sizeof(srvr_curr->addrV4));
+ else
+ memcpy(&srvr_curr->addrV6, &channel->servers[i].addr.addrV6,
+ sizeof(srvr_curr->addrV6));
+ }
+
+ if (status != ARES_SUCCESS)
+ {
+ if (srvr_head)
+ {
+ ares_free_data(srvr_head);
+ srvr_head = NULL;
+ }
+ }
+
+ *servers = srvr_head;
+
+ return status;
+}
int ares_set_servers(ares_channel channel,
struct ares_addr_node *servers)
@@ -92,7 +148,7 @@ int ares_set_servers(ares_channel channel,
int i;
if (ares_library_initialized() != ARES_SUCCESS)
- return ARES_ENOTINITIALIZED;
+ return ARES_ENOTINITIALIZED; /* LCOV_EXCL_LINE: n/a on non-WinSock */
if (!channel)
return ARES_ENODATA;
@@ -107,7 +163,7 @@ int ares_set_servers(ares_channel channel,
if (num_srvrs > 0)
{
/* Allocate storage for servers state */
- channel->servers = malloc(num_srvrs * sizeof(struct server_state));
+ channel->servers = ares_malloc(num_srvrs * sizeof(struct server_state));
if (!channel->servers)
{
return ARES_ENOMEM;
@@ -117,6 +173,57 @@ int ares_set_servers(ares_channel channel,
for (i = 0, srvr = servers; srvr; i++, srvr = srvr->next)
{
channel->servers[i].addr.family = srvr->family;
+ channel->servers[i].addr.udp_port = 0;
+ channel->servers[i].addr.tcp_port = 0;
+ if (srvr->family == AF_INET)
+ memcpy(&channel->servers[i].addr.addrV4, &srvr->addrV4,
+ sizeof(srvr->addrV4));
+ else
+ memcpy(&channel->servers[i].addr.addrV6, &srvr->addrV6,
+ sizeof(srvr->addrV6));
+ }
+ /* Initialize servers state remaining data */
+ ares__init_servers_state(channel);
+ }
+
+ return ARES_SUCCESS;
+}
+
+int ares_set_servers_ports(ares_channel channel,
+ struct ares_addr_port_node *servers)
+{
+ struct ares_addr_port_node *srvr;
+ int num_srvrs = 0;
+ int i;
+
+ if (ares_library_initialized() != ARES_SUCCESS)
+ return ARES_ENOTINITIALIZED; /* LCOV_EXCL_LINE: n/a on non-WinSock */
+
+ if (!channel)
+ return ARES_ENODATA;
+
+ ares__destroy_servers_state(channel);
+
+ for (srvr = servers; srvr; srvr = srvr->next)
+ {
+ num_srvrs++;
+ }
+
+ if (num_srvrs > 0)
+ {
+ /* Allocate storage for servers state */
+ channel->servers = ares_malloc(num_srvrs * sizeof(struct server_state));
+ if (!channel->servers)
+ {
+ return ARES_ENOMEM;
+ }
+ channel->nservers = num_srvrs;
+ /* Fill servers state address data */
+ for (i = 0, srvr = servers; srvr; i++, srvr = srvr->next)
+ {
+ channel->servers[i].addr.family = srvr->family;
+ channel->servers[i].addr.udp_port = htons((unsigned short)srvr->udp_port);
+ channel->servers[i].addr.tcp_port = htons((unsigned short)srvr->tcp_port);
if (srvr->family == AF_INET)
memcpy(&channel->servers[i].addr.addrV4, &srvr->addrV4,
sizeof(srvr->addrV4));
@@ -133,8 +240,8 @@ int ares_set_servers(ares_channel channel,
/* Incomming string format: host[:port][,host[:port]]... */
/* IPv6 addresses with ports require square brackets [fe80::1%lo0]:53 */
-int ares_set_servers_csv(ares_channel channel,
- const char* _csv)
+static int set_servers_csv(ares_channel channel,
+ const char* _csv, int use_port)
{
size_t i;
char* csv = NULL;
@@ -142,11 +249,11 @@ int ares_set_servers_csv(ares_channel channel,
char* start_host;
int cc = 0;
int rv = ARES_SUCCESS;
- struct ares_addr_node *servers = NULL;
- struct ares_addr_node *last = NULL;
+ struct ares_addr_port_node *servers = NULL;
+ struct ares_addr_port_node *last = NULL;
if (ares_library_initialized() != ARES_SUCCESS)
- return ARES_ENOTINITIALIZED;
+ return ARES_ENOTINITIALIZED; /* LCOV_EXCL_LINE: n/a on non-WinSock */
if (!channel)
return ARES_ENODATA;
@@ -157,7 +264,10 @@ int ares_set_servers_csv(ares_channel channel,
if (i == 0)
return ARES_SUCCESS; /* blank all servers */
- csv = malloc(i + 2);
+ csv = ares_malloc(i + 2);
+ if (!csv)
+ return ARES_ENOMEM;
+
strcpy(csv, _csv);
if (csv[i-1] != ',') { /* make parsing easier by ensuring ending ',' */
csv[i] = ',';
@@ -179,9 +289,10 @@ int ares_set_servers_csv(ares_channel channel,
else if (*ptr == ',') {
char* pp = ptr - 1;
char* p = ptr;
+ int port = 0;
struct in_addr in4;
struct ares_in6_addr in6;
- struct ares_addr_node *s = NULL;
+ struct ares_addr_port_node *s = NULL;
*ptr = 0; /* null terminate host:port string */
/* Got an entry..see if the port was specified. */
@@ -210,7 +321,7 @@ int ares_set_servers_csv(ares_channel channel,
if (*pp == ']')
p++; /* move p before ':' */
/* p will point to the start of the port */
- (void)strtol(p, NULL, 10);
+ port = (int)strtol(p, NULL, 10);
*pp = 0; /* null terminate host */
}
}
@@ -224,7 +335,7 @@ int ares_set_servers_csv(ares_channel channel,
goto out;
}
/* was ipv6, add new server */
- s = malloc(sizeof(*s));
+ s = ares_malloc(sizeof(*s));
if (!s) {
rv = ARES_ENOMEM;
goto out;
@@ -234,7 +345,7 @@ int ares_set_servers_csv(ares_channel channel,
}
else {
/* was ipv4, add new server */
- s = malloc(sizeof(*s));
+ s = ares_malloc(sizeof(*s));
if (!s) {
rv = ARES_ENOMEM;
goto out;
@@ -243,8 +354,8 @@ int ares_set_servers_csv(ares_channel channel,
memcpy(&s->addr, &in4, sizeof(struct in_addr));
}
if (s) {
- /* TODO: Add port to ares_addr_node and assign it here. */
-
+ s->udp_port = use_port ? port: 0;
+ s->tcp_port = s->udp_port;
s->next = NULL;
if (last) {
last->next = s;
@@ -263,16 +374,29 @@ int ares_set_servers_csv(ares_channel channel,
}
}
- rv = ares_set_servers(channel, servers);
+ rv = ares_set_servers_ports(channel, servers);
out:
if (csv)
- free(csv);
+ ares_free(csv);
while (servers) {
- struct ares_addr_node *s = servers;
+ struct ares_addr_port_node *s = servers;
servers = servers->next;
- free(s);
+ ares_free(s);
}
return rv;
}
+
+int ares_set_servers_csv(ares_channel channel,
+ const char* _csv)
+{
+ return set_servers_csv(channel, _csv, FALSE);
+}
+
+int ares_set_servers_ports_csv(ares_channel channel,
+ const char* _csv)
+{
+ return set_servers_csv(channel, _csv, TRUE);
+}
+
diff --git a/ares_parse_a_reply.c b/ares_parse_a_reply.c
index a3ed69e..0422bd3 100644
--- a/ares_parse_a_reply.c
+++ b/ares_parse_a_reply.c
@@ -85,7 +85,7 @@ int ares_parse_a_reply(const unsigned char *abuf, int alen,
return status;
if (aptr + len + QFIXEDSZ > abuf + alen)
{
- free(hostname);
+ ares_free(hostname);
return ARES_EBADRESP;
}
aptr += len + QFIXEDSZ;
@@ -94,17 +94,17 @@ int ares_parse_a_reply(const unsigned char *abuf, int alen,
{
/* Allocate addresses and aliases; ancount gives an upper bound for
both. */
- addrs = malloc(ancount * sizeof(struct in_addr));
+ addrs = ares_malloc(ancount * sizeof(struct in_addr));
if (!addrs)
{
- free(hostname);
+ ares_free(hostname);
return ARES_ENOMEM;
}
- aliases = malloc((ancount + 1) * sizeof(char *));
+ aliases = ares_malloc((ancount + 1) * sizeof(char *));
if (!aliases)
{
- free(hostname);
- free(addrs);
+ ares_free(hostname);
+ ares_free(addrs);
return ARES_ENOMEM;
}
}
@@ -127,7 +127,7 @@ int ares_parse_a_reply(const unsigned char *abuf, int alen,
aptr += len;
if (aptr + RRFIXEDSZ > abuf + alen)
{
- free(rr_name);
+ ares_free(rr_name);
status = ARES_EBADRESP;
break;
}
@@ -138,7 +138,7 @@ int ares_parse_a_reply(const unsigned char *abuf, int alen,
aptr += RRFIXEDSZ;
if (aptr + rr_len > abuf + alen)
{
- free(rr_name);
+ ares_free(rr_name);
status = ARES_EBADRESP;
break;
}
@@ -150,22 +150,22 @@ int ares_parse_a_reply(const unsigned char *abuf, int alen,
if (addrs)
{
if (aptr + sizeof(struct in_addr) > abuf + alen)
- {
- free(rr_name);
+ { /* LCOV_EXCL_START: already checked above */
+ ares_free(rr_name);
status = ARES_EBADRESP;
break;
- }
+ } /* LCOV_EXCL_STOP */
memcpy(&addrs[naddrs], aptr, sizeof(struct in_addr));
}
if (naddrs < max_addr_ttls)
{
struct ares_addrttl * const at = &addrttls[naddrs];
if (aptr + sizeof(struct in_addr) > abuf + alen)
- {
- free(rr_name);
+ { /* LCOV_EXCL_START: already checked above */
+ ares_free(rr_name);
status = ARES_EBADRESP;
break;
- }
+ } /* LCOV_EXCL_STOP */
memcpy(&at->ipaddr, aptr, sizeof(struct in_addr));
at->ttl = rr_ttl;
}
@@ -179,7 +179,7 @@ int ares_parse_a_reply(const unsigned char *abuf, int alen,
if (aliases)
aliases[naliases] = rr_name;
else
- free(rr_name);
+ ares_free(rr_name);
naliases++;
/* Decode the RR data and replace the hostname with it. */
@@ -187,7 +187,7 @@ int ares_parse_a_reply(const unsigned char *abuf, int alen,
&len);
if (status != ARES_SUCCESS)
break;
- free(hostname);
+ ares_free(hostname);
hostname = rr_data;
/* Take the min of the TTLs we see in the CNAME chain. */
@@ -195,14 +195,14 @@ int ares_parse_a_reply(const unsigned char *abuf, int alen,
cname_ttl = rr_ttl;
}
else
- free(rr_name);
+ ares_free(rr_name);
aptr += rr_len;
if (aptr > abuf + alen)
- {
+ { /* LCOV_EXCL_START: already checked above */
status = ARES_EBADRESP;
break;
- }
+ } /* LCOV_EXCL_STOP */
}
if (status == ARES_SUCCESS && naddrs == 0 && naliases == 0)
@@ -228,10 +228,10 @@ int ares_parse_a_reply(const unsigned char *abuf, int alen,
if (host)
{
/* Allocate memory to build the host entry. */
- hostent = malloc(sizeof(struct hostent));
+ hostent = ares_malloc(sizeof(struct hostent));
if (hostent)
{
- hostent->h_addr_list = malloc((naddrs + 1) * sizeof(char *));
+ hostent->h_addr_list = ares_malloc((naddrs + 1) * sizeof(char *));
if (hostent->h_addr_list)
{
/* Fill in the hostent and return successfully. */
@@ -243,11 +243,11 @@ int ares_parse_a_reply(const unsigned char *abuf, int alen,
hostent->h_addr_list[i] = (char *) &addrs[i];
hostent->h_addr_list[naddrs] = NULL;
if (!naddrs && addrs)
- free(addrs);
+ ares_free(addrs);
*host = hostent;
return ARES_SUCCESS;
}
- free(hostent);
+ ares_free(hostent);
}
status = ARES_ENOMEM;
}
@@ -255,10 +255,10 @@ int ares_parse_a_reply(const unsigned char *abuf, int alen,
if (aliases)
{
for (i = 0; i < naliases; i++)
- free(aliases[i]);
- free(aliases);
+ ares_free(aliases[i]);
+ ares_free(aliases);
}
- free(addrs);
- free(hostname);
+ ares_free(addrs);
+ ares_free(hostname);
return status;
}
diff --git a/ares_parse_aaaa_reply.c b/ares_parse_aaaa_reply.c
index 31e4a8c..5b38bb5 100644
--- a/ares_parse_aaaa_reply.c
+++ b/ares_parse_aaaa_reply.c
@@ -87,7 +87,7 @@ int ares_parse_aaaa_reply(const unsigned char *abuf, int alen,
return status;
if (aptr + len + QFIXEDSZ > abuf + alen)
{
- free(hostname);
+ ares_free(hostname);
return ARES_EBADRESP;
}
aptr += len + QFIXEDSZ;
@@ -95,17 +95,17 @@ int ares_parse_aaaa_reply(const unsigned char *abuf, int alen,
/* Allocate addresses and aliases; ancount gives an upper bound for both. */
if (host)
{
- addrs = malloc(ancount * sizeof(struct ares_in6_addr));
+ addrs = ares_malloc(ancount * sizeof(struct ares_in6_addr));
if (!addrs)
{
- free(hostname);
+ ares_free(hostname);
return ARES_ENOMEM;
}
- aliases = malloc((ancount + 1) * sizeof(char *));
+ aliases = ares_malloc((ancount + 1) * sizeof(char *));
if (!aliases)
{
- free(hostname);
- free(addrs);
+ ares_free(hostname);
+ ares_free(addrs);
return ARES_ENOMEM;
}
}
@@ -127,7 +127,7 @@ int ares_parse_aaaa_reply(const unsigned char *abuf, int alen,
aptr += len;
if (aptr + RRFIXEDSZ > abuf + alen)
{
- free(rr_name);
+ ares_free(rr_name);
status = ARES_EBADRESP;
break;
}
@@ -138,7 +138,7 @@ int ares_parse_aaaa_reply(const unsigned char *abuf, int alen,
aptr += RRFIXEDSZ;
if (aptr + rr_len > abuf + alen)
{
- free(rr_name);
+ ares_free(rr_name);
status = ARES_EBADRESP;
break;
}
@@ -150,22 +150,22 @@ int ares_parse_aaaa_reply(const unsigned char *abuf, int alen,
if (addrs)
{
if (aptr + sizeof(struct ares_in6_addr) > abuf + alen)
- {
- free(rr_name);
+ { /* LCOV_EXCL_START: already checked above */
+ ares_free(rr_name);
status = ARES_EBADRESP;
break;
- }
+ } /* LCOV_EXCL_STOP */
memcpy(&addrs[naddrs], aptr, sizeof(struct ares_in6_addr));
}
if (naddrs < max_addr_ttls)
{
struct ares_addr6ttl * const at = &addrttls[naddrs];
if (aptr + sizeof(struct ares_in6_addr) > abuf + alen)
- {
- free(rr_name);
+ { /* LCOV_EXCL_START: already checked above */
+ ares_free(rr_name);
status = ARES_EBADRESP;
break;
- }
+ } /* LCOV_EXCL_STOP */
memcpy(&at->ip6addr, aptr, sizeof(struct ares_in6_addr));
at->ttl = rr_ttl;
}
@@ -179,7 +179,7 @@ int ares_parse_aaaa_reply(const unsigned char *abuf, int alen,
if (aliases)
aliases[naliases] = rr_name;
else
- free(rr_name);
+ ares_free(rr_name);
naliases++;
/* Decode the RR data and replace the hostname with it. */
@@ -187,7 +187,7 @@ int ares_parse_aaaa_reply(const unsigned char *abuf, int alen,
&len);
if (status != ARES_SUCCESS)
break;
- free(hostname);
+ ares_free(hostname);
hostname = rr_data;
/* Take the min of the TTLs we see in the CNAME chain. */
@@ -195,14 +195,14 @@ int ares_parse_aaaa_reply(const unsigned char *abuf, int alen,
cname_ttl = rr_ttl;
}
else
- free(rr_name);
+ ares_free(rr_name);
aptr += rr_len;
if (aptr > abuf + alen)
- {
+ { /* LCOV_EXCL_START: already checked above */
status = ARES_EBADRESP;
break;
- }
+ } /* LCOV_EXCL_STOP */
}
/* the check for naliases to be zero is to make sure CNAME responses
@@ -228,10 +228,10 @@ int ares_parse_aaaa_reply(const unsigned char *abuf, int alen,
if (host)
{
/* Allocate memory to build the host entry. */
- hostent = malloc(sizeof(struct hostent));
+ hostent = ares_malloc(sizeof(struct hostent));
if (hostent)
{
- hostent->h_addr_list = malloc((naddrs + 1) * sizeof(char *));
+ hostent->h_addr_list = ares_malloc((naddrs + 1) * sizeof(char *));
if (hostent->h_addr_list)
{
/* Fill in the hostent and return successfully. */
@@ -243,11 +243,11 @@ int ares_parse_aaaa_reply(const unsigned char *abuf, int alen,
hostent->h_addr_list[i] = (char *) &addrs[i];
hostent->h_addr_list[naddrs] = NULL;
if (!naddrs && addrs)
- free(addrs);
+ ares_free(addrs);
*host = hostent;
return ARES_SUCCESS;
}
- free(hostent);
+ ares_free(hostent);
}
status = ARES_ENOMEM;
}
@@ -255,10 +255,10 @@ int ares_parse_aaaa_reply(const unsigned char *abuf, int alen,
if (aliases)
{
for (i = 0; i < naliases; i++)
- free(aliases[i]);
- free(aliases);
+ ares_free(aliases[i]);
+ ares_free(aliases);
}
- free(addrs);
- free(hostname);
+ ares_free(addrs);
+ ares_free(hostname);
return status;
}
diff --git a/ares_parse_mx_reply.c b/ares_parse_mx_reply.c
index 95400dd..e633647 100644
--- a/ares_parse_mx_reply.c
+++ b/ares_parse_mx_reply.c
@@ -76,7 +76,7 @@ ares_parse_mx_reply (const unsigned char *abuf, int alen,
if (aptr + len + QFIXEDSZ > abuf + alen)
{
- free (hostname);
+ ares_free (hostname);
return ARES_EBADRESP;
}
aptr += len + QFIXEDSZ;
@@ -143,7 +143,7 @@ ares_parse_mx_reply (const unsigned char *abuf, int alen,
}
/* Don't lose memory in the next iteration */
- free (rr_name);
+ ares_free (rr_name);
rr_name = NULL;
/* Move on to the next record */
@@ -151,9 +151,9 @@ ares_parse_mx_reply (const unsigned char *abuf, int alen,
}
if (hostname)
- free (hostname);
+ ares_free (hostname);
if (rr_name)
- free (rr_name);
+ ares_free (rr_name);
/* clean up on error */
if (status != ARES_SUCCESS)
diff --git a/ares_parse_naptr_reply.c b/ares_parse_naptr_reply.c
index 4935366..11634df 100644
--- a/ares_parse_naptr_reply.c
+++ b/ares_parse_naptr_reply.c
@@ -81,7 +81,7 @@ ares_parse_naptr_reply (const unsigned char *abuf, int alen,
if (aptr + len + QFIXEDSZ > abuf + alen)
{
- free (hostname);
+ ares_free (hostname);
return ARES_EBADRESP;
}
aptr += len + QFIXEDSZ;
@@ -160,7 +160,7 @@ ares_parse_naptr_reply (const unsigned char *abuf, int alen,
}
/* Don't lose memory in the next iteration */
- free (rr_name);
+ ares_free (rr_name);
rr_name = NULL;
/* Move on to the next record */
@@ -168,9 +168,9 @@ ares_parse_naptr_reply (const unsigned char *abuf, int alen,
}
if (hostname)
- free (hostname);
+ ares_free (hostname);
if (rr_name)
- free (rr_name);
+ ares_free (rr_name);
/* clean up on error */
if (status != ARES_SUCCESS)
diff --git a/ares_parse_ns_reply.c b/ares_parse_ns_reply.c
index d331e67..7bb5142 100644
--- a/ares_parse_ns_reply.c
+++ b/ares_parse_ns_reply.c
@@ -73,16 +73,16 @@ int ares_parse_ns_reply( const unsigned char* abuf, int alen,
return status;
if ( aptr + len + QFIXEDSZ > abuf + alen )
{
- free( hostname );
+ ares_free( hostname );
return ARES_EBADRESP;
}
aptr += len + QFIXEDSZ;
/* Allocate nameservers array; ancount gives an upper bound */
- nameservers = malloc( ( ancount + 1 ) * sizeof( char * ) );
+ nameservers = ares_malloc( ( ancount + 1 ) * sizeof( char * ) );
if ( !nameservers )
{
- free( hostname );
+ ares_free( hostname );
return ARES_ENOMEM;
}
nameservers_num = 0;
@@ -98,7 +98,7 @@ int ares_parse_ns_reply( const unsigned char* abuf, int alen,
if ( aptr + RRFIXEDSZ > abuf + alen )
{
status = ARES_EBADRESP;
- free(rr_name);
+ ares_free(rr_name);
break;
}
rr_type = DNS_RR_TYPE( aptr );
@@ -107,7 +107,7 @@ int ares_parse_ns_reply( const unsigned char* abuf, int alen,
aptr += RRFIXEDSZ;
if (aptr + rr_len > abuf + alen)
{
- free(rr_name);
+ ares_free(rr_name);
status = ARES_EBADRESP;
break;
}
@@ -119,33 +119,33 @@ int ares_parse_ns_reply( const unsigned char* abuf, int alen,
&len);
if ( status != ARES_SUCCESS )
{
- free(rr_name);
+ ares_free(rr_name);
break;
}
- nameservers[nameservers_num] = malloc(strlen(rr_data)+1);
+ nameservers[nameservers_num] = ares_malloc(strlen(rr_data)+1);
if (nameservers[nameservers_num]==NULL)
{
- free(rr_name);
- free(rr_data);
+ ares_free(rr_name);
+ ares_free(rr_data);
status=ARES_ENOMEM;
break;
}
strcpy(nameservers[nameservers_num],rr_data);
- free(rr_data);
+ ares_free(rr_data);
nameservers_num++;
}
- free( rr_name );
+ ares_free( rr_name );
aptr += rr_len;
if ( aptr > abuf + alen )
- {
+ { /* LCOV_EXCL_START: already checked above */
status = ARES_EBADRESP;
break;
- }
+ } /* LCOV_EXCL_STOP */
}
if ( status == ARES_SUCCESS && nameservers_num == 0 )
@@ -156,10 +156,10 @@ int ares_parse_ns_reply( const unsigned char* abuf, int alen,
{
/* We got our answer. Allocate memory to build the host entry. */
nameservers[nameservers_num] = NULL;
- hostent = malloc( sizeof( struct hostent ) );
+ hostent = ares_malloc( sizeof( struct hostent ) );
if ( hostent )
{
- hostent->h_addr_list = malloc( 1 * sizeof( char * ) );
+ hostent->h_addr_list = ares_malloc( 1 * sizeof( char * ) );
if ( hostent->h_addr_list )
{
/* Fill in the hostent and return successfully. */
@@ -171,13 +171,13 @@ int ares_parse_ns_reply( const unsigned char* abuf, int alen,
*host = hostent;
return ARES_SUCCESS;
}
- free( hostent );
+ ares_free( hostent );
}
status = ARES_ENOMEM;
}
for ( i = 0; i < nameservers_num; i++ )
- free( nameservers[i] );
- free( nameservers );
- free( hostname );
+ ares_free( nameservers[i] );
+ ares_free( nameservers );
+ ares_free( hostname );
return status;
}
diff --git a/ares_parse_ptr_reply.c b/ares_parse_ptr_reply.c
index df21e40..976a531 100644
--- a/ares_parse_ptr_reply.c
+++ b/ares_parse_ptr_reply.c
@@ -73,17 +73,17 @@ int ares_parse_ptr_reply(const unsigned char *abuf, int alen, const void *addr,
return status;
if (aptr + len + QFIXEDSZ > abuf + alen)
{
- free(ptrname);
+ ares_free(ptrname);
return ARES_EBADRESP;
}
aptr += len + QFIXEDSZ;
/* Examine each answer resource record (RR) in turn. */
hostname = NULL;
- aliases = malloc(alias_alloc * sizeof(char *));
+ aliases = ares_malloc(alias_alloc * sizeof(char *));
if (!aliases)
{
- free(ptrname);
+ ares_free(ptrname);
return ARES_ENOMEM;
}
for (i = 0; i < (int)ancount; i++)
@@ -95,7 +95,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);
+ ares_free(rr_name);
status = ARES_EBADRESP;
break;
}
@@ -105,7 +105,7 @@ int ares_parse_ptr_reply(const unsigned char *abuf, int alen, const void *addr,
aptr += RRFIXEDSZ;
if (aptr + rr_len > abuf + alen)
{
- free(rr_name);
+ ares_free(rr_name);
status = ARES_EBADRESP;
break;
}
@@ -118,16 +118,16 @@ int ares_parse_ptr_reply(const unsigned char *abuf, int alen, const void *addr,
&len);
if (status != ARES_SUCCESS)
{
- free(rr_name);
+ ares_free(rr_name);
break;
}
if (hostname)
- free(hostname);
+ ares_free(hostname);
hostname = rr_data;
- aliases[aliascnt] = malloc((strlen(rr_data)+1) * sizeof(char));
+ aliases[aliascnt] = ares_malloc((strlen(rr_data)+1) * sizeof(char));
if (!aliases[aliascnt])
{
- free(rr_name);
+ ares_free(rr_name);
status = ARES_ENOMEM;
break;
}
@@ -136,9 +136,9 @@ int ares_parse_ptr_reply(const unsigned char *abuf, int alen, const void *addr,
if (aliascnt >= alias_alloc) {
char **ptr;
alias_alloc *= 2;
- ptr = realloc(aliases, alias_alloc * sizeof(char *));
+ ptr = ares_realloc(aliases, alias_alloc * sizeof(char *));
if(!ptr) {
- free(rr_name);
+ ares_free(rr_name);
status = ARES_ENOMEM;
break;
}
@@ -153,20 +153,20 @@ int ares_parse_ptr_reply(const unsigned char *abuf, int alen, const void *addr,
&len);
if (status != ARES_SUCCESS)
{
- free(rr_name);
+ ares_free(rr_name);
break;
}
- free(ptrname);
+ ares_free(ptrname);
ptrname = rr_data;
}
- free(rr_name);
+ ares_free(rr_name);
aptr += rr_len;
if (aptr > abuf + alen)
- {
+ { /* LCOV_EXCL_START: already checked above */
status = ARES_EBADRESP;
break;
- }
+ } /* LCOV_EXCL_STOP */
}
if (status == ARES_SUCCESS && !hostname)
@@ -174,16 +174,16 @@ int ares_parse_ptr_reply(const unsigned char *abuf, int alen, const void *addr,
if (status == ARES_SUCCESS)
{
/* We got our answer. Allocate memory to build the host entry. */
- hostent = malloc(sizeof(struct hostent));
+ hostent = ares_malloc(sizeof(struct hostent));
if (hostent)
{
- hostent->h_addr_list = malloc(2 * sizeof(char *));
+ hostent->h_addr_list = ares_malloc(2 * sizeof(char *));
if (hostent->h_addr_list)
{
- hostent->h_addr_list[0] = malloc(addrlen);
+ hostent->h_addr_list[0] = ares_malloc(addrlen);
if (hostent->h_addr_list[0])
{
- hostent->h_aliases = malloc((aliascnt+1) * sizeof (char *));
+ hostent->h_aliases = ares_malloc((aliascnt+1) * sizeof (char *));
if (hostent->h_aliases)
{
/* Fill in the hostent and return successfully. */
@@ -196,24 +196,24 @@ int ares_parse_ptr_reply(const unsigned char *abuf, int alen, const void *addr,
memcpy(hostent->h_addr_list[0], addr, addrlen);
hostent->h_addr_list[1] = NULL;
*host = hostent;
- free(aliases);
- free(ptrname);
+ ares_free(aliases);
+ ares_free(ptrname);
return ARES_SUCCESS;
}
- free(hostent->h_addr_list[0]);
+ ares_free(hostent->h_addr_list[0]);
}
- free(hostent->h_addr_list);
+ ares_free(hostent->h_addr_list);
}
- free(hostent);
+ ares_free(hostent);
}
status = ARES_ENOMEM;
}
for (i=0 ; i<aliascnt ; i++)
if (aliases[i])
- free(aliases[i]);
- free(aliases);
+ ares_free(aliases[i]);
+ ares_free(aliases);
if (hostname)
- free(hostname);
- free(ptrname);
+ ares_free(hostname);
+ ares_free(ptrname);
return status;
}
diff --git a/ares_parse_soa_reply.c b/ares_parse_soa_reply.c
index da1c6dc..35af0a7 100644
--- a/ares_parse_soa_reply.c
+++ b/ares_parse_soa_reply.c
@@ -86,7 +86,10 @@ ares_parse_soa_reply(const unsigned char *abuf, int alen,
/* allocate result struct */
soa = ares_malloc_data(ARES_DATATYPE_SOA_REPLY);
if (!soa)
- return ARES_ENOMEM;
+ {
+ status = ARES_ENOMEM;
+ goto failed_stat;
+ }
/* nsname */
status = ares__expand_name_for_response(aptr, abuf, alen, &soa->nsname, &len);
@@ -109,8 +112,8 @@ ares_parse_soa_reply(const unsigned char *abuf, int alen,
soa->expire = DNS__32BIT(aptr + 3 * 4);
soa->minttl = DNS__32BIT(aptr + 4 * 4);
- free(qname);
- free(rr_name);
+ ares_free(qname);
+ ares_free(rr_name);
*soa_out = soa;
@@ -122,9 +125,9 @@ failed:
failed_stat:
ares_free_data(soa);
if (qname)
- free(qname);
+ ares_free(qname);
if (rr_name)
- free(rr_name);
+ ares_free(rr_name);
return status;
}
diff --git a/ares_parse_srv_reply.c b/ares_parse_srv_reply.c
index 0739c27..824ff3a 100644
--- a/ares_parse_srv_reply.c
+++ b/ares_parse_srv_reply.c
@@ -81,7 +81,7 @@ ares_parse_srv_reply (const unsigned char *abuf, int alen,
if (aptr + len + QFIXEDSZ > abuf + alen)
{
- free (hostname);
+ ares_free (hostname);
return ARES_EBADRESP;
}
aptr += len + QFIXEDSZ;
@@ -152,7 +152,7 @@ ares_parse_srv_reply (const unsigned char *abuf, int alen,
}
/* Don't lose memory in the next iteration */
- free (rr_name);
+ ares_free (rr_name);
rr_name = NULL;
/* Move on to the next record */
@@ -160,9 +160,9 @@ ares_parse_srv_reply (const unsigned char *abuf, int alen,
}
if (hostname)
- free (hostname);
+ ares_free (hostname);
if (rr_name)
- free (rr_name);
+ ares_free (rr_name);
/* clean up on error */
if (status != ARES_SUCCESS)
diff --git a/ares_parse_txt_reply.3 b/ares_parse_txt_reply.3
index 063b3ff..e15d0ea 100644
--- a/ares_parse_txt_reply.3
+++ b/ares_parse_txt_reply.3
@@ -22,13 +22,16 @@ ares_parse_txt_reply \- Parse a reply to a DNS query of type TXT
.PP
.B int ares_parse_txt_reply(const unsigned char* \fIabuf\fP, int \fIalen\fP,
.B struct ares_txt_reply **\fItxt_out\fP);
+.PP
+.B int ares_parse_txt_reply_ext(const unsigned char* \fIabuf\fP, int \fIalen\fP,
+.B struct ares_txt_ext **\fItxt_out\fP);
.fi
.SH DESCRIPTION
The
-.B ares_parse_txt_reply
+.BR "ares_parse_txt_reply" " (" "ares_parse_txt_reply_ext" ")"
function parses the response to a query of type TXT into a
linked list (one element per sub-string) of
-.I struct ares_txt_reply
+.IR "struct ares_txt_reply" " (" "struct ares_txt_ext" ")"
The parameters
.I abuf
and
@@ -55,8 +58,44 @@ struct ares_txt_reply {
.fi
.in
.PP
+The structure
+.I ares_txt_ext
+contains the following fields:
+.sp
+.in +4n
+.nf
+struct ares_txt_ext {
+ struct ares_txt_ext *next;
+ unsigned int length;
+ unsigned char *txt;
+ unsigned char record_start;
+};
+.fi
+.in
+.PP
+The
+.I record_start
+field in
+.I struct ares_txt_ext
+is 1 if this structure is a start of a TXT record, and 0 if the structure is a
+continuation of a previous record. The linked list of the
+.I struct ares_txt_ext
+will have at least one item with
+.I record_start
+equal to 1, and may have some items with
+.I record_start
+equal to 0 between them.
+.PP
+These sequences of
+.I struct ares_txt_ext
+(starting from the item with
+.I record_start
+equal to 1, and ending right before the record start item) may be treated as
+either components of a single TXT record or as a multi-parted TXT record,
+depending on particular use case.
+.PP
.SH RETURN VALUES
-.B ares_parse_txt_reply
+.BR "ares_parse_txt_reply" " (" "ares_parse_txt_reply_ext" ")"
can return any of the following values:
.TP 15
.B ARES_SUCCESS
@@ -77,4 +116,5 @@ This function was first introduced in c-ares version 1.7.0.
.BR ares_free_data (3)
.SH AUTHOR
Written by Jakub Hrozek <jhrozek@redhat.com>, on behalf of Red Hat, Inc http://www.redhat.com
-
+.PP
+Amended by Fedor Indutny <fedor@indutny.com>, on behalf of PayPal, Inc https://www.paypal.com
diff --git a/ares_parse_txt_reply.c b/ares_parse_txt_reply.c
index 981db4c..4856b4c 100644
--- a/ares_parse_txt_reply.c
+++ b/ares_parse_txt_reply.c
@@ -44,9 +44,9 @@
#include "ares_data.h"
#include "ares_private.h"
-int
-ares_parse_txt_reply (const unsigned char *abuf, int alen,
- struct ares_txt_reply **txt_out)
+static int
+ares__parse_txt_reply (const unsigned char *abuf, int alen,
+ int ex, void **txt_out)
{
size_t substr_len;
unsigned int qdcount, ancount, i;
@@ -55,9 +55,9 @@ ares_parse_txt_reply (const unsigned char *abuf, int alen,
int status, rr_type, rr_class, rr_len;
long len;
char *hostname = NULL, *rr_name = NULL;
- struct ares_txt_reply *txt_head = NULL;
- struct ares_txt_reply *txt_last = NULL;
- struct ares_txt_reply *txt_curr;
+ struct ares_txt_ext *txt_head = NULL;
+ struct ares_txt_ext *txt_last = NULL;
+ struct ares_txt_ext *txt_curr;
/* Set *txt_out to NULL for all failure cases. */
*txt_out = NULL;
@@ -82,7 +82,7 @@ ares_parse_txt_reply (const unsigned char *abuf, int alen,
if (aptr + len + QFIXEDSZ > abuf + alen)
{
- free (hostname);
+ ares_free (hostname);
return ARES_EBADRESP;
}
aptr += len + QFIXEDSZ;
@@ -133,10 +133,9 @@ ares_parse_txt_reply (const unsigned char *abuf, int alen,
break;
}
- ++strptr;
-
/* Allocate storage for this TXT answer appending it to the list */
- txt_curr = ares_malloc_data(ARES_DATATYPE_TXT_REPLY);
+ txt_curr = ares_malloc_data(ex ? ARES_DATATYPE_TXT_EXT :
+ ARES_DATATYPE_TXT_REPLY);
if (!txt_curr)
{
status = ARES_ENOMEM;
@@ -152,13 +151,17 @@ ares_parse_txt_reply (const unsigned char *abuf, int alen,
}
txt_last = txt_curr;
+ if (ex)
+ txt_curr->record_start = (strptr == aptr);
txt_curr->length = substr_len;
- txt_curr->txt = malloc (substr_len + 1/* Including null byte */);
+ txt_curr->txt = ares_malloc (substr_len + 1/* Including null byte */);
if (txt_curr->txt == NULL)
{
status = ARES_ENOMEM;
break;
}
+
+ ++strptr;
memcpy ((char *) txt_curr->txt, strptr, substr_len);
/* Make sure we NULL-terminate */
@@ -168,8 +171,14 @@ ares_parse_txt_reply (const unsigned char *abuf, int alen,
}
}
+ /* Propagate any failures */
+ if (status != ARES_SUCCESS)
+ {
+ break;
+ }
+
/* Don't lose memory in the next iteration */
- free (rr_name);
+ ares_free (rr_name);
rr_name = NULL;
/* Move on to the next record */
@@ -177,9 +186,9 @@ ares_parse_txt_reply (const unsigned char *abuf, int alen,
}
if (hostname)
- free (hostname);
+ ares_free (hostname);
if (rr_name)
- free (rr_name);
+ ares_free (rr_name);
/* clean up on error */
if (status != ARES_SUCCESS)
@@ -194,3 +203,18 @@ ares_parse_txt_reply (const unsigned char *abuf, int alen,
return ARES_SUCCESS;
}
+
+int
+ares_parse_txt_reply (const unsigned char *abuf, int alen,
+ struct ares_txt_reply **txt_out)
+{
+ return ares__parse_txt_reply(abuf, alen, 0, (void **) txt_out);
+}
+
+
+int
+ares_parse_txt_reply_ext (const unsigned char *abuf, int alen,
+ struct ares_txt_ext **txt_out)
+{
+ return ares__parse_txt_reply(abuf, alen, 1, (void **) txt_out);
+}
diff --git a/ares_private.h b/ares_private.h
index ab5be5a..33a23e7 100644
--- a/ares_private.h
+++ b/ares_private.h
@@ -43,6 +43,13 @@
#define INADDR_NONE 0xffffffff
#endif
+#ifdef CARES_EXPOSE_STATICS
+/* Make some internal functions visible for testing */
+#define STATIC_TESTABLE
+#else
+#define STATIC_TESTABLE static
+#endif
+
#if defined(WIN32) && !defined(WATT32)
#define WIN_NS_9X "System\\CurrentControlSet\\Services\\VxD\\MSTCP"
@@ -86,10 +93,7 @@
# define getenv(ptr) ares_getenv(ptr)
#endif
-#ifndef HAVE_STRDUP
-# include "ares_strdup.h"
-# define strdup(ptr) ares_strdup(ptr)
-#endif
+#include "ares_strdup.h"
#ifndef HAVE_STRCASECMP
# include "ares_strcasecmp.h"
@@ -119,6 +123,8 @@ struct ares_addr {
struct in_addr addr4;
struct ares_in6_addr addr6;
} addr;
+ int udp_port; /* stored in network order */
+ int tcp_port; /* stored in network order */
};
#define addrV4 addr.addr4
#define addrV6 addr.addr6
@@ -251,8 +257,8 @@ struct ares_channeldata {
int tries;
int ndots;
int rotate; /* if true, all servers specified are used */
- int udp_port;
- int tcp_port;
+ int udp_port; /* stored in network order */
+ int tcp_port; /* stored in network order */
int socket_send_buffer_size;
int socket_receive_buffer_size;
char **domains;
@@ -305,19 +311,20 @@ struct ares_channeldata {
ares_sock_create_callback sock_create_cb;
void *sock_create_cb_data;
+
+ ares_sock_config_callback sock_config_cb;
+ void *sock_config_cb_data;
};
+/* Memory management functions */
+extern void *(*ares_malloc)(size_t size);
+extern void *(*ares_realloc)(void *ptr, size_t size);
+extern void (*ares_free)(void *ptr);
+
/* return true if now is exactly check time or later */
int ares__timedout(struct timeval *now,
struct timeval *check);
-/* add the specific number of milliseconds to the time in the first argument */
-int ares__timeadd(struct timeval *now,
- int millisecs);
-/* return time offset between now and (future) check, in milliseconds */
-long ares__timeoffset(struct timeval *now,
- struct timeval *check);
-/* returns ARES_SUCCESS if library has been initialized */
-int ares_library_initialized(void);
+
void ares__send_query(ares_channel channel, struct query *query,
struct timeval *now);
void ares__close_sockets(ares_channel channel, struct server_state *server);
diff --git a/ares_process.c b/ares_process.c
index 4d7dcd3..1d1e7b8 100644
--- a/ares_process.c
+++ b/ares_process.c
@@ -1,6 +1,6 @@
/* Copyright 1998 by the Massachusetts Institute of Technology.
- * Copyright (C) 2004-2013 by Daniel Stenberg
+ * Copyright (C) 2004-2016 by Daniel Stenberg
*
* Permission to use, copy, modify, and distribute this
* software and its documentation for any purpose and without
@@ -102,8 +102,7 @@ int ares__timedout(struct timeval *now,
}
/* add the specific number of milliseconds to the time in the first argument */
-int ares__timeadd(struct timeval *now,
- int millisecs)
+static void timeadd(struct timeval *now, int millisecs)
{
now->tv_sec += millisecs/1000;
now->tv_usec += (millisecs%1000)*1000;
@@ -112,19 +111,8 @@ int ares__timeadd(struct timeval *now,
++(now->tv_sec);
now->tv_usec -= 1000000;
}
-
- return 0;
-}
-
-/* return time offset between now and (future) check, in milliseconds */
-long ares__timeoffset(struct timeval *now,
- struct timeval *check)
-{
- return (check->tv_sec - now->tv_sec)*1000 +
- (check->tv_usec - now->tv_usec)/1000;
}
-
/*
* generic process function
*/
@@ -239,7 +227,7 @@ static void write_tcp_data(ares_channel channel,
n++;
/* Allocate iovecs so we can send all our data at once. */
- vec = malloc(n * sizeof(struct iovec));
+ vec = ares_malloc(n * sizeof(struct iovec));
if (vec)
{
/* Fill in the iovecs and send. */
@@ -251,7 +239,7 @@ static void write_tcp_data(ares_channel channel,
n++;
}
wcount = (ssize_t)writev(server->tcp_socket, vec, (int)n);
- free(vec);
+ ares_free(vec);
if (wcount < 0)
{
if (!try_again(SOCKERRNO))
@@ -293,8 +281,8 @@ static void advance_tcp_send_queue(ares_channel channel, int whichserver,
num_bytes -= sendreq->len;
server->qhead = sendreq->next;
if (sendreq->data_storage)
- free(sendreq->data_storage);
- free(sendreq);
+ ares_free(sendreq->data_storage);
+ ares_free(sendreq);
if (server->qhead == NULL) {
SOCK_STATE_CALLBACK(channel, server->tcp_socket, 1, 0);
server->qtail = NULL;
@@ -373,9 +361,12 @@ static void read_tcp_data(ares_channel channel, fd_set *read_fds,
*/
server->tcp_length = server->tcp_lenbuf[0] << 8
| server->tcp_lenbuf[1];
- server->tcp_buffer = malloc(server->tcp_length);
- if (!server->tcp_buffer)
+ server->tcp_buffer = ares_malloc(server->tcp_length);
+ if (!server->tcp_buffer) {
handle_error(channel, i, now);
+ return; /* bail out on malloc failure. TODO: make this
+ function return error codes */
+ }
server->tcp_buffer_pos = 0;
}
}
@@ -400,8 +391,7 @@ static void read_tcp_data(ares_channel channel, fd_set *read_fds,
*/
process_answer(channel, server->tcp_buffer, server->tcp_length,
i, 1, now);
- if (server->tcp_buffer)
- free(server->tcp_buffer);
+ ares_free(server->tcp_buffer);
server->tcp_buffer = NULL;
server->tcp_lenbuf_pos = 0;
server->tcp_buffer_pos = 0;
@@ -575,14 +565,15 @@ static void process_answer(ares_channel channel, unsigned char *abuf,
packetsz = channel->ednspsz;
if (rcode == NOTIMP || rcode == FORMERR || rcode == SERVFAIL)
{
- int qlen = alen - EDNSFIXEDSZ;
+ int qlen = (query->tcplen - 2) - EDNSFIXEDSZ;
channel->flags ^= ARES_FLAG_EDNS;
query->tcplen -= EDNSFIXEDSZ;
query->qlen -= EDNSFIXEDSZ;
query->tcpbuf[0] = (unsigned char)((qlen >> 8) & 0xff);
query->tcpbuf[1] = (unsigned char)(qlen & 0xff);
DNS_HEADER_SET_ARCOUNT(query->tcpbuf + 2, 0);
- query->tcpbuf = realloc(query->tcpbuf, query->tcplen);
+ query->tcpbuf = ares_realloc(query->tcpbuf, query->tcplen);
+ query->qbuf = query->tcpbuf + 2;
ares__send_query(channel, query, now);
return;
}
@@ -781,12 +772,13 @@ void ares__send_query(ares_channel channel, struct query *query,
return;
}
}
- sendreq = calloc(1, sizeof(struct send_request));
+ sendreq = ares_malloc(sizeof(struct send_request));
if (!sendreq)
{
end_query(channel, query, ARES_ENOMEM, NULL, 0);
return;
}
+ memset(sendreq, 0, sizeof(struct send_request));
/* To make the common case fast, we avoid copies by using the query's
* tcpbuf for as long as the query is alive. In the rare case where the
* query ends while it's queued for transmission, then we give the
@@ -831,8 +823,7 @@ void ares__send_query(ares_channel channel, struct query *query,
timeplus = channel->timeout << (query->try_count / channel->nservers);
timeplus = (timeplus * (9 + (rand () & 7))) / 16;
query->timeout = *now;
- ares__timeadd(&query->timeout,
- timeplus);
+ timeadd(&query->timeout, timeplus);
/* Keep track of queries bucketed by timeout, so we can process
* timeout events quickly.
*/
@@ -856,7 +847,7 @@ void ares__send_query(ares_channel channel, struct query *query,
* portable.
*/
static int setsocknonblock(ares_socket_t sockfd, /* operate on this */
- int nonblock /* TRUE or FALSE */)
+ int nonblock /* TRUE or FALSE */)
{
#if defined(USE_BLOCKING_SOCKETS)
@@ -870,7 +861,7 @@ static int setsocknonblock(ares_socket_t sockfd, /* operate on this */
if (FALSE != nonblock)
return fcntl(sockfd, F_SETFL, flags | O_NONBLOCK);
else
- return fcntl(sockfd, F_SETFL, flags & (~O_NONBLOCK));
+ return fcntl(sockfd, F_SETFL, flags & (~O_NONBLOCK)); /* LCOV_EXCL_LINE */
#elif defined(HAVE_IOCTL_FIONBIO)
@@ -913,12 +904,12 @@ static int configure_socket(ares_socket_t s, int family, ares_channel channel)
struct sockaddr_in6 sa6;
} local;
- setsocknonblock(s, TRUE);
+ (void)setsocknonblock(s, TRUE);
-#if !defined(SOCK_CLOEXEC) && defined(FD_CLOEXEC) && !defined(MSDOS)
+#if defined(FD_CLOEXEC) && !defined(MSDOS)
/* Configure the socket fd as close-on-exec. */
if (fcntl(s, F_SETFD, FD_CLOEXEC) == -1)
- return -1;
+ return -1; /* LCOV_EXCL_LINE */
#endif
/* Set the socket's send and receive buffer sizes. */
@@ -986,7 +977,11 @@ static int open_tcp_socket(ares_channel channel, struct server_state *server)
salen = sizeof(saddr.sa4);
memset(sa, 0, salen);
saddr.sa4.sin_family = AF_INET;
- saddr.sa4.sin_port = aresx_sitous(channel->tcp_port);
+ if (server->addr.tcp_port) {
+ saddr.sa4.sin_port = aresx_sitous(server->addr.tcp_port);
+ } else {
+ saddr.sa4.sin_port = aresx_sitous(channel->tcp_port);
+ }
memcpy(&saddr.sa4.sin_addr, &server->addr.addrV4,
sizeof(server->addr.addrV4));
break;
@@ -995,16 +990,20 @@ static int open_tcp_socket(ares_channel channel, struct server_state *server)
salen = sizeof(saddr.sa6);
memset(sa, 0, salen);
saddr.sa6.sin6_family = AF_INET6;
- saddr.sa6.sin6_port = aresx_sitous(channel->tcp_port);
+ if (server->addr.tcp_port) {
+ saddr.sa6.sin6_port = aresx_sitous(server->addr.tcp_port);
+ } else {
+ saddr.sa6.sin6_port = aresx_sitous(channel->tcp_port);
+ }
memcpy(&saddr.sa6.sin6_addr, &server->addr.addrV6,
sizeof(server->addr.addrV6));
break;
default:
- return -1;
+ return -1; /* LCOV_EXCL_LINE */
}
/* Acquire a socket. */
- s = socket(server->addr.family, SOCK_STREAM | SOCK_CLOEXEC, 0);
+ s = socket(server->addr.family, SOCK_STREAM, 0);
if (s == ARES_SOCKET_BAD)
return -1;
@@ -1031,6 +1030,17 @@ static int open_tcp_socket(ares_channel channel, struct server_state *server)
}
#endif
+ if (channel->sock_config_cb)
+ {
+ int err = channel->sock_config_cb(s, SOCK_STREAM,
+ channel->sock_config_cb_data);
+ if (err < 0)
+ {
+ sclose(s);
+ return err;
+ }
+ }
+
/* Connect to the server. */
if (connect(s, sa, salen) == -1)
{
@@ -1078,7 +1088,11 @@ static int open_udp_socket(ares_channel channel, struct server_state *server)
salen = sizeof(saddr.sa4);
memset(sa, 0, salen);
saddr.sa4.sin_family = AF_INET;
- saddr.sa4.sin_port = aresx_sitous(channel->udp_port);
+ if (server->addr.udp_port) {
+ saddr.sa4.sin_port = aresx_sitous(server->addr.udp_port);
+ } else {
+ saddr.sa4.sin_port = aresx_sitous(channel->udp_port);
+ }
memcpy(&saddr.sa4.sin_addr, &server->addr.addrV4,
sizeof(server->addr.addrV4));
break;
@@ -1087,16 +1101,20 @@ static int open_udp_socket(ares_channel channel, struct server_state *server)
salen = sizeof(saddr.sa6);
memset(sa, 0, salen);
saddr.sa6.sin6_family = AF_INET6;
- saddr.sa6.sin6_port = aresx_sitous(channel->udp_port);
+ if (server->addr.udp_port) {
+ saddr.sa6.sin6_port = aresx_sitous(server->addr.udp_port);
+ } else {
+ saddr.sa6.sin6_port = aresx_sitous(channel->udp_port);
+ }
memcpy(&saddr.sa6.sin6_addr, &server->addr.addrV6,
sizeof(server->addr.addrV6));
break;
default:
- return -1;
+ return -1; /* LCOV_EXCL_LINE */
}
/* Acquire a socket. */
- s = socket(server->addr.family, SOCK_DGRAM | SOCK_CLOEXEC, 0);
+ s = socket(server->addr.family, SOCK_DGRAM, 0);
if (s == ARES_SOCKET_BAD)
return -1;
@@ -1107,6 +1125,17 @@ static int open_udp_socket(ares_channel channel, struct server_state *server)
return -1;
}
+ if (channel->sock_config_cb)
+ {
+ int err = channel->sock_config_cb(s, SOCK_DGRAM,
+ channel->sock_config_cb_data);
+ if (err < 0)
+ {
+ sclose(s);
+ return err;
+ }
+ }
+
/* Connect to the server. */
if (connect(s, sa, salen) == -1)
{
@@ -1169,7 +1198,7 @@ static int same_questions(const unsigned char *qbuf, int qlen,
q.p += q.namelen;
if (q.p + QFIXEDSZ > qbuf + qlen)
{
- free(q.name);
+ ares_free(q.name);
return 0;
}
q.type = DNS_QUESTION_TYPE(q.p);
@@ -1184,14 +1213,14 @@ static int same_questions(const unsigned char *qbuf, int qlen,
if (ares_expand_name(a.p, abuf, alen, &a.name, &a.namelen)
!= ARES_SUCCESS)
{
- free(q.name);
+ ares_free(q.name);
return 0;
}
a.p += a.namelen;
if (a.p + QFIXEDSZ > abuf + alen)
{
- free(q.name);
- free(a.name);
+ ares_free(q.name);
+ ares_free(a.name);
return 0;
}
a.type = DNS_QUESTION_TYPE(a.p);
@@ -1202,13 +1231,13 @@ static int same_questions(const unsigned char *qbuf, int qlen,
if (strcasecmp(q.name, a.name) == 0 && q.type == a.type
&& q.dnsclass == a.dnsclass)
{
- free(a.name);
+ ares_free(a.name);
break;
}
- free(a.name);
+ ares_free(a.name);
}
- free(q.name);
+ ares_free(q.name);
if (j == a.qdcount)
return 0;
}
@@ -1237,7 +1266,7 @@ static int same_address(struct sockaddr *sa, struct ares_addr *aa)
return 1; /* match */
break;
default:
- break;
+ break; /* LCOV_EXCL_LINE */
}
}
return 0; /* different */
@@ -1274,7 +1303,7 @@ static void end_query (ares_channel channel, struct query *query, int status,
* to the query's tcpbuf and handle these cases, we just give
* such sendreqs their own copy of the query packet.
*/
- sendreq->data_storage = malloc(sendreq->len);
+ sendreq->data_storage = ares_malloc(sendreq->len);
if (sendreq->data_storage != NULL)
{
memcpy(sendreq->data_storage, sendreq->data, sendreq->len);
@@ -1324,7 +1353,7 @@ void ares__free_query(struct query *query)
query->callback = NULL;
query->arg = NULL;
/* Deallocate the memory associated with the query */
- free(query->tcpbuf);
- free(query->server_info);
- free(query);
+ ares_free(query->tcpbuf);
+ ares_free(query->server_info);
+ ares_free(query);
}
diff --git a/ares_query.c b/ares_query.c
index 4bc9c25..b38b8a6 100644
--- a/ares_query.c
+++ b/ares_query.c
@@ -121,7 +121,7 @@ void ares_query(ares_channel channel, const char *name, int dnsclass,
&qlen, (channel->flags & ARES_FLAG_EDNS) ? channel->ednspsz : 0);
if (status != ARES_SUCCESS)
{
- if (qbuf != NULL) free(qbuf);
+ if (qbuf != NULL) ares_free(qbuf);
callback(arg, status, 0, NULL, 0);
return;
}
@@ -129,7 +129,7 @@ void ares_query(ares_channel channel, const char *name, int dnsclass,
channel->next_id = generate_unique_id(channel);
/* Allocate and fill in the query structure. */
- qquery = malloc(sizeof(struct qquery));
+ qquery = ares_malloc(sizeof(struct qquery));
if (!qquery)
{
ares_free_string(qbuf);
@@ -182,5 +182,5 @@ static void qcallback(void *arg, int status, int timeouts, unsigned char *abuf,
}
qquery->callback(qquery->arg, status, timeouts, abuf, alen);
}
- free(qquery);
+ ares_free(qquery);
}
diff --git a/ares_rules.h b/ares_rules.h
index f94c5b5..e617fdc 100644
--- a/ares_rules.h
+++ b/ares_rules.h
@@ -68,21 +68,11 @@
* Verify that some macros are actually defined.
*/
-#ifndef CARES_SIZEOF_LONG
-# error "CARES_SIZEOF_LONG definition is missing!"
- Error Compilation_aborted_CARES_SIZEOF_LONG_is_missing
-#endif
-
#ifndef CARES_TYPEOF_ARES_SOCKLEN_T
# error "CARES_TYPEOF_ARES_SOCKLEN_T definition is missing!"
Error Compilation_aborted_CARES_TYPEOF_ARES_SOCKLEN_T_is_missing
#endif
-#ifndef CARES_SIZEOF_ARES_SOCKLEN_T
-# error "CARES_SIZEOF_ARES_SOCKLEN_T definition is missing!"
- Error Compilation_aborted_CARES_SIZEOF_ARES_SOCKLEN_T_is_missing
-#endif
-
/*
* Macros private to this header file.
*/
@@ -92,15 +82,6 @@
#define CareschkszGE(t1, t2) sizeof(t1) >= sizeof(t2) ? 1 : -1
/*
- * Verify that the size previously defined and expected for long
- * is the same as the one reported by sizeof() at compile time.
- */
-
-typedef char
- __cares_rule_01__
- [CareschkszEQ(long, CARES_SIZEOF_LONG)];
-
-/*
* Verify that the size previously defined and expected for
* ares_socklen_t is actually the the same as the one reported
* by sizeof() at compile time.
@@ -108,7 +89,7 @@ typedef char
typedef char
__cares_rule_02__
- [CareschkszEQ(ares_socklen_t, CARES_SIZEOF_ARES_SOCKLEN_T)];
+ [CareschkszEQ(ares_socklen_t, sizeof(CARES_TYPEOF_ARES_SOCKLEN_T))];
/*
* Verify at compile time that the size of ares_socklen_t as reported
diff --git a/ares_save_options.3 b/ares_save_options.3
index db4055c..bddae04 100644
--- a/ares_save_options.3
+++ b/ares_save_options.3
@@ -40,7 +40,7 @@ to free any associated memory.
can return any of the following values:
.TP 15
.B ARES_SUCCESS
-The channel data was successfuly stored
+The channel data was successfully stored
.TP 15
.B ARES_ENOMEM
The memory was exhausted
diff --git a/ares_search.c b/ares_search.c
index 45ba0a0..68e8525 100644
--- a/ares_search.c
+++ b/ares_search.c
@@ -44,7 +44,7 @@ static void search_callback(void *arg, int status, int timeouts,
static void end_squery(struct search_query *squery, int status,
unsigned char *abuf, int alen);
static int cat_domain(const char *name, const char *domain, char **s);
-static int single_domain(ares_channel channel, const char *name, char **s);
+STATIC_TESTABLE int single_domain(ares_channel channel, const char *name, char **s);
void ares_search(ares_channel channel, const char *name, int dnsclass,
int type, ares_callback callback, void *arg)
@@ -66,24 +66,24 @@ void ares_search(ares_channel channel, const char *name, int dnsclass,
if (s)
{
ares_query(channel, s, dnsclass, type, callback, arg);
- free(s);
+ ares_free(s);
return;
}
/* Allocate a search_query structure to hold the state necessary for
* doing multiple lookups.
*/
- squery = malloc(sizeof(struct search_query));
+ squery = ares_malloc(sizeof(struct search_query));
if (!squery)
{
callback(arg, ARES_ENOMEM, 0, NULL, 0);
return;
}
squery->channel = channel;
- squery->name = strdup(name);
+ squery->name = ares_strdup(name);
if (!squery->name)
{
- free(squery);
+ ares_free(squery);
callback(arg, ARES_ENOMEM, 0, NULL, 0);
return;
}
@@ -123,13 +123,13 @@ void ares_search(ares_channel channel, const char *name, int dnsclass,
if (status == ARES_SUCCESS)
{
ares_query(channel, s, dnsclass, type, search_callback, squery);
- free(s);
+ ares_free(s);
}
else
{
/* failed, free the malloc()ed memory */
- free(squery->name);
- free(squery);
+ ares_free(squery->name);
+ ares_free(squery);
callback(arg, status, 0, NULL, 0);
}
}
@@ -177,7 +177,7 @@ static void search_callback(void *arg, int status, int timeouts,
squery->next_domain++;
ares_query(channel, s, squery->dnsclass, squery->type,
search_callback, squery);
- free(s);
+ ares_free(s);
}
}
else if (squery->status_as_is == -1)
@@ -201,8 +201,8 @@ static void end_squery(struct search_query *squery, int status,
unsigned char *abuf, int alen)
{
squery->callback(squery->arg, status, squery->timeouts, abuf, alen);
- free(squery->name);
- free(squery);
+ ares_free(squery->name);
+ ares_free(squery);
}
/* Concatenate two domains. */
@@ -211,7 +211,7 @@ static int cat_domain(const char *name, const char *domain, char **s)
size_t nlen = strlen(name);
size_t dlen = strlen(domain);
- *s = malloc(nlen + 1 + dlen + 1);
+ *s = ares_malloc(nlen + 1 + dlen + 1);
if (!*s)
return ARES_ENOMEM;
memcpy(*s, name, nlen);
@@ -225,7 +225,7 @@ static int cat_domain(const char *name, const char *domain, char **s)
* the string we should query, in an allocated buffer. If not, set *s
* to NULL.
*/
-static int single_domain(ares_channel channel, const char *name, char **s)
+STATIC_TESTABLE int single_domain(ares_channel channel, const char *name, char **s)
{
size_t len = strlen(name);
const char *hostaliases;
@@ -239,9 +239,9 @@ static int single_domain(ares_channel channel, const char *name, char **s)
/* If the name contains a trailing dot, then the single query is the name
* sans the trailing dot.
*/
- if (name[len - 1] == '.')
+ if ((len > 0) && (name[len - 1] == '.'))
{
- *s = strdup(name);
+ *s = ares_strdup(name);
return (*s) ? ARES_SUCCESS : ARES_ENOMEM;
}
@@ -251,7 +251,7 @@ static int single_domain(ares_channel channel, const char *name, char **s)
hostaliases = getenv("HOSTALIASES");
if (hostaliases)
{
- fp = fopen(hostaliases, "re");
+ fp = fopen(hostaliases, "r");
if (fp)
{
while ((status = ares__read_line(fp, &line, &linesize))
@@ -268,18 +268,18 @@ static int single_domain(ares_channel channel, const char *name, char **s)
q = p + 1;
while (*q && !ISSPACE(*q))
q++;
- *s = malloc(q - p + 1);
+ *s = ares_malloc(q - p + 1);
if (*s)
{
memcpy(*s, p, q - p);
(*s)[q - p] = 0;
}
- free(line);
+ ares_free(line);
fclose(fp);
return (*s) ? ARES_SUCCESS : ARES_ENOMEM;
}
}
- free(line);
+ ares_free(line);
fclose(fp);
if (status != ARES_SUCCESS && status != ARES_EOF)
return status;
@@ -307,7 +307,7 @@ static int single_domain(ares_channel channel, const char *name, char **s)
if (channel->flags & ARES_FLAG_NOSEARCH || channel->ndomains == 0)
{
/* No domain search to do; just try the name as-is. */
- *s = strdup(name);
+ *s = ares_strdup(name);
return (*s) ? ARES_SUCCESS : ARES_ENOMEM;
}
diff --git a/ares_send.c b/ares_send.c
index 1a450b1..88c0035 100644
--- a/ares_send.c
+++ b/ares_send.c
@@ -47,25 +47,25 @@ void ares_send(ares_channel channel, const unsigned char *qbuf, int qlen,
}
/* Allocate space for query and allocated fields. */
- query = malloc(sizeof(struct query));
+ query = ares_malloc(sizeof(struct query));
if (!query)
{
callback(arg, ARES_ENOMEM, 0, NULL, 0);
return;
}
- query->tcpbuf = malloc(qlen + 2);
+ query->tcpbuf = ares_malloc(qlen + 2);
if (!query->tcpbuf)
{
- free(query);
+ ares_free(query);
callback(arg, ARES_ENOMEM, 0, NULL, 0);
return;
}
- query->server_info = malloc(channel->nservers *
- sizeof(query->server_info[0]));
+ query->server_info = ares_malloc(channel->nservers *
+ sizeof(query->server_info[0]));
if (!query->server_info)
{
- free(query->tcpbuf);
- free(query);
+ ares_free(query->tcpbuf);
+ ares_free(query);
callback(arg, ARES_ENOMEM, 0, NULL, 0);
return;
}
diff --git a/ares_set_local_dev.3 b/ares_set_local_dev.3
index cf2b7a6..f446888 100644
--- a/ares_set_local_dev.3
+++ b/ares_set_local_dev.3
@@ -26,7 +26,7 @@ ares_set_local_dev \- Bind to a specific network device when creating sockets.
The \fBares_set_local_dev\fP function causes all future sockets
to be bound to this device with SO_BINDTODEVICE. This forces communications
to go over a certain interface, which can be useful on multi-homed machines.
-This option is only supported on Linux, and root priviledges are required
+This option is only supported on Linux, and root privileges are required
for the option to work. If SO_BINDTODEVICE is not supported or the
setsocktop call fails (probably because of permissions), the error is
silently ignored.
diff --git a/ares_set_servers.3 b/ares_set_servers.3
index 6f25c29..a48c11c 100644
--- a/ares_set_servers.3
+++ b/ares_set_servers.3
@@ -15,12 +15,13 @@
.\"
.TH ARES_SET_SERVERS 3 "5 March 2010"
.SH NAME
-ares_set_servers \- Initialize an ares_channel name servers configuration
+ares_set_servers, ares_set_servers_ports \- Initialize an ares_channel name servers configuration
.SH SYNOPSIS
.nf
.B #include <ares.h>
.PP
.B int ares_set_servers(ares_channel \fIchannel\fP, struct ares_addr_node *\fIservers\fP)
+.B int ares_set_servers_ports(ares_channel \fIchannel\fP, struct ares_addr_port_node *\fIservers\fP)
.fi
.SH DESCRIPTION
The \fBares_set_servers(3)\fP function initializes name servers configuration
@@ -30,19 +31,25 @@ from a
.IR servers
pointer to a linked list of ares_addr_node structs holding name servers
address data.
-
+.PP
The name server linked list pointer argument may be the result of a previous
-call to \fBares_get_servers(3)\fP or a linked list of ares_addr_node structs
-setup by other means.
-
+call to \fBares_get_servers(3)\fP or a linked list of \fBares_addr_node\fP structs
+set up by other means.
+.PP
+The \fBares_set_servers(3)\fP function also allows the specification of UDP and
+TCP ports to be used for communication on a per-server basis. The provided
+linked list argument may be the result of a previous call to
+\fBares_get_servers_ports(3)\fP or a linked list of \fBares_addr_port_node\fP structs
+set up by other means.
+.PP
This function replaces any potentially previously configured name servers
with the ones given in the linked list. So, in order to configure a channel
-with more than one name server all the desired ones must be specified in a
+with more than one name server all the desired ones must be specified in a
single list.
-
-\fBares_set_servers(3)\fP does not take ownership of the linked list argument.
+.PP
+The function does not take ownership of the linked list argument.
The caller is responsible for freeing the linked list when no longer needed.
-
+.PP
This function is capable of handling IPv4 and IPv6 name server
addresses simultaneously, rendering \fBares_init_options(3)\fP with
optmask \fBARES_OPT_SERVERS\fP functionally obsolete except for
@@ -53,7 +60,7 @@ IPv4-only name server usage.
may return any of the following values:
.TP 15
.B ARES_SUCCESS
-The name servers configuration was successfuly initialized.
+The name servers configuration was successfully initialized.
.TP 15
.B ARES_ENOMEM
The process's available memory was exhausted.
@@ -71,7 +78,8 @@ c-ares library initialization not yet performed.
.BR ares_init_options (3),
.BR ares_dup(3)
.SH AVAILABILITY
-ares_set_servers(3) was added in c-ares 1.7.1
+\fBares_set_servers(3)\fP was added in c-ares 1.7.1;
+\fBares_set_servers_ports(3)\fP was added in c-ares 1.11.0.
.SH AUTHOR
Implementation of this function and associated library internals are based
on code, comments and feedback provided in November and December of 2008 by
diff --git a/ares_set_servers_csv.3 b/ares_set_servers_csv.3
index a37c437..cad2078 100644
--- a/ares_set_servers_csv.3
+++ b/ares_set_servers_csv.3
@@ -15,7 +15,7 @@
.\"
.TH ARES_SET_SERVERS_CSV 3 "30 June 2010"
.SH NAME
-ares_set_servers_csv \- Set list of DNS servers to be used.
+ares_set_servers_csv, ares_set_servers_ports_csv \- Set list of DNS servers to be used.
.SH SYNOPSIS
.nf
.B #include <ares.h>
@@ -25,6 +25,12 @@ ares_set_servers_csv \- Set list of DNS servers to be used.
.SH DESCRIPTION
The \fBares_set_servers_csv\fP function sets the list of DNS servers
that ARES will query. The format of the servers option is:
+.B int ares_set_servers_csv(ares_channel \fIchannel\fP, const char* \fIservers\fP)
+.B int ares_set_servers_ports_csv(ares_channel \fIchannel\fP, const char* \fIservers\fP)
+.fi
+.SH DESCRIPTION
+The \fBares_set_servers_csv\fP and \fBares_set_servers_ports_csv\fPfunctions set
+the list of DNS servers that ARES will query. The format of the servers option is:
host[:port][,host[:port]]...
@@ -39,5 +45,33 @@ The port option is currently ignored by c-ares internals
and the standard port is always used.
This function was added in c-ares 1.7.2
+.PP
+The \fBares_set_servers_csv\fP function will ignore any port values specified in
+the input string, whereare the \fBares_set_servers_ports_csv\fP function will
+apply any specified port values as the UDP and TCP port to be used for that
+particular nameserver.
+
+.SH RETURN VALUES
+.B ares_set_servers_csv(3)
+This function may return any of the following values:
+.TP 15
+.B ARES_SUCCESS
+The name servers configuration was successfully initialized.
+.TP 15
+.B ARES_ENOMEM
+The process's available memory was exhausted.
+.TP 15
+.B ARES_ENODATA
+The channel data identified by
+.IR channel
+was invalid.
+.TP 15
+.B ARES_ENOTINITIALIZED
+c-ares library initialization not yet performed.
+.SH SEE ALSO
+.BR ares_set_servers (3)
+.SH AVAILABILITY
+\fBares_set_servers_csv\fP was added in c-ares 1.7.2;
+\fBares_set_servers_ports_csv\fP was added in c-ares 1.11.0.
.SH AUTHOR
Ben Greear
diff --git a/ares_set_servers_ports.3 b/ares_set_servers_ports.3
new file mode 100644
index 0000000..a3be189
--- /dev/null
+++ b/ares_set_servers_ports.3
@@ -0,0 +1 @@
+.so man3/ares_set_servers.3
diff --git a/ares_set_servers_ports_csv.3 b/ares_set_servers_ports_csv.3
new file mode 100644
index 0000000..30535c6
--- /dev/null
+++ b/ares_set_servers_ports_csv.3
@@ -0,0 +1 @@
+.so man3/ares_set_servers_csv.3
diff --git a/ares_set_socket_callback.3 b/ares_set_socket_callback.3
index 68e608b..14a5ad2 100644
--- a/ares_set_socket_callback.3
+++ b/ares_set_socket_callback.3
@@ -6,6 +6,10 @@ ares_set_socket_callback \- Set a socket creation callback
.nf
.B #include <ares.h>
.PP
+.B typedef int (*ares_sock_create_callback)(ares_socket_t \fIsocket_fd\fP,
+ int \fItype\fP,
+ void *\fIuserdata\fP)
+.PP
.B void ares_set_socket_callback(ares_channel \fIchannel\fP,
ares_sock_create_callback \fIcallback\fP,
void *\fIuserdata\fP)
@@ -17,10 +21,10 @@ ares_set_socket_callback \- Set a socket creation callback
This function sets a \fIcallback\fP in the given ares channel handle. This
callback function will be invoked after the socket has been created, and
connected to the remote server. The callback must return ARES_SUCCESS if
-things are fine, or use the standard ares error codes to signal errors
-back. Returned errors will abort the ares operation.
+things are fine, or return -1 to signal an error. A returned error will
+abort the ares operation.
.SH SEE ALSO
-.BR ares_init_options (3)
+.BR ares_init_options (3), ares_set_socket_configure_callback (3)
.SH AVAILABILITY
ares_set_socket_callback(3) was added in c-ares 1.6.0
.SH AUTHOR
diff --git a/ares_set_socket_configure_callback.3 b/ares_set_socket_configure_callback.3
new file mode 100644
index 0000000..d3b2f93
--- /dev/null
+++ b/ares_set_socket_configure_callback.3
@@ -0,0 +1,33 @@
+.\"
+.TH ARES_SET_SOCKET_CONFIGURE_CALLBACK 3 "6 Feb 2016"
+.SH NAME
+ares_set_socket_configure_callback \- Set a socket configuration callback
+.SH SYNOPSIS
+.nf
+.B #include <ares.h>
+.PP
+.B typedef int (*ares_sock_config_callback)(ares_socket_t \fIsocket_fd\fP,
+ int \fItype\fP,
+ void *\fIuserdata\fP)
+.PP
+.B void ares_set_socket_configure_callback(ares_channel \fIchannel\fP,
+ ares_sock_config_callback \fIcallback\fP,
+ void *\fIuserdata\fP)
+.PP
+.B cc file.c -lcares
+.fi
+.SH DESCRIPTION
+.PP
+This function sets a \fIcallback\fP in the given ares channel handle. This
+callback function will be invoked after the socket has been created, but
+before it has been connected to the remote server, which is an ideal time
+to configure various socket options. The callback must return ARES_SUCCESS
+if things are fine, or return -1 to signal an error. A returned error will
+abort the ares operation.
+.SH SEE ALSO
+.BR ares_init_options (3), ares_set_socket_callback (3)
+.SH AVAILABILITY
+ares_set_socket_configure_callback(3) was added in c-ares 1.11.0
+.SH AUTHOR
+Andrew Ayer
+
diff --git a/ares_set_sortlist.3 b/ares_set_sortlist.3
new file mode 100644
index 0000000..24a9790
--- /dev/null
+++ b/ares_set_sortlist.3
@@ -0,0 +1,58 @@
+.\"
+.\" 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.
+.\"
+.TH ARES_SET_SORTLIST 3 "23 November 2015"
+.SH NAME
+ares_set_sortlist \- Initialize an ares_channel sortlist configuration
+.SH SYNOPSIS
+.nf
+.B #include <ares.h>
+.PP
+.B int ares_set_sortlist(ares_channel \fIchannel\fP, const char *\fIsortstr\fP)
+.fi
+.SH DESCRIPTION
+The \fBares_set_sortlist(3)\fP function initializes an address sortlist configuration
+for the channel data identified by
+.IR channel ,
+so that addresses returned by \fBares_gethostbyname(3)\fP are sorted according to the
+sortlist. The provided
+.IR sortstr
+string that holds a space separated list of IP-address-netmask pairs. The
+netmask is optional but follows the address after a slash if present. For example,
+"130.155.160.0/255.255.240.0 130.155.0.0".
+
+This function replaces any potentially previously configured address sortlist
+with the ones given in the configuration string.
+
+.SH RETURN VALUES
+.B ares_set_sortlist(3)
+may return any of the following values:
+.TP 15
+.B ARES_SUCCESS
+The sortlist configuration was successfully initialized.
+.TP 15
+.B ARES_ENOMEM
+The process's available memory was exhausted.
+.TP 15
+.B ARES_ENODATA
+The channel data identified by
+.IR channel
+was invalid.
+.TP 15
+.B ARES_ENOTINITIALIZED
+c-ares library initialization not yet performed.
+.SH SEE ALSO
+.BR ares_init_options (3),
+.BR ares_dup(3)
+.SH AVAILABILITY
+ares_set_sortlist(3) was added in c-ares 1.11.0
diff --git a/ares_strdup.c b/ares_strdup.c
index 1804327..0c3dcff 100644
--- a/ares_strdup.c
+++ b/ares_strdup.c
@@ -17,26 +17,33 @@
#include "ares_setup.h"
#include "ares_strdup.h"
+#include "ares.h"
+#include "ares_private.h"
-#ifndef HAVE_STRDUP
char *ares_strdup(const char *s1)
{
- size_t sz;
- char * s2;
+#ifdef HAVE_STRDUP
+ if (ares_malloc == malloc)
+ return strdup(s1);
+ else
+#endif
+ {
+ size_t sz;
+ char * s2;
- if(s1) {
- sz = strlen(s1);
- if(sz < (size_t)-1) {
- sz++;
- if(sz < ((size_t)-1) / sizeof(char)) {
- s2 = malloc(sz * sizeof(char));
- if(s2) {
- memcpy(s2, s1, sz * sizeof(char));
- return s2;
+ if(s1) {
+ sz = strlen(s1);
+ if(sz < (size_t)-1) {
+ sz++;
+ if(sz < ((size_t)-1) / sizeof(char)) {
+ s2 = ares_malloc(sz * sizeof(char));
+ if(s2) {
+ memcpy(s2, s1, sz * sizeof(char));
+ return s2;
+ }
}
}
}
+ return (char *)NULL;
}
- return (char *)NULL;
}
-#endif
diff --git a/ares_strdup.h b/ares_strdup.h
index c413a94..67f2a74 100644
--- a/ares_strdup.h
+++ b/ares_strdup.h
@@ -19,8 +19,6 @@
#include "ares_setup.h"
-#ifndef HAVE_STRDUP
extern char *ares_strdup(const char *s1);
-#endif
#endif /* HEADER_CARES_STRDUP_H */
diff --git a/ares_timeout.c b/ares_timeout.c
index 0b5a435..293e4af 100644
--- a/ares_timeout.c
+++ b/ares_timeout.c
@@ -23,6 +23,13 @@
#include "ares.h"
#include "ares_private.h"
+/* return time offset between now and (future) check, in milliseconds */
+static long timeoffset(struct timeval *now, struct timeval *check)
+{
+ return (check->tv_sec - now->tv_sec)*1000 +
+ (check->tv_usec - now->tv_usec)/1000;
+}
+
/* WARNING: Beware that this is linear in the number of outstanding
* requests! You are probably far better off just calling ares_process()
* once per second, rather than calling ares_timeout() to figure out
@@ -53,7 +60,7 @@ struct timeval *ares_timeout(ares_channel channel, struct timeval *maxtv,
query = list_node->data;
if (query->timeout.tv_sec == 0)
continue;
- offset = ares__timeoffset(&now, &query->timeout);
+ offset = timeoffset(&now, &query->timeout);
if (offset < 0)
offset = 0;
if (min_offset == -1 || offset < min_offset)
diff --git a/ares_version.h b/ares_version.h
index cdd4992..92c8584 100644
--- a/ares_version.h
+++ b/ares_version.h
@@ -3,15 +3,15 @@
#define ARES__VERSION_H
/* This is the global package copyright */
-#define ARES_COPYRIGHT "2004 - 2013 Daniel Stenberg, <daniel@haxx.se>."
+#define ARES_COPYRIGHT "2004 - 2016 Daniel Stenberg, <daniel@haxx.se>."
#define ARES_VERSION_MAJOR 1
-#define ARES_VERSION_MINOR 10
+#define ARES_VERSION_MINOR 12
#define ARES_VERSION_PATCH 0
#define ARES_VERSION ((ARES_VERSION_MAJOR<<16)|\
(ARES_VERSION_MINOR<<8)|\
(ARES_VERSION_PATCH))
-#define ARES_VERSION_STR "1.10.0-DEV"
+#define ARES_VERSION_STR "1.12.0"
#if (ARES_VERSION >= 0x010700)
# define CARES_HAVE_ARES_LIBRARY_INIT 1
diff --git a/ares_writev.c b/ares_writev.c
index 9e8e2d6..008efdd 100644
--- a/ares_writev.c
+++ b/ares_writev.c
@@ -54,7 +54,7 @@ ssize_t ares_writev(ares_socket_t s, const struct iovec *iov, int iovcnt)
return (0);
/* Allocate a temporary buffer to hold the data */
- buffer = malloc(bytes);
+ buffer = ares_malloc(bytes);
if (!buffer)
{
SET_ERRNO(ENOMEM);
@@ -71,7 +71,7 @@ ssize_t ares_writev(ares_socket_t s, const struct iovec *iov, int iovcnt)
/* Send buffer contents */
result = swrite(s, buffer, bytes);
- free(buffer);
+ ares_free(buffer);
return (result);
}
diff --git a/bitncmp.c b/bitncmp.c
index faedff9..1468d49 100644
--- a/bitncmp.c
+++ b/bitncmp.c
@@ -26,7 +26,7 @@
* bitncmp(l, r, n)
* compare bit masks l and r, for n bits.
* return:
- * -1, 1, or 0 in the libc tradition.
+ * <0, >0, or 0 in the libc tradition.
* note:
* network byte order assumed. this means 192.5.5.240/28 has
* 0x11110000 in its fourth octet.
diff --git a/buildconf b/buildconf
index c42f8a1..a779d86 100755
--- a/buildconf
+++ b/buildconf
@@ -74,25 +74,25 @@ want_lt_minor=4
want_lt_patch=2
want_lt_version=1.4.2
-# This approach that tries 'glibtool' first is intended for systems that
-# have GNU libtool named as 'glibtool' and libtool not being GNU's.
+# This approach that tries 'glibtoolize first is intended for systems that
+# have GNU libtool named as 'glibtoolize' and libtoolize not being GNU's.
-libtool=`findtool glibtool 2>/dev/null`
-if test ! -x "$libtool"; then
- libtool=`findtool ${LIBTOOL:-libtool}`
+libtoolize=`findtool glibtoolize 2>/dev/null`
+if test ! -x "$libtoolize"; then
+ libtoolize=`findtool ${LIBTOOLIZE:-libtoolize}`
fi
-if test -z "$libtool"; then
- echo "buildconf: libtool not found."
- echo " You need GNU libtool $want_lt_version or newer installed."
+if test -z "$libtoolize"; then
+ echo "buildconf: libtoolize not found."
+ echo " You need GNU libtoolize $want_lt_version or newer installed."
exit 1
fi
-lt_pver=`$libtool --version 2>/dev/null|head -n 1`
+lt_pver=`$libtoolize --version 2>/dev/null|head -n 1`
lt_qver=`echo $lt_pver|sed -e "s/([^)]*)//g" -e "s/^[^0-9]*//g"`
lt_version=`echo $lt_qver|sed -e "s/[- ].*//" -e "s/\([a-z]*\)$//"`
if test -z "$lt_version"; then
- echo "buildconf: libtool not found."
- echo " You need GNU libtool $want_lt_version or newer installed."
+ echo "buildconf: libtoolize not found."
+ echo " You need GNU libtoolize $want_lt_version or newer installed."
exit 1
fi
old_IFS=$IFS; IFS='.'; set $lt_version; IFS=$old_IFS
@@ -122,23 +122,8 @@ else
lt_status="good"
fi
if test "$lt_status" != "good"; then
- echo "buildconf: libtool version $lt_version found."
- echo " You need GNU libtool $want_lt_version or newer installed."
- exit 1
-fi
-
-#--------------------------------------------------------------------------
-# GNU libtoolize check
-#
-if test -z "$LIBTOOLIZE"; then
- # use (g)libtoolize from same location as (g)libtool
- libtoolize="${libtool}ize"
-else
- libtoolize=`findtool $LIBTOOLIZE`
-fi
-if test ! -f "$libtoolize"; then
- echo "buildconf: libtoolize not found."
- echo " You need GNU libtoolize $want_lt_version or newer installed."
+ echo "buildconf: libtoolize version $lt_version found."
+ echo " You need GNU libtoolize $want_lt_version or newer installed."
exit 1
fi
@@ -304,4 +289,9 @@ fi
# Finished successfully.
#
echo "buildconf: OK"
+
+if test -f "test/buildconf"; then
+ cd test && ./buildconf
+fi
+
exit 0
diff --git a/cares.rc b/cares.rc
index 50a5e8e..76ec06c 100644
--- a/cares.rc
+++ b/cares.rc
@@ -1,5 +1,5 @@
-/* Copyright (C) 2009 by Daniel Stenberg
+/* Copyright (C) 2009-2016 by Daniel Stenberg
*
* Permission to use, copy, modify, and distribute this
* software and its documentation for any purpose and without
@@ -39,7 +39,7 @@ BEGIN
BEGIN
BLOCK "040904b0"
BEGIN
- VALUE "CompanyName", "The c-ares library, http://c-ares.haxx.se/\0"
+ VALUE "CompanyName", "The c-ares library, https://c-ares.haxx.se/\0"
#if defined(DEBUGBUILD) || defined(_DEBUG)
VALUE "FileDescription", "c-ares Debug Shared Library\0"
VALUE "FileVersion", ARES_VERSION_STR "\0"
@@ -54,7 +54,7 @@ BEGIN
VALUE "ProductName", "The c-ares library\0"
VALUE "ProductVersion", ARES_VERSION_STR "\0"
VALUE "LegalCopyright", "© " ARES_COPYRIGHT "\0"
- VALUE "License", "http://c-ares.haxx.se/license.html\0"
+ VALUE "License", "https://c-ares.haxx.se/license.html\0"
END
END
diff --git a/config-dos.h b/config-dos.h
index f80ca2c..b895987 100644
--- a/config-dos.h
+++ b/config-dos.h
@@ -32,9 +32,6 @@
#define NEED_MALLOC_H 1
#define RETSIGTYPE void
-#define SIZEOF_INT 4
-#define SIZEOF_SHORT 2
-#define SIZEOF_SIZE_T 4
#define TIME_WITH_SYS_TIME 1
/* Qualifiers for send(), recv(), recvfrom() and getnameinfo(). */
diff --git a/config-win32.h b/config-win32.h
index 1245ba2..dd95525 100644
--- a/config-win32.h
+++ b/config-win32.h
@@ -211,6 +211,11 @@
/* Define to the return type of signal handlers (int or void). */
#define RETSIGTYPE void
+#ifdef __cplusplus
+/* Compiling headers in C++ mode means bool is available */
+#define HAVE_BOOL_T
+#endif
+
/* Define if ssize_t is not an available 'typedefed' type. */
#ifndef _SSIZE_T_DEFINED
# if (defined(__WATCOMC__) && (__WATCOMC__ >= 1240)) || \
@@ -229,19 +234,6 @@
/* TYPE SIZES */
/* ---------------------------------------------------------------- */
-/* Define to the size of `int', as computed by sizeof. */
-#define SIZEOF_INT 4
-
-/* Define to the size of `short', as computed by sizeof. */
-#define SIZEOF_SHORT 2
-
-/* Define to the size of `size_t', as computed by sizeof. */
-#if defined(_WIN64)
-# define SIZEOF_SIZE_T 8
-#else
-# define SIZEOF_SIZE_T 4
-#endif
-
/* ---------------------------------------------------------------- */
/* STRUCT RELATED */
/* ---------------------------------------------------------------- */
diff --git a/configure.ac b/configure.ac
index b77d803..b89ce35 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,7 +1,7 @@
AC_PREREQ(2.57)
dnl Version not hardcoded here. Fetched later from ares_version.h
-AC_INIT([c-ares], [-],
+AC_INIT([c-ares], [1.12.0],
[c-ares mailing list: http://cool.haxx.se/mailman/listinfo/c-ares])
XC_OVR_ZZ50
@@ -12,6 +12,7 @@ AC_CONFIG_SRCDIR([ares_ipv6.h])
AC_CONFIG_HEADERS([ares_config.h ares_build.h])
AC_CONFIG_MACRO_DIR([m4])
AM_MAINTAINER_MODE
+m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
CARES_CHECK_OPTION_DEBUG
CARES_CHECK_OPTION_OPTIMIZE
@@ -19,6 +20,7 @@ CARES_CHECK_OPTION_WARNINGS
CARES_CHECK_OPTION_WERROR
CARES_CHECK_OPTION_CURLDEBUG
CARES_CHECK_OPTION_SYMBOL_HIDING
+CARES_CHECK_OPTION_EXPOSE_STATICS
XC_CHECK_PATH_SEPARATOR
@@ -64,6 +66,8 @@ if test -z "$AR" || test "$AR" = "not_found"; then
fi
AC_SUBST([AR])
+AX_CODE_COVERAGE
+
dnl Remove non-configure distributed ares_build.h
if test -f ${srcdir}/ares_build.h; then
rm -f ${srcdir}/ares_build.h
@@ -78,8 +82,9 @@ dnl Get system canonical name
AC_DEFINE_UNQUOTED(OS, "${host}", [cpu-machine-OS])
XC_CHECK_PROG_CC
+AX_CXX_COMPILE_STDCXX_11([noext],[optional])
-AM_INIT_AUTOMAKE
+XC_AUTOMAKE
dnl This defines _ALL_SOURCE for AIX
CARES_CHECK_AIX_ALL_SOURCE
@@ -346,6 +351,30 @@ if test "$HAVE_GETHOSTBYNAME" != "1"; then
AC_MSG_ERROR([couldn't find libraries for gethostbyname()])
fi
+dnl resolv lib for iPhone
+AS_IF([test "x$host_vendor" = "xapple"], [
+ AC_MSG_CHECKING([for iPhone target])
+ AC_COMPILE_IFELSE([
+ AC_LANG_PROGRAM([[
+#include "TargetConditionals.h"
+ ]], [[
+#if TARGET_OS_IPHONE == 0
+#error Not an iPhone target
+#endif
+return 0;
+ ]])
+ ],[
+ AC_MSG_RESULT([yes])
+ AC_SEARCH_LIBS([res_servicename], [resolv], [
+ AC_DEFINE([CARES_USE_LIBRESOLV], [1], [Use resolver library to configure cares])
+ ], [
+ AC_MSG_ERROR([Unable to find libresolv which is required for iPhone targets])
+ ])
+ ],[
+ AC_MSG_RESULT([no])
+ ])
+])
+
dnl resolve lib?
AC_CHECK_FUNC(strcasecmp, , [ AC_CHECK_LIB(resolve, strcasecmp) ])
@@ -453,13 +482,6 @@ AC_TYPE_SIZE_T
AC_HEADER_TIME
CURL_CHECK_STRUCT_TIMEVAL
-AC_CHECK_SIZEOF(size_t)
-AC_CHECK_SIZEOF(long)
-AC_CHECK_SIZEOF(int)
-AC_CHECK_SIZEOF(short)
-CARES_CONFIGURE_LONG
-AC_CHECK_SIZEOF(time_t)
-
AC_CHECK_TYPE(long long,
[AC_DEFINE(HAVE_LONGLONG, 1,
[Define to 1 if the compiler supports the 'long long' data type.])]
@@ -732,63 +754,6 @@ AC_CHECK_FUNCS([bitncmp \
])
-AC_CHECK_SIZEOF(struct in6_addr, ,
-[
-#undef inline
-#ifdef HAVE_WINDOWS_H
-#ifndef WIN32_LEAN_AND_MEAN
-#define WIN32_LEAN_AND_MEAN
-#endif
-#include <windows.h>
-#ifdef HAVE_WINSOCK2_H
-#include <winsock2.h>
-#ifdef HAVE_WS2TCPIP_H
-#include <ws2tcpip.h>
-#endif
-#endif
-#else
-#ifdef HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
-#ifdef HAVE_SYS_SOCKET_H
-#include <sys/socket.h>
-#endif
-#ifdef HAVE_NETINET_IN_H
-#include <netinet/in.h>
-#endif
-#endif
-]
-)
-
-AC_CHECK_SIZEOF(struct in_addr, ,
-[
-#undef inline
-#ifdef HAVE_WINDOWS_H
-#ifndef WIN32_LEAN_AND_MEAN
-#define WIN32_LEAN_AND_MEAN
-#endif
-#include <windows.h>
-#ifdef HAVE_WINSOCK2_H
-#include <winsock2.h>
-#ifdef HAVE_WS2TCPIP_H
-#include <ws2tcpip.h>
-#endif
-#endif
-#else
-#ifdef HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
-#ifdef HAVE_SYS_SOCKET_H
-#include <sys/socket.h>
-#endif
-#ifdef HAVE_NETINET_IN_H
-#include <netinet/in.h>
-#endif
-#endif
-]
-)
-
-
dnl Check if the getnameinfo function is available
dnl and get the types of five of its arguments.
CURL_CHECK_FUNC_GETNAMEINFO
@@ -850,5 +815,32 @@ squeeze CARES_PRIVATE_LIBS
XC_CHECK_BUILD_FLAGS
+AC_MSG_CHECKING([whether to build tests])
+AC_ARG_ENABLE(tests,
+ AC_HELP_STRING([--enable-tests], [build test suite]),
+ [ build_tests="$enableval" ],
+ [ if test "x$HAVE_CXX11" = "x1" && test "x$cross_compiling" = "xno" ; then
+ build_tests="yes"
+ else
+ build_tests="no"
+ fi
+ ]
+)
+
+if test "x$build_tests" = "xyes" ; then
+ if test "x$HAVE_CXX11" = "0" ; then
+ AC_MSG_ERROR([*** Building tests requires a CXX11 compiler])
+ fi
+ if test "x$cross_compiling" = "xyes" ; then
+ AC_MSG_ERROR([*** Tests not supported when cross compiling])
+ fi
+fi
+AC_MSG_RESULT([$build_tests])
+
+if test "x$build_tests" = "xyes" ; then
+ AC_CONFIG_SUBDIRS([test])
+fi
+
AC_CONFIG_FILES([Makefile libcares.pc])
AC_OUTPUT
+XC_AMEND_DISTCLEAN(['.'])
diff --git a/inet_net_pton.c b/inet_net_pton.c
index 71c07c5..b64fc5b 100644
--- a/inet_net_pton.c
+++ b/inet_net_pton.c
@@ -151,7 +151,7 @@ inet_net_pton_ipv4(const char *src, unsigned char *dst, size_t size)
/* If nothing was written to the destination, we found no address. */
if (dst == odst)
- goto enoent;
+ goto enoent; /* LCOV_EXCL_LINE: all valid paths above increment dst */
/* If no CIDR spec was given, infer width from net class. */
if (bits == -1) {
if (*odst >= 240) /* Class E */
diff --git a/install-sh b/install-sh
index e843669..377bb86 100755
--- a/install-sh
+++ b/install-sh
@@ -1,250 +1,527 @@
#!/bin/sh
-#
# install - install a program, script, or datafile
-# This comes from X11R5 (mit/util/scripts/install.sh).
+
+scriptversion=2011-11-20.07; # UTC
+
+# This originates from X11R5 (mit/util/scripts/install.sh), which was
+# later released in X11R6 (xc/config/util/install.sh) with the
+# following copyright and license.
+#
+# Copyright (C) 1994 X Consortium
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to
+# deal in the Software without restriction, including without limitation the
+# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+# sell copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
+# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-# Copyright 1991 by the Massachusetts Institute of Technology
+# Except as contained in this notice, the name of the X Consortium shall not
+# be used in advertising or otherwise to promote the sale, use or other deal-
+# ings in this Software without prior written authorization from the X Consor-
+# tium.
#
-# Permission to use, copy, modify, distribute, and sell this software and its
-# documentation for any purpose is hereby granted without fee, 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.
+#
+# FSF changes to this file are in the public domain.
#
# Calling this script install-sh is preferred over install.sh, to prevent
-# `make' implicit rules from creating a file called install from it
+# 'make' implicit rules from creating a file called install from it
# when there is no Makefile.
#
# This script is compatible with the BSD install script, but was written
-# from scratch. It can only install one file at a time, a restriction
-# shared with many OS's install programs.
+# from scratch.
+nl='
+'
+IFS=" "" $nl"
# set DOITPROG to echo to test this script
# Don't use :- since 4.3BSD and earlier shells don't like it.
-doit="${DOITPROG-}"
-
-
-# put in absolute paths if you don't have them in your path; or use env. vars.
-
-mvprog="${MVPROG-mv}"
-cpprog="${CPPROG-cp}"
-chmodprog="${CHMODPROG-chmod}"
-chownprog="${CHOWNPROG-chown}"
-chgrpprog="${CHGRPPROG-chgrp}"
-stripprog="${STRIPPROG-strip}"
-rmprog="${RMPROG-rm}"
-mkdirprog="${MKDIRPROG-mkdir}"
-
-transformbasename=""
-transform_arg=""
-instcmd="$mvprog"
-chmodcmd="$chmodprog 0755"
-chowncmd=""
-chgrpcmd=""
-stripcmd=""
-rmcmd="$rmprog -f"
-mvcmd="$mvprog"
-src=""
-dst=""
-dir_arg=""
-
-while [ x"$1" != x ]; do
- case $1 in
- -c) instcmd="$cpprog"
- shift
- continue;;
-
- -d) dir_arg=true
- shift
- continue;;
-
- -m) chmodcmd="$chmodprog $2"
- shift
- shift
- continue;;
-
- -o) chowncmd="$chownprog $2"
- shift
- shift
- continue;;
-
- -g) chgrpcmd="$chgrpprog $2"
- shift
- shift
- continue;;
-
- -s) stripcmd="$stripprog"
- shift
- continue;;
-
- -t=*) transformarg=`echo $1 | sed 's/-t=//'`
- shift
- continue;;
-
- -b=*) transformbasename=`echo $1 | sed 's/-b=//'`
- shift
- continue;;
-
- *) if [ x"$src" = x ]
- then
- src=$1
- else
- # this colon is to work around a 386BSD /bin/sh bug
- :
- dst=$1
- fi
- shift
- continue;;
- esac
-done
-
-if [ x"$src" = x ]
-then
- echo "install: no input file specified"
- exit 1
+doit=${DOITPROG-}
+if test -z "$doit"; then
+ doit_exec=exec
else
- true
+ doit_exec=$doit
fi
-if [ x"$dir_arg" != x ]; then
- dst=$src
- src=""
-
- if [ -d $dst ]; then
- instcmd=:
- else
- instcmd=mkdir
- fi
-else
+# Put in absolute file names if you don't have them in your path;
+# or use environment vars.
+
+chgrpprog=${CHGRPPROG-chgrp}
+chmodprog=${CHMODPROG-chmod}
+chownprog=${CHOWNPROG-chown}
+cmpprog=${CMPPROG-cmp}
+cpprog=${CPPROG-cp}
+mkdirprog=${MKDIRPROG-mkdir}
+mvprog=${MVPROG-mv}
+rmprog=${RMPROG-rm}
+stripprog=${STRIPPROG-strip}
+
+posix_glob='?'
+initialize_posix_glob='
+ test "$posix_glob" != "?" || {
+ if (set -f) 2>/dev/null; then
+ posix_glob=
+ else
+ posix_glob=:
+ fi
+ }
+'
-# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
-# might cause directories to be created, which would be especially bad
-# if $src (and thus $dsttmp) contains '*'.
+posix_mkdir=
- if [ -f $src -o -d $src ]
- then
- true
- else
- echo "install: $src does not exist"
- exit 1
- fi
-
- if [ x"$dst" = x ]
- then
- echo "install: no destination specified"
- exit 1
- else
- true
- fi
+# Desired mode of installed file.
+mode=0755
-# If destination is a directory, append the input filename; if your system
-# does not like double slashes in filenames, you may need to add some logic
+chgrpcmd=
+chmodcmd=$chmodprog
+chowncmd=
+mvcmd=$mvprog
+rmcmd="$rmprog -f"
+stripcmd=
- if [ -d $dst ]
- then
- dst="$dst"/`basename $src`
- else
- true
- fi
-fi
+src=
+dst=
+dir_arg=
+dst_arg=
-## this sed command emulates the dirname command
-dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
+copy_on_change=false
+no_target_directory=
-# Make sure that the destination directory exists.
-# this part is taken from Noah Friedman's mkinstalldirs script
+usage="\
+Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
+ or: $0 [OPTION]... SRCFILES... DIRECTORY
+ or: $0 [OPTION]... -t DIRECTORY SRCFILES...
+ or: $0 [OPTION]... -d DIRECTORIES...
-# Skip lots of stat calls in the usual case.
-if [ ! -d "$dstdir" ]; then
-defaultIFS='
-'
-IFS="${IFS-${defaultIFS}}"
+In the 1st form, copy SRCFILE to DSTFILE.
+In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
+In the 4th, create DIRECTORIES.
-oIFS="${IFS}"
-# Some sh's can't handle IFS=/ for some reason.
-IFS='%'
-set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
-IFS="${oIFS}"
+Options:
+ --help display this help and exit.
+ --version display version info and exit.
-pathcomp=''
+ -c (ignored)
+ -C install only if different (preserve the last data modification time)
+ -d create directories instead of installing files.
+ -g GROUP $chgrpprog installed files to GROUP.
+ -m MODE $chmodprog installed files to MODE.
+ -o USER $chownprog installed files to USER.
+ -s $stripprog installed files.
+ -t DIRECTORY install into DIRECTORY.
+ -T report an error if DSTFILE is a directory.
-while [ $# -ne 0 ] ; do
- pathcomp="${pathcomp}${1}"
- shift
+Environment variables override the default commands:
+ CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG
+ RMPROG STRIPPROG
+"
- if [ ! -d "${pathcomp}" ] ;
- then
- $mkdirprog "${pathcomp}"
- else
- true
- fi
+while test $# -ne 0; do
+ case $1 in
+ -c) ;;
- pathcomp="${pathcomp}/"
-done
-fi
+ -C) copy_on_change=true;;
-if [ x"$dir_arg" != x ]
-then
- $doit $instcmd $dst &&
+ -d) dir_arg=true;;
- if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
- if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
- if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
- if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
-else
+ -g) chgrpcmd="$chgrpprog $2"
+ shift;;
-# If we're going to rename the final executable, determine the name now.
+ --help) echo "$usage"; exit $?;;
- if [ x"$transformarg" = x ]
- then
- dstfile=`basename $dst`
- else
- dstfile=`basename $dst $transformbasename |
- sed $transformarg`$transformbasename
- fi
+ -m) mode=$2
+ case $mode in
+ *' '* | *' '* | *'
+'* | *'*'* | *'?'* | *'['*)
+ echo "$0: invalid mode: $mode" >&2
+ exit 1;;
+ esac
+ shift;;
-# don't allow the sed command to completely eliminate the filename
+ -o) chowncmd="$chownprog $2"
+ shift;;
- if [ x"$dstfile" = x ]
- then
- dstfile=`basename $dst`
- else
- true
- fi
+ -s) stripcmd=$stripprog;;
-# Make a temp file name in the proper directory.
+ -t) dst_arg=$2
+ # Protect names problematic for 'test' and other utilities.
+ case $dst_arg in
+ -* | [=\(\)!]) dst_arg=./$dst_arg;;
+ esac
+ shift;;
- dsttmp=$dstdir/#inst.$$#
+ -T) no_target_directory=true;;
-# Move or copy the file name to the temp name
+ --version) echo "$0 $scriptversion"; exit $?;;
- $doit $instcmd $src $dsttmp &&
+ --) shift
+ break;;
- trap "rm -f ${dsttmp}" 0 &&
+ -*) echo "$0: invalid option: $1" >&2
+ exit 1;;
-# and set any options; do chmod last to preserve setuid bits
+ *) break;;
+ esac
+ shift
+done
-# If any of these fail, we abort the whole thing. If we want to
-# ignore errors from any of these, just make sure not to ignore
-# errors from the above "$doit $instcmd $src $dsttmp" command.
+if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
+ # When -d is used, all remaining arguments are directories to create.
+ # When -t is used, the destination is already specified.
+ # Otherwise, the last argument is the destination. Remove it from $@.
+ for arg
+ do
+ if test -n "$dst_arg"; then
+ # $@ is not empty: it contains at least $arg.
+ set fnord "$@" "$dst_arg"
+ shift # fnord
+ fi
+ shift # arg
+ dst_arg=$arg
+ # Protect names problematic for 'test' and other utilities.
+ case $dst_arg in
+ -* | [=\(\)!]) dst_arg=./$dst_arg;;
+ esac
+ done
+fi
- if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
- if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
- if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
- if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
+if test $# -eq 0; then
+ if test -z "$dir_arg"; then
+ echo "$0: no input file specified." >&2
+ exit 1
+ fi
+ # It's OK to call 'install-sh -d' without argument.
+ # This can happen when creating conditional directories.
+ exit 0
+fi
-# Now rename the file to the real destination.
+if test -z "$dir_arg"; then
+ do_exit='(exit $ret); exit $ret'
+ trap "ret=129; $do_exit" 1
+ trap "ret=130; $do_exit" 2
+ trap "ret=141; $do_exit" 13
+ trap "ret=143; $do_exit" 15
+
+ # Set umask so as not to create temps with too-generous modes.
+ # However, 'strip' requires both read and write access to temps.
+ case $mode in
+ # Optimize common cases.
+ *644) cp_umask=133;;
+ *755) cp_umask=22;;
+
+ *[0-7])
+ if test -z "$stripcmd"; then
+ u_plus_rw=
+ else
+ u_plus_rw='% 200'
+ fi
+ cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;;
+ *)
+ if test -z "$stripcmd"; then
+ u_plus_rw=
+ else
+ u_plus_rw=,u+rw
+ fi
+ cp_umask=$mode$u_plus_rw;;
+ esac
+fi
- $doit $rmcmd -f $dstdir/$dstfile &&
- $doit $mvcmd $dsttmp $dstdir/$dstfile
+for src
+do
+ # Protect names problematic for 'test' and other utilities.
+ case $src in
+ -* | [=\(\)!]) src=./$src;;
+ esac
+
+ if test -n "$dir_arg"; then
+ dst=$src
+ dstdir=$dst
+ test -d "$dstdir"
+ dstdir_status=$?
+ else
+
+ # Waiting for this to be detected by the "$cpprog $src $dsttmp" command
+ # might cause directories to be created, which would be especially bad
+ # if $src (and thus $dsttmp) contains '*'.
+ if test ! -f "$src" && test ! -d "$src"; then
+ echo "$0: $src does not exist." >&2
+ exit 1
+ fi
+
+ if test -z "$dst_arg"; then
+ echo "$0: no destination specified." >&2
+ exit 1
+ fi
+ dst=$dst_arg
+
+ # If destination is a directory, append the input filename; won't work
+ # if double slashes aren't ignored.
+ if test -d "$dst"; then
+ if test -n "$no_target_directory"; then
+ echo "$0: $dst_arg: Is a directory" >&2
+ exit 1
+ fi
+ dstdir=$dst
+ dst=$dstdir/`basename "$src"`
+ dstdir_status=0
+ else
+ # Prefer dirname, but fall back on a substitute if dirname fails.
+ dstdir=`
+ (dirname "$dst") 2>/dev/null ||
+ expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ X"$dst" : 'X\(//\)[^/]' \| \
+ X"$dst" : 'X\(//\)$' \| \
+ X"$dst" : 'X\(/\)' \| . 2>/dev/null ||
+ echo X"$dst" |
+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)[^/].*/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\).*/{
+ s//\1/
+ q
+ }
+ s/.*/./; q'
+ `
+
+ test -d "$dstdir"
+ dstdir_status=$?
+ fi
+ fi
+
+ obsolete_mkdir_used=false
+
+ if test $dstdir_status != 0; then
+ case $posix_mkdir in
+ '')
+ # Create intermediate dirs using mode 755 as modified by the umask.
+ # This is like FreeBSD 'install' as of 1997-10-28.
+ umask=`umask`
+ case $stripcmd.$umask in
+ # Optimize common cases.
+ *[2367][2367]) mkdir_umask=$umask;;
+ .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;
+
+ *[0-7])
+ mkdir_umask=`expr $umask + 22 \
+ - $umask % 100 % 40 + $umask % 20 \
+ - $umask % 10 % 4 + $umask % 2
+ `;;
+ *) mkdir_umask=$umask,go-w;;
+ esac
+
+ # With -d, create the new directory with the user-specified mode.
+ # Otherwise, rely on $mkdir_umask.
+ if test -n "$dir_arg"; then
+ mkdir_mode=-m$mode
+ else
+ mkdir_mode=
+ fi
-fi &&
+ posix_mkdir=false
+ case $umask in
+ *[123567][0-7][0-7])
+ # POSIX mkdir -p sets u+wx bits regardless of umask, which
+ # is incompatible with FreeBSD 'install' when (umask & 300) != 0.
+ ;;
+ *)
+ tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
+ trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0
+
+ if (umask $mkdir_umask &&
+ exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1
+ then
+ if test -z "$dir_arg" || {
+ # Check for POSIX incompatibilities with -m.
+ # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
+ # other-writable bit of parent directory when it shouldn't.
+ # FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
+ ls_ld_tmpdir=`ls -ld "$tmpdir"`
+ case $ls_ld_tmpdir in
+ d????-?r-*) different_mode=700;;
+ d????-?--*) different_mode=755;;
+ *) false;;
+ esac &&
+ $mkdirprog -m$different_mode -p -- "$tmpdir" && {
+ ls_ld_tmpdir_1=`ls -ld "$tmpdir"`
+ test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
+ }
+ }
+ then posix_mkdir=:
+ fi
+ rmdir "$tmpdir/d" "$tmpdir"
+ else
+ # Remove any dirs left behind by ancient mkdir implementations.
+ rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null
+ fi
+ trap '' 0;;
+ esac;;
+ esac
+ if
+ $posix_mkdir && (
+ umask $mkdir_umask &&
+ $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
+ )
+ then :
+ else
+
+ # The umask is ridiculous, or mkdir does not conform to POSIX,
+ # or it failed possibly due to a race condition. Create the
+ # directory the slow way, step by step, checking for races as we go.
+
+ case $dstdir in
+ /*) prefix='/';;
+ [-=\(\)!]*) prefix='./';;
+ *) prefix='';;
+ esac
+
+ eval "$initialize_posix_glob"
+
+ oIFS=$IFS
+ IFS=/
+ $posix_glob set -f
+ set fnord $dstdir
+ shift
+ $posix_glob set +f
+ IFS=$oIFS
+
+ prefixes=
+
+ for d
+ do
+ test X"$d" = X && continue
+
+ prefix=$prefix$d
+ if test -d "$prefix"; then
+ prefixes=
+ else
+ if $posix_mkdir; then
+ (umask=$mkdir_umask &&
+ $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
+ # Don't fail if two instances are running concurrently.
+ test -d "$prefix" || exit 1
+ else
+ case $prefix in
+ *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
+ *) qprefix=$prefix;;
+ esac
+ prefixes="$prefixes '$qprefix'"
+ fi
+ fi
+ prefix=$prefix/
+ done
+
+ if test -n "$prefixes"; then
+ # Don't fail if two instances are running concurrently.
+ (umask $mkdir_umask &&
+ eval "\$doit_exec \$mkdirprog $prefixes") ||
+ test -d "$dstdir" || exit 1
+ obsolete_mkdir_used=true
+ fi
+ fi
+ fi
+
+ if test -n "$dir_arg"; then
+ { test -z "$chowncmd" || $doit $chowncmd "$dst"; } &&
+ { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } &&
+ { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false ||
+ test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1
+ else
+
+ # Make a couple of temp file names in the proper directory.
+ dsttmp=$dstdir/_inst.$$_
+ rmtmp=$dstdir/_rm.$$_
+
+ # Trap to clean up those temp files at exit.
+ trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
+
+ # Copy the file name to the temp name.
+ (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") &&
+
+ # and set any options; do chmod last to preserve setuid bits.
+ #
+ # If any of these fail, we abort the whole thing. If we want to
+ # ignore errors from any of these, just make sure not to ignore
+ # errors from the above "$doit $cpprog $src $dsttmp" command.
+ #
+ { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } &&
+ { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } &&
+ { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } &&
+ { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } &&
+
+ # If -C, don't bother to copy if it wouldn't change the file.
+ if $copy_on_change &&
+ old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` &&
+ new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` &&
+
+ eval "$initialize_posix_glob" &&
+ $posix_glob set -f &&
+ set X $old && old=:$2:$4:$5:$6 &&
+ set X $new && new=:$2:$4:$5:$6 &&
+ $posix_glob set +f &&
+
+ test "$old" = "$new" &&
+ $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1
+ then
+ rm -f "$dsttmp"
+ else
+ # Rename the file to the real destination.
+ $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null ||
+
+ # The rename failed, perhaps because mv can't rename something else
+ # to itself, or perhaps because mv is so ancient that it does not
+ # support -f.
+ {
+ # Now remove or move aside any old file at destination location.
+ # We try this two ways since rm can't unlink itself on some
+ # systems and the destination file might be busy for other
+ # reasons. In this case, the final cleanup might fail but the new
+ # file should still install successfully.
+ {
+ test ! -f "$dst" ||
+ $doit $rmcmd -f "$dst" 2>/dev/null ||
+ { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
+ { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }
+ } ||
+ { echo "$0: cannot unlink or rename $dst" >&2
+ (exit 1); exit 1
+ }
+ } &&
+
+ # Now rename the file to the real destination.
+ $doit $mvcmd "$dsttmp" "$dst"
+ }
+ fi || exit 1
+
+ trap '' 0
+ fi
+done
-exit 0
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-time-zone: "UTC"
+# time-stamp-end: "; # UTC"
+# End:
diff --git a/m4/ax_check_user_namespace.m4 b/m4/ax_check_user_namespace.m4
new file mode 100644
index 0000000..27ba698
--- /dev/null
+++ b/m4/ax_check_user_namespace.m4
@@ -0,0 +1,54 @@
+# -*- Autoconf -*-
+
+# SYNOPSIS
+#
+# AX_CHECK_USER_NAMESPACE
+#
+# DESCRIPTION
+#
+# This macro checks whether the local system supports Linux user namespaces.
+# If so, it calls AC_DEFINE(HAVE_USER_NAMESPACE).
+
+AC_DEFUN([AX_CHECK_USER_NAMESPACE],[dnl
+ AC_CACHE_CHECK([whether user namespaces are supported],
+ ax_cv_user_namespace,[
+ AC_LANG_PUSH([C])
+ AC_RUN_IFELSE([AC_LANG_SOURCE([[
+#define _GNU_SOURCE
+#include <fcntl.h>
+#include <sched.h>
+#include <signal.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+
+int userfn(void *d) {
+ usleep(100000); /* synchronize by sleep */
+ return (getuid() != 0);
+}
+char userst[1024*1024];
+int main() {
+ char buffer[1024];
+ int rc, status, fd;
+ pid_t child = clone(userfn, userst + 1024*1024, CLONE_NEWUSER|SIGCHLD, 0);
+ if (child < 0) return 1;
+
+ sprintf(buffer, "/proc/%d/uid_map", child);
+ fd = open(buffer, O_CREAT|O_WRONLY|O_TRUNC, 0755);
+ sprintf(buffer, "0 %d 1\n", getuid());
+ write(fd, buffer, strlen(buffer));
+ close(fd);
+
+ rc = waitpid(child, &status, 0);
+ if (rc <= 0) return 1;
+ if (!WIFEXITED(status)) return 1;
+ return WEXITSTATUS(status);
+}
+ ]])],[ax_cv_user_namespace=yes],[ax_cv_user_namespace=no],[ax_cv_user_namespace=no])
+ AC_LANG_POP([C])
+ ])
+ if test "$ax_cv_user_namespace" = yes; then
+ AC_DEFINE([HAVE_USER_NAMESPACE],[1],[Whether user namespaces are available])
+ fi
+]) # AX_CHECK_USER_NAMESPACE
diff --git a/m4/ax_check_uts_namespace.m4 b/m4/ax_check_uts_namespace.m4
new file mode 100644
index 0000000..cf7b145
--- /dev/null
+++ b/m4/ax_check_uts_namespace.m4
@@ -0,0 +1,76 @@
+# -*- Autoconf -*-
+
+# SYNOPSIS
+#
+# AX_CHECK_UTS_NAMESPACE
+#
+# DESCRIPTION
+#
+# This macro checks whether the local system supports Linux UTS namespaces.
+# Also requires user namespaces to be available, so that non-root users
+# can enter the namespace.
+# If so, it calls AC_DEFINE(HAVE_UTS_NAMESPACE).
+
+AC_DEFUN([AX_CHECK_UTS_NAMESPACE],[dnl
+ AC_CACHE_CHECK([whether UTS namespaces are supported],
+ ax_cv_uts_namespace,[
+ AC_LANG_PUSH([C])
+ AC_RUN_IFELSE([AC_LANG_SOURCE([[
+#define _GNU_SOURCE
+#include <sched.h>
+#include <signal.h>
+#include <stdio.h>
+#include <string.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+
+int utsfn(void *d) {
+ char buffer[1024];
+ const char *name = "autoconftest";
+ int rc = sethostname(name, strlen(name));
+ if (rc != 0) return 1;
+ gethostname(buffer, 1024);
+ return (strcmp(buffer, name) != 0);
+}
+
+char st2[1024*1024];
+int fn(void *d) {
+ pid_t child;
+ int rc, status;
+ usleep(100000); /* synchronize by sleep */
+ if (getuid() != 0) return 1;
+ child = clone(utsfn, st2 + 1024*1024, CLONE_NEWUTS|SIGCHLD, 0);
+ if (child < 0) return 1;
+ rc = waitpid(child, &status, 0);
+ if (rc <= 0) return 1;
+ if (!WIFEXITED(status)) return 1;
+ return WEXITSTATUS(status);
+}
+char st[1024*1024];
+int main() {
+ char buffer[1024];
+ int rc, status, fd;
+ pid_t child = clone(fn, st + 1024*1024, CLONE_NEWUSER|SIGCHLD, 0);
+ if (child < 0) return 1;
+
+ sprintf(buffer, "/proc/%d/uid_map", child);
+ fd = open(buffer, O_CREAT|O_WRONLY|O_TRUNC, 0755);
+ sprintf(buffer, "0 %d 1\n", getuid());
+ write(fd, buffer, strlen(buffer));
+ close(fd);
+
+ rc = waitpid(child, &status, 0);
+ if (rc <= 0) return 1;
+ if (!WIFEXITED(status)) return 1;
+ return WEXITSTATUS(status);
+}
+]])
+ ],[ax_cv_uts_namespace=yes],[ax_cv_uts_namespace=no],[ax_cv_uts_namespace=no])
+ AC_LANG_POP([C])
+ ])
+ if test "$ax_cv_uts_namespace" = yes; then
+ AC_DEFINE([HAVE_UTS_NAMESPACE],[1],[Whether UTS namespaces are available])
+ fi
+]) # AX_CHECK_UTS_NAMESPACE
diff --git a/m4/ax_code_coverage.m4 b/m4/ax_code_coverage.m4
new file mode 100644
index 0000000..5120c3b
--- /dev/null
+++ b/m4/ax_code_coverage.m4
@@ -0,0 +1,219 @@
+# ===========================================================================
+# http://www.gnu.org/software/autoconf-archive/ax_code_coverage.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+# AX_CODE_COVERAGE()
+#
+# DESCRIPTION
+#
+# Defines CODE_COVERAGE_CFLAGS and CODE_COVERAGE_LDFLAGS which should be
+# included in the CFLAGS and LIBS/LDFLAGS variables of every build target
+# (program or library) which should be built with code coverage support.
+# Also defines CODE_COVERAGE_RULES which should be substituted in your
+# Makefile; and $enable_code_coverage which can be used in subsequent
+# configure output. CODE_COVERAGE_ENABLED is defined and substituted, and
+# corresponds to the value of the --enable-code-coverage option, which
+# defaults to being disabled.
+#
+# Test also for gcov program and create GCOV variable that could be
+# substituted.
+#
+# Note that all optimisation flags in CFLAGS must be disabled when code
+# coverage is enabled.
+#
+# Usage example:
+#
+# configure.ac:
+#
+# AX_CODE_COVERAGE
+#
+# Makefile.am:
+#
+# @CODE_COVERAGE_RULES@
+# my_program_LIBS = ... $(CODE_COVERAGE_LDFLAGS) ...
+# my_program_CFLAGS = ... $(CODE_COVERAGE_CFLAGS) ...
+#
+# This results in a "check-code-coverage" rule being added to any
+# Makefile.am which includes "@CODE_COVERAGE_RULES@" (assuming the module
+# has been configured with --enable-code-coverage). Running `make
+# check-code-coverage` in that directory will run the module's test suite
+# (`make check`) and build a code coverage report detailing the code which
+# was touched, then print the URI for the report.
+#
+# This code was derived from Makefile.decl in GLib, originally licenced
+# under LGPLv2.1+.
+#
+# LICENSE
+#
+# Copyright (c) 2012 Philip Withnall
+# Copyright (c) 2012 Xan Lopez
+# Copyright (c) 2012 Christian Persch
+# Copyright (c) 2012 Paolo Borelli
+# Copyright (c) 2012 Dan Winship
+# Copyright (c) 2015 Bastien ROUCARIES
+#
+# This library is free software; you can redistribute it and/or modify it
+# under the terms of the GNU Lesser General Public License as published by
+# the Free Software Foundation; either version 2.1 of the License, or (at
+# your option) any later version.
+#
+# This library is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
+# General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+#serial 5
+
+AC_DEFUN([AX_CODE_COVERAGE],[
+ dnl Check for --enable-code-coverage
+ AC_REQUIRE([AC_PROG_SED])
+
+ # allow to override gcov location
+ AC_ARG_WITH([gcov],
+ [AS_HELP_STRING([--with-gcov[=GCOV]], [use given GCOV for coverage (GCOV=gcov).])],
+ [_AX_CODE_COVERAGE_GCOV_PROG_WITH=$with_gcov],
+ [_AX_CODE_COVERAGE_GCOV_PROG_WITH=gcov])
+
+ AC_MSG_CHECKING([whether to build with code coverage support])
+ AC_ARG_ENABLE([code-coverage],
+ AS_HELP_STRING([--enable-code-coverage],
+ [Whether to enable code coverage support]),,
+ enable_code_coverage=no)
+
+ AM_CONDITIONAL([CODE_COVERAGE_ENABLED], [test x$enable_code_coverage = xyes])
+ AC_SUBST([CODE_COVERAGE_ENABLED], [$enable_code_coverage])
+ AC_MSG_RESULT($enable_code_coverage)
+
+ AS_IF([ test "$enable_code_coverage" = "yes" ], [
+ # check for gcov
+ AC_CHECK_TOOL([GCOV],
+ [$_AX_CODE_COVERAGE_GCOV_PROG_WITH],
+ [:])
+ AS_IF([test "X$GCOV" = "X:"],
+ [AC_MSG_ERROR([gcov is needed to do coverage])])
+ AC_SUBST([GCOV])
+
+ dnl Check if gcc is being used
+ AS_IF([ test "$GCC" = "no" ], [
+ AC_MSG_ERROR([not compiling with gcc, which is required for gcov code coverage])
+ ])
+
+ # List of supported lcov versions.
+ lcov_version_list="1.6 1.7 1.8 1.9 1.10 1.11"
+
+ AC_CHECK_PROG([LCOV], [lcov], [lcov])
+ AC_CHECK_PROG([GENHTML], [genhtml], [genhtml])
+
+ AS_IF([ test "$LCOV" ], [
+ AC_CACHE_CHECK([for lcov version], ax_cv_lcov_version, [
+ ax_cv_lcov_version=invalid
+ lcov_version=`$LCOV -v 2>/dev/null | $SED -e 's/^.* //'`
+ for lcov_check_version in $lcov_version_list; do
+ if test "$lcov_version" = "$lcov_check_version"; then
+ ax_cv_lcov_version="$lcov_check_version (ok)"
+ fi
+ done
+ ])
+ ], [
+ lcov_msg="To enable code coverage reporting you must have one of the following lcov versions installed: $lcov_version_list"
+ AC_MSG_ERROR([$lcov_msg])
+ ])
+
+ case $ax_cv_lcov_version in
+ ""|invalid[)]
+ lcov_msg="You must have one of the following versions of lcov: $lcov_version_list (found: $lcov_version)."
+ AC_MSG_ERROR([$lcov_msg])
+ LCOV="exit 0;"
+ ;;
+ esac
+
+ AS_IF([ test -z "$GENHTML" ], [
+ AC_MSG_ERROR([Could not find genhtml from the lcov package])
+ ])
+
+ dnl Build the code coverage flags
+ CODE_COVERAGE_CFLAGS="-O0 -g -fprofile-arcs -ftest-coverage"
+ CODE_COVERAGE_LDFLAGS="-lgcov"
+
+ AC_SUBST([CODE_COVERAGE_CFLAGS])
+ AC_SUBST([CODE_COVERAGE_LDFLAGS])
+
+CODE_COVERAGE_RULES='
+# Code coverage
+#
+# Optional:
+# - CODE_COVERAGE_DIRECTORY: Top-level directory for code coverage reporting.
+# (Default: $(top_builddir))
+# - CODE_COVERAGE_OUTPUT_FILE: Filename and path for the .info file generated
+# by lcov for code coverage. (Default:
+# $(PACKAGE_NAME)-$(PACKAGE_VERSION)-coverage.info)
+# - CODE_COVERAGE_OUTPUT_DIRECTORY: Directory for generated code coverage
+# reports to be created. (Default:
+# $(PACKAGE_NAME)-$(PACKAGE_VERSION)-coverage)
+# - CODE_COVERAGE_LCOV_OPTIONS_GCOVPATH: --gcov-tool pathtogcov
+# - CODE_COVERAGE_LCOV_OPTIONS_DEFAULT: Extra options to pass to the lcov instance.
+# (Default: $CODE_COVERAGE_LCOV_OPTIONS_GCOVPATH)
+# - CODE_COVERAGE_LCOV_OPTIONS: Extra options to pass to the lcov instance.
+# (Default: $CODE_COVERAGE_LCOV_OPTIONS_DEFAULT)
+# - CODE_COVERAGE_GENHTML_OPTIONS: Extra options to pass to the genhtml
+# instance. (Default: empty)
+# - CODE_COVERAGE_IGNORE_PATTERN: Extra glob pattern of files to ignore
+#
+# The generated report will be titled using the $(PACKAGE_NAME) and
+# $(PACKAGE_VERSION). In order to add the current git hash to the title,
+# use the git-version-gen script, available online.
+
+# Optional variables
+CODE_COVERAGE_DIRECTORY ?= $(top_builddir)
+CODE_COVERAGE_OUTPUT_FILE ?= $(PACKAGE_NAME)-$(PACKAGE_VERSION)-coverage.info
+CODE_COVERAGE_OUTPUT_DIRECTORY ?= $(PACKAGE_NAME)-$(PACKAGE_VERSION)-coverage
+CODE_COVERAGE_LCOV_OPTIONS_GCOVPATH ?= --gcov-tool "$(GCOV)"
+CODE_COVERAGE_LCOV_OPTIONS_DEFAULT ?= $(CODE_COVERAGE_LCOV_OPTIONS_GCOVPATH)
+CODE_COVERAGE_LCOV_OPTIONS ?= $(CODE_COVERAGE_LCOV_OPTIONS_DEFAULT)
+CODE_COVERAGE_GENHTML_OPTIONS ?=
+CODE_COVERAGE_IGNORE_PATTERN ?=
+
+code_coverage_quiet = $(code_coverage_quiet_$(V))
+code_coverage_quiet_ =
+code_coverage_quiet_0 = --quiet
+
+# Use recursive makes in order to ignore errors during check
+check-code-coverage:
+ -$(MAKE) $(AM_MAKEFLAGS) -k check
+ $(MAKE) $(AM_MAKEFLAGS) code-coverage-capture
+
+# Capture code coverage data
+code-coverage-capture: code-coverage-capture-hook
+ $(LCOV) $(code_coverage_quiet) --directory $(CODE_COVERAGE_DIRECTORY) --capture --output-file "$(CODE_COVERAGE_OUTPUT_FILE).tmp" --test-name "$(PACKAGE_NAME)-$(PACKAGE_VERSION)" --no-checksum --compat-libtool $(CODE_COVERAGE_LCOV_OPTIONS)
+ $(LCOV) $(code_coverage_quiet) --directory $(CODE_COVERAGE_DIRECTORY) --remove "$(CODE_COVERAGE_OUTPUT_FILE).tmp" "/tmp/*" $(CODE_COVERAGE_IGNORE_PATTERN) --output-file "$(CODE_COVERAGE_OUTPUT_FILE)"
+ -@rm -f $(CODE_COVERAGE_OUTPUT_FILE).tmp
+ LANG=C $(GENHTML) $(code_coverage_quiet) --prefix $(CODE_COVERAGE_DIRECTORY) --output-directory "$(CODE_COVERAGE_OUTPUT_DIRECTORY)" --title "$(PACKAGE_NAME)-$(PACKAGE_VERSION) Code Coverage" --legend --show-details "$(CODE_COVERAGE_OUTPUT_FILE)" $(CODE_COVERAGE_GENHTML_OPTIONS)
+ @echo "file://$(abs_builddir)/$(CODE_COVERAGE_OUTPUT_DIRECTORY)/index.html"
+
+# Hook rule executed before code-coverage-capture, overridable by the user
+code-coverage-capture-hook:
+
+clean: code-coverage-clean
+code-coverage-clean:
+ -$(LCOV) --directory $(top_builddir) -z
+ -rm -rf $(CODE_COVERAGE_OUTPUT_FILE) $(CODE_COVERAGE_OUTPUT_FILE).tmp $(CODE_COVERAGE_OUTPUT_DIRECTORY)
+ -find . -name "*.gcda" -o -name "*.gcov" -delete
+
+GITIGNOREFILES ?=
+GITIGNOREFILES += $(CODE_COVERAGE_OUTPUT_FILE) $(CODE_COVERAGE_OUTPUT_DIRECTORY)
+
+DISTCHECK_CONFIGURE_FLAGS ?=
+DISTCHECK_CONFIGURE_FLAGS += --disable-code-coverage
+
+.PHONY: check-code-coverage code-coverage-capture code-coverage-capture-hook code-coverage-clean
+'
+ AC_SUBST([CODE_COVERAGE_RULES])
+ ])
+
+ m4_ifdef([_AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE([CODE_COVERAGE_RULES])])
+])
diff --git a/m4/ax_cxx_compile_stdcxx_11.m4 b/m4/ax_cxx_compile_stdcxx_11.m4
new file mode 100644
index 0000000..229de30
--- /dev/null
+++ b/m4/ax_cxx_compile_stdcxx_11.m4
@@ -0,0 +1,163 @@
+# ============================================================================
+# http://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx_11.html
+# ============================================================================
+#
+# SYNOPSIS
+#
+# AX_CXX_COMPILE_STDCXX_11([ext|noext],[mandatory|optional])
+#
+# DESCRIPTION
+#
+# Check for baseline language coverage in the compiler for the C++11
+# standard; if necessary, add switches to CXXFLAGS to enable support.
+#
+# The first argument, if specified, indicates whether you insist on an
+# extended mode (e.g. -std=gnu++11) or a strict conformance mode (e.g.
+# -std=c++11). If neither is specified, you get whatever works, with
+# preference for an extended mode.
+#
+# The second argument, if specified 'mandatory' or if left unspecified,
+# indicates that baseline C++11 support is required and that the macro
+# should error out if no mode with that support is found. If specified
+# 'optional', then configuration proceeds regardless, after defining
+# HAVE_CXX11 if and only if a supporting mode is found.
+#
+# LICENSE
+#
+# Copyright (c) 2008 Benjamin Kosnik <bkoz@redhat.com>
+# Copyright (c) 2012 Zack Weinberg <zackw@panix.com>
+# Copyright (c) 2013 Roy Stogner <roystgnr@ices.utexas.edu>
+# Copyright (c) 2014, 2015 Google Inc.; contributed by Alexey Sokolov <sokolov@google.com>
+#
+# Copying and distribution of this file, with or without modification, are
+# permitted in any medium without royalty provided the copyright notice
+# and this notice are preserved. This file is offered as-is, without any
+# warranty.
+
+#serial 9
+
+m4_define([_AX_CXX_COMPILE_STDCXX_11_testbody], [[
+ template <typename T>
+ struct check
+ {
+ static_assert(sizeof(int) <= sizeof(T), "not big enough");
+ };
+
+ struct Base {
+ virtual void f() {}
+ };
+ struct Child : public Base {
+ virtual void f() override {}
+ };
+
+ typedef check<check<bool>> right_angle_brackets;
+
+ int a;
+ decltype(a) b;
+
+ typedef check<int> check_type;
+ check_type c;
+ check_type&& cr = static_cast<check_type&&>(c);
+
+ auto d = a;
+ auto l = [](){};
+
+ // http://stackoverflow.com/questions/13728184/template-aliases-and-sfinae
+ // Clang 3.1 fails with headers of libstd++ 4.8.3 when using std::function because of this
+ namespace test_template_alias_sfinae {
+ struct foo {};
+
+ template<typename T>
+ using member = typename T::member_type;
+
+ template<typename T>
+ void func(...) {}
+
+ template<typename T>
+ void func(member<T>*) {}
+
+ void test();
+
+ void test() {
+ func<foo>(0);
+ }
+ }
+]])
+
+AC_DEFUN([AX_CXX_COMPILE_STDCXX_11], [dnl
+ m4_if([$1], [], [],
+ [$1], [ext], [],
+ [$1], [noext], [],
+ [m4_fatal([invalid argument `$1' to AX_CXX_COMPILE_STDCXX_11])])dnl
+ m4_if([$2], [], [ax_cxx_compile_cxx11_required=true],
+ [$2], [mandatory], [ax_cxx_compile_cxx11_required=true],
+ [$2], [optional], [ax_cxx_compile_cxx11_required=false],
+ [m4_fatal([invalid second argument `$2' to AX_CXX_COMPILE_STDCXX_11])])
+ AC_LANG_PUSH([C++])dnl
+ ac_success=no
+ AC_CACHE_CHECK(whether $CXX supports C++11 features by default,
+ ax_cv_cxx_compile_cxx11,
+ [AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_11_testbody])],
+ [ax_cv_cxx_compile_cxx11=yes],
+ [ax_cv_cxx_compile_cxx11=no])])
+ if test x$ax_cv_cxx_compile_cxx11 = xyes; then
+ ac_success=yes
+ fi
+
+ m4_if([$1], [noext], [], [dnl
+ if test x$ac_success = xno; then
+ for switch in -std=gnu++11 -std=gnu++0x; do
+ cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx11_$switch])
+ AC_CACHE_CHECK(whether $CXX supports C++11 features with $switch,
+ $cachevar,
+ [ac_save_CXXFLAGS="$CXXFLAGS"
+ CXXFLAGS="$CXXFLAGS $switch"
+ AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_11_testbody])],
+ [eval $cachevar=yes],
+ [eval $cachevar=no])
+ CXXFLAGS="$ac_save_CXXFLAGS"])
+ if eval test x\$$cachevar = xyes; then
+ CXXFLAGS="$CXXFLAGS $switch"
+ ac_success=yes
+ break
+ fi
+ done
+ fi])
+
+ m4_if([$1], [ext], [], [dnl
+ if test x$ac_success = xno; then
+ for switch in -std=c++11 -std=c++0x; do
+ cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx11_$switch])
+ AC_CACHE_CHECK(whether $CXX supports C++11 features with $switch,
+ $cachevar,
+ [ac_save_CXXFLAGS="$CXXFLAGS"
+ CXXFLAGS="$CXXFLAGS $switch"
+ AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_11_testbody])],
+ [eval $cachevar=yes],
+ [eval $cachevar=no])
+ CXXFLAGS="$ac_save_CXXFLAGS"])
+ if eval test x\$$cachevar = xyes; then
+ CXXFLAGS="$CXXFLAGS $switch"
+ ac_success=yes
+ break
+ fi
+ done
+ fi])
+ AC_LANG_POP([C++])
+ if test x$ax_cxx_compile_cxx11_required = xtrue; then
+ if test x$ac_success = xno; then
+ AC_MSG_ERROR([*** A compiler with support for C++11 language features is required.])
+ fi
+ else
+ if test x$ac_success = xno; then
+ HAVE_CXX11=0
+ AC_MSG_NOTICE([No compiler with C++11 support was found])
+ else
+ HAVE_CXX11=1
+ AC_DEFINE(HAVE_CXX11,1,
+ [define if the compiler supports basic C++11 syntax])
+ fi
+
+ AC_SUBST(HAVE_CXX11)
+ fi
+])
diff --git a/m4/ax_pthread.m4 b/m4/ax_pthread.m4
new file mode 100644
index 0000000..d383ad5
--- /dev/null
+++ b/m4/ax_pthread.m4
@@ -0,0 +1,332 @@
+# ===========================================================================
+# http://www.gnu.org/software/autoconf-archive/ax_pthread.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+# AX_PTHREAD([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
+#
+# DESCRIPTION
+#
+# This macro figures out how to build C programs using POSIX threads. It
+# sets the PTHREAD_LIBS output variable to the threads library and linker
+# flags, and the PTHREAD_CFLAGS output variable to any special C compiler
+# flags that are needed. (The user can also force certain compiler
+# flags/libs to be tested by setting these environment variables.)
+#
+# Also sets PTHREAD_CC to any special C compiler that is needed for
+# multi-threaded programs (defaults to the value of CC otherwise). (This
+# is necessary on AIX to use the special cc_r compiler alias.)
+#
+# NOTE: You are assumed to not only compile your program with these flags,
+# but also link it with them as well. e.g. you should link with
+# $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS $LIBS
+#
+# If you are only building threads programs, you may wish to use these
+# variables in your default LIBS, CFLAGS, and CC:
+#
+# LIBS="$PTHREAD_LIBS $LIBS"
+# CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
+# CC="$PTHREAD_CC"
+#
+# In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute constant
+# has a nonstandard name, defines PTHREAD_CREATE_JOINABLE to that name
+# (e.g. PTHREAD_CREATE_UNDETACHED on AIX).
+#
+# Also HAVE_PTHREAD_PRIO_INHERIT is defined if pthread is found and the
+# PTHREAD_PRIO_INHERIT symbol is defined when compiling with
+# PTHREAD_CFLAGS.
+#
+# ACTION-IF-FOUND is a list of shell commands to run if a threads library
+# is found, and ACTION-IF-NOT-FOUND is a list of commands to run it if it
+# is not found. If ACTION-IF-FOUND is not specified, the default action
+# will define HAVE_PTHREAD.
+#
+# Please let the authors know if this macro fails on any platform, or if
+# you have any other suggestions or comments. This macro was based on work
+# by SGJ on autoconf scripts for FFTW (http://www.fftw.org/) (with help
+# from M. Frigo), as well as ac_pthread and hb_pthread macros posted by
+# Alejandro Forero Cuervo to the autoconf macro repository. We are also
+# grateful for the helpful feedback of numerous users.
+#
+# Updated for Autoconf 2.68 by Daniel Richard G.
+#
+# LICENSE
+#
+# Copyright (c) 2008 Steven G. Johnson <stevenj@alum.mit.edu>
+# Copyright (c) 2011 Daniel Richard G. <skunk@iSKUNK.ORG>
+#
+# This program is free software: you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation, either version 3 of the License, or (at your
+# option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+# Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# As a special exception, the respective Autoconf Macro's copyright owner
+# gives unlimited permission to copy, distribute and modify the configure
+# scripts that are the output of Autoconf when processing the Macro. You
+# need not follow the terms of the GNU General Public License when using
+# or distributing such scripts, even though portions of the text of the
+# Macro appear in them. The GNU General Public License (GPL) does govern
+# all other use of the material that constitutes the Autoconf Macro.
+#
+# This special exception to the GPL applies to versions of the Autoconf
+# Macro released by the Autoconf Archive. When you make and distribute a
+# modified version of the Autoconf Macro, you may extend this special
+# exception to the GPL to apply to your modified version as well.
+
+#serial 21
+
+AU_ALIAS([ACX_PTHREAD], [AX_PTHREAD])
+AC_DEFUN([AX_PTHREAD], [
+AC_REQUIRE([AC_CANONICAL_HOST])
+AC_LANG_PUSH([C])
+ax_pthread_ok=no
+
+# We used to check for pthread.h first, but this fails if pthread.h
+# requires special compiler flags (e.g. on True64 or Sequent).
+# It gets checked for in the link test anyway.
+
+# First of all, check if the user has set any of the PTHREAD_LIBS,
+# etcetera environment variables, and if threads linking works using
+# them:
+if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then
+ save_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
+ save_LIBS="$LIBS"
+ LIBS="$PTHREAD_LIBS $LIBS"
+ AC_MSG_CHECKING([for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS])
+ AC_TRY_LINK_FUNC([pthread_join], [ax_pthread_ok=yes])
+ AC_MSG_RESULT([$ax_pthread_ok])
+ if test x"$ax_pthread_ok" = xno; then
+ PTHREAD_LIBS=""
+ PTHREAD_CFLAGS=""
+ fi
+ LIBS="$save_LIBS"
+ CFLAGS="$save_CFLAGS"
+fi
+
+# We must check for the threads library under a number of different
+# names; the ordering is very important because some systems
+# (e.g. DEC) have both -lpthread and -lpthreads, where one of the
+# libraries is broken (non-POSIX).
+
+# Create a list of thread flags to try. Items starting with a "-" are
+# C compiler flags, and other items are library names, except for "none"
+# which indicates that we try without any flags at all, and "pthread-config"
+# which is a program returning the flags for the Pth emulation library.
+
+ax_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config"
+
+# The ordering *is* (sometimes) important. Some notes on the
+# individual items follow:
+
+# pthreads: AIX (must check this before -lpthread)
+# none: in case threads are in libc; should be tried before -Kthread and
+# other compiler flags to prevent continual compiler warnings
+# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)
+# -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)
+# lthread: LinuxThreads port on FreeBSD (also preferred to -pthread)
+# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads)
+# -pthreads: Solaris/gcc
+# -mthreads: Mingw32/gcc, Lynx/gcc
+# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it
+# doesn't hurt to check since this sometimes defines pthreads too;
+# also defines -D_REENTRANT)
+# ... -mt is also the pthreads flag for HP/aCC
+# pthread: Linux, etcetera
+# --thread-safe: KAI C++
+# pthread-config: use pthread-config program (for GNU Pth library)
+
+case ${host_os} in
+ solaris*)
+
+ # On Solaris (at least, for some versions), libc contains stubbed
+ # (non-functional) versions of the pthreads routines, so link-based
+ # tests will erroneously succeed. (We need to link with -pthreads/-mt/
+ # -lpthread.) (The stubs are missing pthread_cleanup_push, or rather
+ # a function called by this macro, so we could check for that, but
+ # who knows whether they'll stub that too in a future libc.) So,
+ # we'll just look for -pthreads and -lpthread first:
+
+ ax_pthread_flags="-pthreads pthread -mt -pthread $ax_pthread_flags"
+ ;;
+
+ darwin*)
+ ax_pthread_flags="-pthread $ax_pthread_flags"
+ ;;
+esac
+
+# Clang doesn't consider unrecognized options an error unless we specify
+# -Werror. We throw in some extra Clang-specific options to ensure that
+# this doesn't happen for GCC, which also accepts -Werror.
+
+AC_MSG_CHECKING([if compiler needs -Werror to reject unknown flags])
+save_CFLAGS="$CFLAGS"
+ax_pthread_extra_flags="-Werror"
+CFLAGS="$CFLAGS $ax_pthread_extra_flags -Wunknown-warning-option -Wsizeof-array-argument"
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([int foo(void);],[foo()])],
+ [AC_MSG_RESULT([yes])],
+ [ax_pthread_extra_flags=
+ AC_MSG_RESULT([no])])
+CFLAGS="$save_CFLAGS"
+
+if test x"$ax_pthread_ok" = xno; then
+for flag in $ax_pthread_flags; do
+
+ case $flag in
+ none)
+ AC_MSG_CHECKING([whether pthreads work without any flags])
+ ;;
+
+ -*)
+ AC_MSG_CHECKING([whether pthreads work with $flag])
+ PTHREAD_CFLAGS="$flag"
+ ;;
+
+ pthread-config)
+ AC_CHECK_PROG([ax_pthread_config], [pthread-config], [yes], [no])
+ if test x"$ax_pthread_config" = xno; then continue; fi
+ PTHREAD_CFLAGS="`pthread-config --cflags`"
+ PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`"
+ ;;
+
+ *)
+ AC_MSG_CHECKING([for the pthreads library -l$flag])
+ PTHREAD_LIBS="-l$flag"
+ ;;
+ esac
+
+ save_LIBS="$LIBS"
+ save_CFLAGS="$CFLAGS"
+ LIBS="$PTHREAD_LIBS $LIBS"
+ CFLAGS="$CFLAGS $PTHREAD_CFLAGS $ax_pthread_extra_flags"
+
+ # Check for various functions. We must include pthread.h,
+ # since some functions may be macros. (On the Sequent, we
+ # need a special flag -Kthread to make this header compile.)
+ # We check for pthread_join because it is in -lpthread on IRIX
+ # while pthread_create is in libc. We check for pthread_attr_init
+ # due to DEC craziness with -lpthreads. We check for
+ # pthread_cleanup_push because it is one of the few pthread
+ # functions on Solaris that doesn't have a non-functional libc stub.
+ # We try pthread_create on general principles.
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <pthread.h>
+ static void routine(void *a) { a = 0; }
+ static void *start_routine(void *a) { return a; }],
+ [pthread_t th; pthread_attr_t attr;
+ pthread_create(&th, 0, start_routine, 0);
+ pthread_join(th, 0);
+ pthread_attr_init(&attr);
+ pthread_cleanup_push(routine, 0);
+ pthread_cleanup_pop(0) /* ; */])],
+ [ax_pthread_ok=yes],
+ [])
+
+ LIBS="$save_LIBS"
+ CFLAGS="$save_CFLAGS"
+
+ AC_MSG_RESULT([$ax_pthread_ok])
+ if test "x$ax_pthread_ok" = xyes; then
+ break;
+ fi
+
+ PTHREAD_LIBS=""
+ PTHREAD_CFLAGS=""
+done
+fi
+
+# Various other checks:
+if test "x$ax_pthread_ok" = xyes; then
+ save_LIBS="$LIBS"
+ LIBS="$PTHREAD_LIBS $LIBS"
+ save_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
+
+ # Detect AIX lossage: JOINABLE attribute is called UNDETACHED.
+ AC_MSG_CHECKING([for joinable pthread attribute])
+ attr_name=unknown
+ for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <pthread.h>],
+ [int attr = $attr; return attr /* ; */])],
+ [attr_name=$attr; break],
+ [])
+ done
+ AC_MSG_RESULT([$attr_name])
+ if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then
+ AC_DEFINE_UNQUOTED([PTHREAD_CREATE_JOINABLE], [$attr_name],
+ [Define to necessary symbol if this constant
+ uses a non-standard name on your system.])
+ fi
+
+ AC_MSG_CHECKING([if more special flags are required for pthreads])
+ flag=no
+ case ${host_os} in
+ aix* | freebsd* | darwin*) flag="-D_THREAD_SAFE";;
+ osf* | hpux*) flag="-D_REENTRANT";;
+ solaris*)
+ if test "$GCC" = "yes"; then
+ flag="-D_REENTRANT"
+ else
+ # TODO: What about Clang on Solaris?
+ flag="-mt -D_REENTRANT"
+ fi
+ ;;
+ esac
+ AC_MSG_RESULT([$flag])
+ if test "x$flag" != xno; then
+ PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS"
+ fi
+
+ AC_CACHE_CHECK([for PTHREAD_PRIO_INHERIT],
+ [ax_cv_PTHREAD_PRIO_INHERIT], [
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <pthread.h>]],
+ [[int i = PTHREAD_PRIO_INHERIT;]])],
+ [ax_cv_PTHREAD_PRIO_INHERIT=yes],
+ [ax_cv_PTHREAD_PRIO_INHERIT=no])
+ ])
+ AS_IF([test "x$ax_cv_PTHREAD_PRIO_INHERIT" = "xyes"],
+ [AC_DEFINE([HAVE_PTHREAD_PRIO_INHERIT], [1], [Have PTHREAD_PRIO_INHERIT.])])
+
+ LIBS="$save_LIBS"
+ CFLAGS="$save_CFLAGS"
+
+ # More AIX lossage: compile with *_r variant
+ if test "x$GCC" != xyes; then
+ case $host_os in
+ aix*)
+ AS_CASE(["x/$CC"],
+ [x*/c89|x*/c89_128|x*/c99|x*/c99_128|x*/cc|x*/cc128|x*/xlc|x*/xlc_v6|x*/xlc128|x*/xlc128_v6],
+ [#handle absolute path differently from PATH based program lookup
+ AS_CASE(["x$CC"],
+ [x/*],
+ [AS_IF([AS_EXECUTABLE_P([${CC}_r])],[PTHREAD_CC="${CC}_r"])],
+ [AC_CHECK_PROGS([PTHREAD_CC],[${CC}_r],[$CC])])])
+ ;;
+ esac
+ fi
+fi
+
+test -n "$PTHREAD_CC" || PTHREAD_CC="$CC"
+
+AC_SUBST([PTHREAD_LIBS])
+AC_SUBST([PTHREAD_CFLAGS])
+AC_SUBST([PTHREAD_CC])
+
+# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
+if test x"$ax_pthread_ok" = xyes; then
+ ifelse([$1],,[AC_DEFINE([HAVE_PTHREAD],[1],[Define if you have POSIX threads libraries and header files.])],[$1])
+ :
+else
+ ax_pthread_ok=no
+ $2
+fi
+AC_LANG_POP
+])dnl AX_PTHREAD
diff --git a/m4/cares-confopts.m4 b/m4/cares-confopts.m4
index 9d12a9b..135036a 100644
--- a/m4/cares-confopts.m4
+++ b/m4/cares-confopts.m4
@@ -219,6 +219,44 @@ AC_HELP_STRING([--disable-symbol-hiding],[Disable hiding of library internal sym
])
+dnl CARES_CHECK_OPTION_EXPOSE_STATICS
+dnl -------------------------------------------------
+dnl Verify if configure has been invoked with option
+dnl --enable-expose-statics or --disable-expose-statics,
+dnl setting shell variable want_expose_statics value.
+
+AC_DEFUN([CARES_CHECK_OPTION_EXPOSE_STATICS], [
+ AC_MSG_CHECKING([whether to expose internal static functions for testing])
+ OPT_EXPOSE_STATICS="default"
+ AC_ARG_ENABLE(expose-statics,
+AC_HELP_STRING([--enable-expose-statics],[Enable exposure of internal static functions for testing])
+AC_HELP_STRING([--disable-expose-statics],[Disable exposure of internal static functions for testing]),
+ OPT_EXPOSE_STATICS=$enableval)
+ case "$OPT_EXPOSE_STATICS" in
+ no)
+ dnl --disable-expose-statics option used.
+ want_expose_statics="no"
+ AC_MSG_RESULT([no])
+ ;;
+ default)
+ dnl configure's expose-statics option not specified.
+ dnl Handle this as if --disable-expose-statics option was given.
+ want_expose_statics="no"
+ AC_MSG_RESULT([no])
+ ;;
+ *)
+ dnl --enable-expose-statics option used.
+ want_expose_statics="yes"
+ AC_MSG_RESULT([yes])
+ ;;
+ esac
+ if test "$want_expose_statics" = "yes"; then
+ AC_DEFINE_UNQUOTED(CARES_EXPOSE_STATICS, 1,
+ [Defined for build that exposes internal static functions for testing.])
+ fi
+])
+
+
dnl CARES_CHECK_OPTION_WARNINGS
dnl -------------------------------------------------
dnl Verify if configure has been invoked with option
@@ -350,5 +388,9 @@ AC_DEFUN([CARES_CONFIGURE_SYMBOL_HIDING], [
fi
AM_CONDITIONAL(DOING_CARES_SYMBOL_HIDING, test x$doing_symbol_hiding = xyes)
AC_SUBST(CFLAG_CARES_SYMBOL_HIDING)
+ if test "$doing_symbol_hiding" = "yes"; then
+ AC_DEFINE_UNQUOTED(CARES_SYMBOL_HIDING, 1,
+ [Defined for build with symbol hiding.])
+ fi
])
diff --git a/m4/xc-am-iface.m4 b/m4/xc-am-iface.m4
new file mode 100644
index 0000000..1571c21
--- /dev/null
+++ b/m4/xc-am-iface.m4
@@ -0,0 +1,253 @@
+#---------------------------------------------------------------------------
+#
+# xc-am-iface.m4
+#
+# Copyright (c) 2013 Daniel Stenberg <daniel@haxx.se>
+#
+# 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 THE AUTHOR DISCLAIMS ALL WARRANTIES
+# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR 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.
+#
+#---------------------------------------------------------------------------
+
+# serial 1
+
+
+dnl _XC_AUTOMAKE_BODY
+dnl -------------------------------------------------
+dnl Private macro.
+dnl
+dnl This macro performs embedding of automake initialization
+dnl code into configure script. When automake version 1.14 or
+dnl newer is used at configure script generation time, this
+dnl results in 'subdir-objects' automake option being used.
+dnl When using automake versions older than 1.14 this option
+dnl is not used when generating configure script.
+dnl
+dnl Existence of automake _AM_PROG_CC_C_O m4 private macro
+dnl is used to differentiate automake version 1.14 from older
+dnl ones which lack this macro.
+
+m4_define([_XC_AUTOMAKE_BODY],
+[dnl
+## --------------------------------------- ##
+## Start of automake initialization code ##
+## --------------------------------------- ##
+m4_ifdef([_AM_PROG_CC_C_O],
+[
+AM_INIT_AUTOMAKE([subdir-objects])
+],[
+AM_INIT_AUTOMAKE
+])dnl
+## ------------------------------------- ##
+## End of automake initialization code ##
+## ------------------------------------- ##
+dnl
+m4_define([$0], [])[]dnl
+])
+
+
+dnl XC_AUTOMAKE
+dnl -------------------------------------------------
+dnl Public macro.
+dnl
+dnl This macro embeds automake machinery into configure
+dnl script regardless of automake version used in order
+dnl to generate configure script.
+dnl
+dnl When using automake version 1.14 or newer, automake
+dnl initialization option 'subdir-objects' is used to
+dnl generate the configure script, otherwise this option
+dnl is not used.
+
+AC_DEFUN([XC_AUTOMAKE],
+[dnl
+AC_PREREQ([2.50])dnl
+dnl
+AC_BEFORE([$0],[AM_INIT_AUTOMAKE])dnl
+dnl
+_XC_AUTOMAKE_BODY
+dnl
+m4_ifdef([AM_INIT_AUTOMAKE],
+ [m4_undefine([AM_INIT_AUTOMAKE])])dnl
+dnl
+m4_define([$0], [])[]dnl
+])
+
+
+dnl _XC_AMEND_DISTCLEAN_BODY ([LIST-OF-SUBDIRS])
+dnl -------------------------------------------------
+dnl Private macro.
+dnl
+dnl This macro performs shell code embedding into
+dnl configure script in order to modify distclean
+dnl and maintainer-clean targets of makefiles which
+dnl are located in given list of subdirs.
+dnl
+dnl See XC_AMEND_DISTCLEAN comments for details.
+
+m4_define([_XC_AMEND_DISTCLEAN_BODY],
+[dnl
+## ---------------------------------- ##
+## Start of distclean amending code ##
+## ---------------------------------- ##
+
+for xc_subdir in [$1]
+do
+
+if test ! -f "$xc_subdir/Makefile"; then
+ echo "$xc_msg_err $xc_subdir/Makefile file not found. $xc_msg_abrt" >&2
+ exit 1
+fi
+
+# Fetch dependency tracking file list from Makefile include lines.
+
+xc_inc_lines=`grep '^include .*(DEPDIR)' "$xc_subdir/Makefile" 2>/dev/null`
+xc_cnt_words=`echo "$xc_inc_lines" | wc -w | tr -d "$xc_space$xc_tab"`
+
+# --disable-dependency-tracking might have been used, consequently
+# there is nothing to amend without a dependency tracking file list.
+
+if test $xc_cnt_words -gt 0; then
+
+AC_MSG_NOTICE([amending $xc_subdir/Makefile])
+
+# Build Makefile specific patch hunk.
+
+xc_p="$xc_subdir/xc_patch.tmp"
+
+xc_rm_depfiles=`echo "$xc_inc_lines" \
+ | $SED 's%include% -rm -f%' 2>/dev/null`
+
+xc_dep_subdirs=`echo "$xc_inc_lines" \
+ | $SED 's%include[[ ]][[ ]]*%%' 2>/dev/null \
+ | $SED 's%(DEPDIR)/.*%(DEPDIR)%' 2>/dev/null \
+ | sort | uniq`
+
+echo "$xc_rm_depfiles" >$xc_p
+
+for xc_dep_dir in $xc_dep_subdirs; do
+ echo "${xc_tab}@xm_dep_cnt=\`ls $xc_dep_dir | wc -l 2>/dev/null\`; \\" >>$xc_p
+ echo "${xc_tab}if test \$\$xm_dep_cnt -eq 0 && test -d $xc_dep_dir; then \\" >>$xc_p
+ echo "${xc_tab} rm -rf $xc_dep_dir; \\" >>$xc_p
+ echo "${xc_tab}fi" >>$xc_p
+done
+
+# Build Makefile patching sed scripts.
+
+xc_s1="$xc_subdir/xc_script_1.tmp"
+xc_s2="$xc_subdir/xc_script_2.tmp"
+xc_s3="$xc_subdir/xc_script_3.tmp"
+
+cat >$xc_s1 <<\_EOT
+/^distclean[[ ]]*:/,/^[[^ ]][[^ ]]*:/{
+ s/^.*(DEPDIR)/___xc_depdir_line___/
+}
+/^maintainer-clean[[ ]]*:/,/^[[^ ]][[^ ]]*:/{
+ s/^.*(DEPDIR)/___xc_depdir_line___/
+}
+_EOT
+
+cat >$xc_s2 <<\_EOT
+/___xc_depdir_line___$/{
+ N
+ /___xc_depdir_line___$/D
+}
+_EOT
+
+cat >$xc_s3 <<_EOT
+/^___xc_depdir_line___/{
+ r $xc_p
+ d
+}
+_EOT
+
+# Apply patch to Makefile and cleanup.
+
+$SED -f "$xc_s1" "$xc_subdir/Makefile" >"$xc_subdir/Makefile.tmp1"
+$SED -f "$xc_s2" "$xc_subdir/Makefile.tmp1" >"$xc_subdir/Makefile.tmp2"
+$SED -f "$xc_s3" "$xc_subdir/Makefile.tmp2" >"$xc_subdir/Makefile.tmp3"
+
+if test -f "$xc_subdir/Makefile.tmp3"; then
+ mv -f "$xc_subdir/Makefile.tmp3" "$xc_subdir/Makefile"
+fi
+
+test -f "$xc_subdir/Makefile.tmp1" && rm -f "$xc_subdir/Makefile.tmp1"
+test -f "$xc_subdir/Makefile.tmp2" && rm -f "$xc_subdir/Makefile.tmp2"
+test -f "$xc_subdir/Makefile.tmp3" && rm -f "$xc_subdir/Makefile.tmp3"
+
+test -f "$xc_p" && rm -f "$xc_p"
+test -f "$xc_s1" && rm -f "$xc_s1"
+test -f "$xc_s2" && rm -f "$xc_s2"
+test -f "$xc_s3" && rm -f "$xc_s3"
+
+fi
+
+done
+
+## -------------------------------- ##
+## End of distclean amending code ##
+## -------------------------------- ##
+dnl
+m4_define([$0], [])[]dnl
+])
+
+
+dnl XC_AMEND_DISTCLEAN ([LIST-OF-SUBDIRS])
+dnl -------------------------------------------------
+dnl Public macro.
+dnl
+dnl This macro embeds shell code into configure script
+dnl that amends, at configure runtime, the distclean
+dnl and maintainer-clean targets of Makefiles located
+dnl in all subdirs given in the mandatory white-space
+dnl separated list argument.
+dnl
+dnl Embedding only takes place when using automake 1.14
+dnl or newer, otherwise amending code is not included
+dnl in generated configure script.
+dnl
+dnl distclean and maintainer-clean targets are modified
+dnl to avoid unconditional removal of dependency subdirs
+dnl which triggers distclean and maintainer-clean errors
+dnl when using automake 'subdir-objects' option along
+dnl with per-target objects and source files existing in
+dnl multiple subdirs used for different build targets.
+dnl
+dnl New behavior first removes each dependency tracking
+dnl file independently, and only removes each dependency
+dnl subdir when it finds out that it no longer holds any
+dnl dependency tracking file.
+dnl
+dnl When configure option --disable-dependency-tracking
+dnl is used no amending takes place given that there are
+dnl no dependency tracking files.
+
+AC_DEFUN([XC_AMEND_DISTCLEAN],
+[dnl
+AC_PREREQ([2.50])dnl
+dnl
+m4_ifdef([_AC_OUTPUT_MAIN_LOOP],
+ [m4_provide_if([_AC_OUTPUT_MAIN_LOOP], [],
+ [m4_fatal([call to AC_OUTPUT needed before $0])])])dnl
+dnl
+m4_if([$#], [1], [], [m4_fatal([$0: wrong number of arguments])])dnl
+m4_if([$1], [], [m4_fatal([$0: missing argument])])dnl
+dnl
+AC_REQUIRE([XC_CONFIGURE_PREAMBLE])dnl
+dnl
+m4_ifdef([_AM_PROG_CC_C_O],
+[
+_XC_AMEND_DISTCLEAN_BODY([$1])
+])dnl
+m4_define([$0], [])[]dnl
+])
+
diff --git a/mkinstalldirs b/mkinstalldirs
index 3bc1836..55d537f 100755
--- a/mkinstalldirs
+++ b/mkinstalldirs
@@ -1,39 +1,162 @@
#! /bin/sh
# mkinstalldirs --- make directory hierarchy
-# Author: Noah Friedman <friedman@prep.ai.mit.edu>
-# Created: 1993-05-16
-# Public domain
+scriptversion=2009-04-28.21; # UTC
+
+# Original author: Noah Friedman <friedman@prep.ai.mit.edu>
+# Created: 1993-05-16
+# Public domain.
+#
+# This file is maintained in Automake, please report
+# bugs to <bug-automake@gnu.org> or send patches to
+# <automake-patches@gnu.org>.
+nl='
+'
+IFS=" "" $nl"
errstatus=0
+dirmode=
+
+usage="\
+Usage: mkinstalldirs [-h] [--help] [--version] [-m MODE] DIR ...
+
+Create each directory DIR (with mode MODE, if specified), including all
+leading file name components.
+
+Report bugs to <bug-automake@gnu.org>."
+
+# process command line arguments
+while test $# -gt 0 ; do
+ case $1 in
+ -h | --help | --h*) # -h for help
+ echo "$usage"
+ exit $?
+ ;;
+ -m) # -m PERM arg
+ shift
+ test $# -eq 0 && { echo "$usage" 1>&2; exit 1; }
+ dirmode=$1
+ shift
+ ;;
+ --version)
+ echo "$0 $scriptversion"
+ exit $?
+ ;;
+ --) # stop option processing
+ shift
+ break
+ ;;
+ -*) # unknown option
+ echo "$usage" 1>&2
+ exit 1
+ ;;
+ *) # first non-opt arg
+ break
+ ;;
+ esac
+done
for file
do
- set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`
- shift
+ if test -d "$file"; then
+ shift
+ else
+ break
+ fi
+done
+
+case $# in
+ 0) exit 0 ;;
+esac
+
+# Solaris 8's mkdir -p isn't thread-safe. If you mkdir -p a/b and
+# mkdir -p a/c at the same time, both will detect that a is missing,
+# one will create a, then the other will try to create a and die with
+# a "File exists" error. This is a problem when calling mkinstalldirs
+# from a parallel make. We use --version in the probe to restrict
+# ourselves to GNU mkdir, which is thread-safe.
+case $dirmode in
+ '')
+ if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then
+ echo "mkdir -p -- $*"
+ exec mkdir -p -- "$@"
+ else
+ # On NextStep and OpenStep, the 'mkdir' command does not
+ # recognize any option. It will interpret all options as
+ # directories to create, and then abort because '.' already
+ # exists.
+ test -d ./-p && rmdir ./-p
+ test -d ./--version && rmdir ./--version
+ fi
+ ;;
+ *)
+ if mkdir -m "$dirmode" -p --version . >/dev/null 2>&1 &&
+ test ! -d ./--version; then
+ echo "mkdir -m $dirmode -p -- $*"
+ exec mkdir -m "$dirmode" -p -- "$@"
+ else
+ # Clean up after NextStep and OpenStep mkdir.
+ for d in ./-m ./-p ./--version "./$dirmode";
+ do
+ test -d $d && rmdir $d
+ done
+ fi
+ ;;
+esac
+
+for file
+do
+ case $file in
+ /*) pathcomp=/ ;;
+ *) pathcomp= ;;
+ esac
+ oIFS=$IFS
+ IFS=/
+ set fnord $file
+ shift
+ IFS=$oIFS
+
+ for d
+ do
+ test "x$d" = x && continue
+
+ pathcomp=$pathcomp$d
+ case $pathcomp in
+ -*) pathcomp=./$pathcomp ;;
+ esac
- pathcomp=
- for d
- do
- pathcomp="$pathcomp$d"
- case "$pathcomp" in
- -* ) pathcomp=./$pathcomp ;;
- esac
+ if test ! -d "$pathcomp"; then
+ echo "mkdir $pathcomp"
- if test ! -d "$pathcomp"; then
- echo "mkdir $pathcomp" 1>&2
+ mkdir "$pathcomp" || lasterr=$?
- mkdir "$pathcomp" || lasterr=$?
+ if test ! -d "$pathcomp"; then
+ errstatus=$lasterr
+ else
+ if test ! -z "$dirmode"; then
+ echo "chmod $dirmode $pathcomp"
+ lasterr=
+ chmod "$dirmode" "$pathcomp" || lasterr=$?
- if test ! -d "$pathcomp"; then
- errstatus=$lasterr
- fi
- fi
+ if test ! -z "$lasterr"; then
+ errstatus=$lasterr
+ fi
+ fi
+ fi
+ fi
- pathcomp="$pathcomp/"
- done
+ pathcomp=$pathcomp/
+ done
done
exit $errstatus
-# mkinstalldirs ends here
+# Local Variables:
+# mode: shell-script
+# sh-indentation: 2
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-time-zone: "UTC"
+# time-stamp-end: "; # UTC"
+# End:
diff --git a/packaging/c-ares.spec b/packaging/c-ares.spec
index dac7494..6a2e2fd 100644
--- a/packaging/c-ares.spec
+++ b/packaging/c-ares.spec
@@ -1,5 +1,5 @@
Name: c-ares
-Version: 1.10.0
+Version: 1.12.0
Release: 0
License: MIT
Summary: Library for asynchronous name resolves
@@ -44,28 +44,26 @@ cp %{SOURCE1002} .
%build
autoreconf -fiv
-%configure --enable-symbol-hiding --enable-nonblocking --enable-shared --disable-static --with-pic
+%configure --enable-symbol-hiding --enable-nonblocking --enable-shared --disable-static --with-pic --disable-tests
sed -i -e 's@-g0@-g@g' Makefile
make %{?_smp_mflags}
%install
%make_install
-#mkdir -p %{buildroot}/usr/share/license
-#cp LICENSE %{buildroot}/usr/share/license/%{name}
%post -p /sbin/ldconfig -n libcares
%postun -p /sbin/ldconfig -n libcares
%files -n libcares
-%manifest %{name}.manifest
%license LICENSE
+%manifest %{name}.manifest
%defattr(-,root,root)
%{_libdir}/libcares.so.2*
%files -n libcares-devel
-%manifest %{name}.manifest
%license LICENSE
+%manifest %{name}.manifest
%defattr(-,root,root)
%{_libdir}/libcares.so
%{_includedir}/*.h