diff options
author | snermolaev <snermolaev@yandex-team.ru> | 2022-02-10 16:45:53 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:53 +0300 |
commit | 2015790ac9fcc04caab83fccc23ab2460310a797 (patch) | |
tree | e644e9bc3f6f688561a871793b59bf8a637e0f72 /contrib/libs/c-ares | |
parent | c768a99151e47c3a4bb7b92c514d256abd301c4d (diff) | |
download | ydb-2015790ac9fcc04caab83fccc23ab2460310a797.tar.gz |
Restoring authorship annotation for <snermolaev@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'contrib/libs/c-ares')
60 files changed, 4572 insertions, 4572 deletions
diff --git a/contrib/libs/c-ares/AUTHORS b/contrib/libs/c-ares/AUTHORS index 7db6584c91..1698e73a60 100644 --- a/contrib/libs/c-ares/AUTHORS +++ b/contrib/libs/c-ares/AUTHORS @@ -2,13 +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 +Alex Loukissas +Alexander Klauer Alexander Lazic Alexey Simak Andreas Rieke -Andrew Andkjar -Andrew Ayer +Andrew Andkjar +Andrew Ayer Andrew C. Morrow Ashish Sharma Ben Greear @@ -17,28 +17,28 @@ BogDan Vatra Brad House Brad Spencer Bram Matthys -Chris Araman +Chris Araman Dan Fandrich Daniel Johnson Daniel Stenberg -David Drysdale +David Drysdale David Stuart Denis Bilenko Dima Tisnek Dirk Manske Dominick Meglio Doug Goldstein -Doug Kwan +Doug Kwan Duncan Wilcox Eino Tuominen Erik Kline -Fedor Indutny -Frederic Germain -Geert Uytterhoeven +Fedor Indutny +Frederic Germain +Geert Uytterhoeven George Neill Gisle Vanem -Google LLC -Gregor Jasny +Google LLC +Gregor Jasny Guenter Knauf Guilherme Balena Versiani Gunter Knauf @@ -46,39 +46,39 @@ Henrik Stoerner Jakub Hrozek James Bursa Jérémy Lal -John Schember -Keith Shaw -Lei Shi +John Schember +Keith Shaw +Lei Shi Marko Kreen Michael Wallner Mike Crowe Nick Alcock Nick Mathewson -Nicolas "Pixel" Noble -Ning Dong -Oleg Pudeyev -Patrick Valsecchi +Nicolas "Pixel" Noble +Ning Dong +Oleg Pudeyev +Patrick Valsecchi Patrik Thunstrom -Paul Saab +Paul Saab Peter Pentchev Phil Blundell Poul Thomas Lomholt Ravi Pratap Robin Cornelius -Saúl Ibarra Corretgé +Saúl Ibarra Corretgé Sebastian at basti79.de Shmulik Regev Stefan Bühler Steinar H. Gunderson -Svante Karlsson +Svante Karlsson Tofu Linden Tom Hughes Tor Arntsen -Viktor Szakats +Viktor Szakats Vlad Dinulescu William Ahern Yang Tse -hpopescu at ixiacom.com +hpopescu at ixiacom.com liren at vivisimo.com -nordsturm -saghul +nordsturm +saghul diff --git a/contrib/libs/c-ares/CHANGES b/contrib/libs/c-ares/CHANGES index f6652caaa0..3f05120c20 100644 --- a/contrib/libs/c-ares/CHANGES +++ b/contrib/libs/c-ares/CHANGES @@ -790,1950 +790,1950 @@ Brad House (6 May 2018) due to not being listed in Makefile.inc. Add missing docs and ensure docs are alphabetized. -Version 1.14.0 (16 Feb 2018) - -Daniel Stenberg (16 Feb 2018) -- ares_android.c: fix warning: ISO C forbids an empty translation unit - -- RELEASE-NOTES: some more work we did and people who helped - -Brad House (16 Feb 2018) -- travis: skip Autotools style testing for cmake - - Fix cmake test build by skipping autotools portion of test script. - -- travis: standardize CMake test off of Autotools tests - - Instead of running 'make test', run the tests directly like autotools - does. It provides more verbose output. - -- travis: Enable building tests for CMake - - Travis should auto-build and run tests for cmake builds now that - PR #168 is merged. - -- fix version in pkgconfig - -- Add version update to CMakeLists in maketgz - -- Release prep. Add support for pkgconfig in cmake, set versions appropriately - -Gregor Jasny (15 Feb 2018) -- CMake: Add tests - -Brad House (14 Feb 2018) -- [Gregor Jasny brought this change] - - Use cmake3 package provided by Ubuntu (#182) - -- Cmake 3.1 instead of 3.2.1 should be the minimum - -- Update RELEASE-NOTES and RELEASE-PROCEDURE.md to prepare for next release - -- get rid of c++ style comments - -- Use trusty for all builds, precise is EOL. Update clang and cmake versions. - -- Current CMakeLists.txt doesn't support 2.8.12 anymore, we need to bump the version to 3.2.1 minimum - -- Re-organize sections in INSTALL.md and add CMake section - -- [Sergey Kolomenkin brought this change] - - remove compilation warnings in MSVC (#47) - -- document handling of timeouts for ares_process and ares_process_fd to close PR #57 - -- As per Issue #155, since we do not require gethostname() during init, if it fails, there's no reason for init to fail as it is only used to populate the domain - -GitHub (7 Feb 2018) -- [David Drysdale brought this change] - - Document WSAStartup requirement (#180) - -David Drysdale (6 Feb 2018) -- [Antonio Tajuelo brought this change] - - Added coderelease.io badge to readme.md for letting people subscribe to new versions (#174) - -- [Sheel Bedi brought this change] - - Update year in LICENSE.md to 2018 (#170) - -GitHub (4 Feb 2018) -- [David Drysdale brought this change] - - travis: use VM not container for {L,A}SAN builds (#177) - - As per https://github.com/travis-ci/travis-ci/issues/9033, container - based builds do not currently allow ptrace, which is used by LSAN and - ASAN. - -Brad House (3 Feb 2018) -- [acthompson-google-com brought this change] - - Android JNI code leaks local references in some cases (#175) - - * Add Google LLC to AUTHORS. - - * android: Explicitly delete all JNI local references, and cache JNI method IDs at initialization. - - * android: Only return ARES_ENOTINITIALIZED on failures in initialization code. - -Gregor Jasny (2 Jan 2018) -- Embed fused Google Test 1.8.0 - -Brad House (21 Dec 2017) -- [John Schember brought this change] - - android: Check returns for obj and classes are not NULL. Document API levels for various Android functions and objects used. (#166) - -- CARES_CHECK_TYPE should reference variable so a warning is not produced for -Werror compatibility - -- [Brad Spencer brought this change] - - Fix computation of IPv6 blacklist mask for values of netmask > 8. (#164) - -David Drysdale (14 Dec 2017) -- travis: Only do coverage/distcheck on normal build - -- travis: only do pip install on Linux - -- travis: only test in IPv4 mode - - Travis' Trusty environment does not support IPv6. - -- test: allow restriction to one IP address family - -- [Roman Teterin brought this change] - - Fix a typo in init_by_resolv_conf (#160) - -Brad House (11 Dec 2017) -- @gvanem says MSVC -RTCc option fails, looks erroneous to me, but the additional mask is harmless - -- Fix some other mingw warnings - -- Issue #143, get rid of windows build warning due to passing 'char **' to argument expecting 'const char **' - -- [Gregor Jasny brought this change] - - Distribute CMake files (#130) - -- Android variants may not have __system_property_get - - Some android systems like ARM64 may not have the __system_property_get - symbol in libc (but still have it in the public headers). Detect this - condition at build time. The __system_property_get method of retrieving - name servers is deprecated as of Oreo so should strictly be a fallback - mechanism anyhow. - -David Drysdale (9 Nov 2017) -- [David Hotham brought this change] - - Wrong function name throughout man page (#154) - -- ares_data.c: iterate through substructs when freeing - - Previous code recursed into substructures, which makes it more likely - that large/heavily-nested responses could use up lots of stack. - -- test: test ares_free_data on long chain of structs - -- [Felix Yan brought this change] - - Fix a typo in inet_ntop.c (#151) - -Daniel Stenberg (29 Sep 2017) -- ares_gethostbyname.3: fix callback status values - - - ARES_ENOTFOUND means the _name_ wasn't found - - - ARES_ENODATA can be returned when a resolve fails - - Reported-by: Jakub Hrozek - Bug: https://c-ares.haxx.se/mail/c-ares-archive-2011-06/0012.shtml - -Brad House (28 Sep 2017) -- [John Schember brought this change] - - Fix DNS server lookup breaking with Android O due to Android removing access to net.dns# system properties. (#148) - - As of Android 8 (Oreo) access to net.dns# has been removed (https://developer.android.com/about/versions/oreo/android-8.0-changes.html). The reasoning given is that it, "improves privacy on the platform". Currently c-ares uses this to get the list of DNS servers. - - Now the only way to access the DNS server list is by using the Connectivity Manager though Java. This adds the necessary JNI code to use the Connectivity Manager and pull the DNS server list. The old way using __system_property_get with net.dns# remains for compatibilty. - - Using the Connectivity Manager requires the ACCESS_NETWORK_STATE permission to be set on the app. Existing applications most likely are not setting this and keeping the previous method as a fallback will at the very least ensure those apps don't break on older versions of Android. They will need to add this permission for Android 8 compatibility. - - Included in the patch are two initalization functions which are required. The JVM must be registered as well as the Connectivity Manager itself. There is no way to get the Connectivity Manager except though Java. Either being passed down to C directly or by passing in an Android Context which can be used to get the Connectivity Manager. Examples are provided in the documentation. - -- [Konstantinos Sofokleous brought this change] - - allow linking against the static msvc runtime library (#133) - - allow linking against the static msvc runtime library - -- [Gergely Nagy brought this change] - - Force using the ANSI versions of WinAPI functions (#142) - - When compiling c-ares with a build system that defines UNICODE, - bad versions of WinAPI functions are used causing failures or even - crashes. When windows.h is included in MBCS mode (like in the default - build system), the ..A versions are the same as using the one without - any suffix. - -- [cmake] build fix on Solaris - -GitHub (11 Sep 2017) -- [Brad House brought this change] - - Win32 exclude legacy ipv6 subnets (#144) - - win32 ipv6: add infrastructure to exclude ipv6 subnets that are known to cause issues - -- [David Drysdale brought this change] - - windows: only look for ancient compilers (#146) - - Also drop the use of a versioned output directory; just use - .\msvc - -- [David Drysdale brought this change] - - ares_init_options.3: match up sock_state_cb args (#141) - - Fixes #140 - -Daniel Stenberg (25 Aug 2017) -- [Anna Henningsen brought this change] - - gethostbyaddr: fail with `ECANCELLED` for `ares_cancel()` - - When `ares_cancel()` was invoked, `ares_gethostbyaddr()` - queries would fail with `ENOTFOUND` instead of `ECANCELLED`. - - It seems appropriate to treat `ares_cancel()` like `ares_destroy()`, - but I would appreciate review of the correctness of this change. - - Ref: https://github.com/nodejs/node/issues/14814 - - Closes #138 - -David Drysdale (18 Aug 2017) -- [David Hotham brought this change] - - support most recent Visual Studio 2017 - -Brad House (26 Jul 2017) -- Preserve original DNS server order on Windows for equal metrics. - - qsort is not stable, in order to make it stable we need to record - the original index and add it as a secondary sort value when the - metrics are equal to prevent using DNS servers that may not work - at all as reported by some users. - -David Drysdale (15 Jul 2017) -- [Anna Henningsen brought this change] - - ares_parse_naptr_reply: make buffer length check more accurate - - 9478908a490a6bf009ba58d81de8c1d06d50a117 introduced a length check - for records parsed by `ares_parse_naptr_reply()`. However, that - function is designed to parse replies which also contain non-NAPTR - records; for A records, the `rr_len > 7` check will fail as there - are only 4 bytes of payload. - In particular, parsing ANY replies for NAPTR records was broken - by that patch. - - Fix that by moving the check into the case in which it is already - known that the record is a NAPTR record. - -- appveyor: run dnsdump as a sanity check - -- travis: run dnsdump as a sanity check - -- test: use ares_free_string() throughout - - As pointed out by Gisle Vanem in #125. - -Daniel Stenberg (3 Jul 2017) -- RELEASE-PROCEDURE.md: how to release - - Fixes #115 - Closes #116 - -David Drysdale (2 Jul 2017) -- test: Build dnsdump on Windows too - - Thanks to Gisle Vanem for showing the way: - https://github.com/c-ares/c-ares/commit/b701af8a24cf9d173b1dbe5faedcea34642e92da#commitcomment-22830845 - -Brad House (26 Jun 2017) -- [Christian Ammer brought this change] - - fix statement like #define - ares ssize_t define had a trailing semicolon (#120) - -David Drysdale (21 Jun 2017) -- test: distribute the fuzzcheck.sh script - - The TESTS target runs fuzzcheck.sh so make sure it is included - in the distributed tarball. - - (The test itself will be pointless when run on a distribution, because - the fuzzing corpus directories are not shipped, but at least this - means that `make -C test test` should work.) - -- test: run the name-parsing corpus check too - -Daniel Stenberg (21 Jun 2017) -- dist: don't build/ship PDF versions in release archives - - ... experience says very few read them and they can still get build by - those who want them.a - -- ares_version.h: bump version - -Version 1.13.0 (20 Jun 2017) - -Daniel Stenberg (20 Jun 2017) -- RELEASE-NOTES: 1.13.0 - -- ares_set_socket_functions.3: added in 1.13.0 - -David Drysdale (18 Jun 2017) -- ares_parse_naptr_reply: check sufficient data - - Check that there is enough data for the required elements - of an NAPTR record (2 int16, 3 bytes for string lengths) - before processing a record. - -- test: Feed in short NAPTR - -- test: Add fuzz input with short NAPTR - -- test: add ares_parse_naptr_reply to fuzzer - -- [noiz brought this change] - - Update ares.h to support compiling with QNX - -- [Dionna Glaze brought this change] - - Simple changes to appease stricter compilers. - - ares_process.c uses htonl, which needs <arpa/inet.h> included. - ares_getnameinfo.c uses a dynamically selected format string for - sprintf, which -Wformat-literal doesn't like. Usually one would use - inttypes.h and a format string "%" PRIu32, but C99 is too new for some - supported platforms. - -GitHub (16 Jun 2017) -- [Gregor Jasny brought this change] - - CMake: Emulate interface library on import (#108) - - Closes: #104 - Signed-off-by: Gregor Jasny <gjasny@googlemail.com> - -Brad House (6 Jun 2017) -- [ChristianAmmer brought this change] - - Added support for Windows DNS Suffix Search List (#93) - - This change solves issue #53. - - Support for suffix search lists was already built in for Linux. The search list could be set via set_search. With this change the suffix search list from Windows is read from the registry and then set into the ares configuration via set_search. There are two sources for the search list: - - The global DNS suffix search list. - The primary and connection specific DNS suffixes if the global is not available. - - Contributed by @ChristianAmmer - -Daniel Stenberg (25 May 2017) -- [Thomas Köckerbauer brought this change] - - configure: do not heck for ar if specified manually - - Closes #62 - -David Drysdale (23 May 2017) -- ares_expand_name: limit number of indirections - -- test: fuzz input file that takes a while to process - -- test: copy data in fuzz regression driver - - Oops. - -GitHub (23 May 2017) -- [David Drysdale brought this change] - - Convert char from ISO-8859-1 to UTF-8 (#99) - - Fixes #97 - -- [Gregor Jasny brought this change] - - travis: Use trusty for cmake builds (#109) - - kubuntu-backports dropped the CMake package for Precise - -David Drysdale (2 May 2017) -- [David Hotham brought this change] - - msvc_ver.inc support most recent Visual Studio 2017 (#101) - -- test: use io.h not unistd.h for Windows - -- test: try building fuzz binaries on Windows - -- test: stick to int in ares-fuzz.c - - Using int rather than ares_ssize_t means this file - needs no c-ares dependency - it's a general driver for - any libFuzzer-style entrypoint. - -- test: force ARES_OPT_NOROTATE for no-rotate tests - -- test: check expected NOROTATE value - -- ares_create_query: use ares_free not naked free - - Accidentally added in commit 65c71be1cbe5 - ("ares_create_query: avoid single-byte buffer overwrite") - -Brad House (17 Mar 2017) -- Need ares.h for ares_ssize_t - -- tests should not use ssize_t, use ares_ssize_t - -GitHub (16 Mar 2017) -- [Brad House brought this change] - - Portability updates for legacy systems. (#92) - - Socklen_t should not be used in code, instead ares_socklen_t should be used. - Convert ssize_t to ares_ssize_t for portability since the public API now exposes this. - -David Drysdale (14 Mar 2017) -- [Michael Osei brought this change] - - Update msvc_ver.inc (#91) - - For Visual Studio 2017 builds - -Daniel Stenberg (13 Mar 2017) -- [Brad House brought this change] - - Windows DNS server sorting (#81) - - Original Patch From Brad Spencer: - https://c-ares.haxx.se/mail/c-ares-archive-2016-04/0000.shtml - - My modifications include: - * Dynamically find GetBestRoute2 since it is a Windows Vista+ symbol, and will fall back to prior behavior when not available. - * Prefer get_DNS_AdaptersAddresses as the modifications should alleviate the concerns which caused us to prefer get_DNS_NetworkParams - * Update AppVeyor to use MinGW-w64 instead of the legacy MinGW - * Fix compile error in test suite for Windows. - - Original message from patch below: - - From: Brad Spencer <bspencer@blackberry.com> - Date: Fri, 29 Apr 2016 14:26:23 -0300 - - On Windows, the c-ares DNS resolver tries first to get a full list of - DNS server addresses by enumerating the system's IPv4/v6 interfaces and - then getting the per-interface DNS server lists from those interfaces - and joining them together. The OS, at least in the way the c-ares - prefers to query them (which also may be the only or best way in some - environments), does not provide a unified list of DNS servers ordered - according to "current network conditions". Currently, c-ares will then - try to use them in whatever order the nested enumeration produces, which - may result in DNS requests being sent to servers on one interface - (hosting the current default route, for example) that are only intended - to be used via another interface (intended to be used when the first - interface is not available, for example). This, in turn, can lead to - spurious failures and timeouts simply because of the server address - order that resulted because of the enumeration process. - - This patch makes the (safe?) assumption that there is no other better - rule to chose which interface's DNS server list should be prioritized. - After all, a DNS lookup isn't something "per network"; applications - don't look up "these DNS names on this interface and those DNS names on - that interface". There is a single resource pool of DNS servers and the - application should presume that any server will give it the "right" - answer. However, even if all DNS servers are assumed to give equally - useful responses, it is reasonable to expect that some DNS servers will - not accept requests on all interfaces. This patch avoids the problem by - sorting the DNS server addresses using the Windows IPv4/v6 routing tables. - - For example, a request to DNS server C on interface 2 that is actually - sent over interface 1 (which may happen to have the default route) may - be rejected by or not delivered to DNS server C. So, better to use DNS - servers A and B associated with interface 1, at least as a first try. - - By using the metric of the route to the DNS server itself as a proxy for - priority of the DNS server in the list, this patch is able to adapt - dynamically to changes in the interface list, the DNS server lists per - interface, which interfaces are active, the routing table, and so on, - while always picking a good "best" DNS server first. - - In cases where any DNS server on any interface will do, this patch still - seems useful because it will prioritize a lower-metric route's (and thus - interface's) servers. - -David Drysdale (22 Feb 2017) -- [Sergii Pylypenko brought this change] - - docs: fixed references to ares_set_local_ip4 and ares_set_local_ip6 - -- [Calle Wilund brought this change] - - ares test: fix win32 build errors with virtual socket function tests - - The added api requires both some typedefs not previously imported - into the test build + the test code did not fully deal with - socket differences on windows. - -- [Calle Wilund brought this change] - - ares_process: fix return type of socket_create function (win32 warning) - -Daniel Stenberg (31 Jan 2017) -- [Calle Wilund brought this change] - - ares_set_socket_functions: Add man page - - Providing some rudimentary documentation for the added functionality - - Closes #72 - -- [Calle Wilund brought this change] - - ares-test: Add test helpers and cases for virtual socket IO - - * Added test case macro to automatically run tests twice, once "normal", - once with virtual IO. - * Changed most "live" query tests to run in dual mode to verify - at least simple socket IO via virtual functions - * Added test case for settings/duping socket functions & callback data - -- [elcallio brought this change] - - Implement using virtual socket IO functions when set - - Uses virtual socket IO functions when set on a channel. - Note that no socket options are set, nor is any binding - done by the library in this case, since the client defining - these is probably more suited to deal with this. - -- [elcallio brought this change] - - Add virtual function set for socket IO - - Defines a structure of basic create, close, read/write - functions as virtual function calls, settable for individual - c-ares channels. - -David Drysdale (30 Jan 2017) -- test: ignore aresfuzzname binary - -Gregor Jasny (14 Jan 2017) -- [Stephen Sorley brought this change] - - Always use check_symbol_exists instead of check_function_exists. - -- Also add includes to TARGETS_INST_DEST - -- [Stephen Sorley brought this change] - - Windows build fixes - -- CMake: Export targets - -- CMake: Use GNUInstallDirs for install location defaults - -David Drysdale (11 Jan 2017) -- Update Makefile.am for renamed INSTALL.md - -GitHub (11 Jan 2017) -- [David Drysdale brought this change] - - docs: convert INSTALL to MarkDown & tweak (#83) - -- [Gregor Jasny brought this change] - - Merge pull request #77 from stephen-sorley/cmake_modernize - - Updated CMake minimum version to 2.8.12. - -Stephen Sorley (4 Jan 2017) -- Changed executables to depend directly on internal libcares target, instead of against - the external-facing alias targets. - -- Updated Travis to pull CMake 2.8.12 from kubuntu-backports ppa. - -- Updated CMake minimum version to 2.8.12. - - Changed the way usage requirements (include dirs, compile defs, dependent libraries) are specified, to match the recommended standard practice for modern CMake. This involves using target-specific functions (target_include_directories, target_compile_definitions, etc.), along with the PUBLIC, PRIVATE or INTERFACE modifiers. - - Updated chain-building support to imitate new-style Find modules (import libs), instead of old-style Find modules (cache variables). - -David Drysdale (26 Dec 2016) -- [Chris Araman brought this change] - - configure: clock_gettime workaround (#75) - - Commits 7518c26, c41726b, and bc14ee7 brought this workaround to the CMake build system. This expands it to the autoconf build system. - - Fixes #71 - -- test: add fuzz entrypoint for ares_create_query() - -- test: Add gTest/gMock files to SOURCES - - Built tarballs are not including all of the files needed - to build the test suite because they are missing from the - <target>_SOURCES variable in Makefile.am. - -- travis: Move build scripts under travis/ - - Travis doesn't always propagate errors in inline multi-line - scripts, so move them all to be explicit shell scripts, each - with set -e. - -- travis: check distributed tarball builds - -Daniel Stenberg (25 Oct 2016) -- dist: ship msvc_ver.inc too - - Reported-by: Bruce Stephens - - Fixes #69 - -- [Aaron Bieber brought this change] - - fix build on OpenBSD - -- ares_version.h: bump, working on 1.12.1 now - -GitHub (18 Oct 2016) -- [Gregor Jasny brought this change] - - Merge pull request #64 from bradh352/master - - Add CMake build system support to C-Ares. - -Brad House (5 Oct 2016) -- suggested PROJECT_NAME change broke chain building as it needs the magic PROJECT_NAME set in the ADD_LIBRARY for matching. Fix to make both goals work - -- update MacOSX 10.12 detection - -- Expand XCode clock_gettime fix to include MacOS 10.12, not just iOS10 - -David Drysdale (4 Oct 2016) -- Revert "travis: work around bug in PyCParser" - - This reverts commit a24a10a348fc00b8cfd684d91894a1df14880ea9. - -- travis: work around bug in PyCParser - - See https://github.com/pyca/cryptography/issues/3187 - -Brad House (3 Oct 2016) -- PROJECT_SOURCE_DIR instead of CMAKE_CURRENT_SOURCE_DIR as per @gjasny - -- use a project name of c-ares as per @gjasny - -- Import curl conversion of Makefile.inc to cmake form dynamically as per bdoetsch@ameritech.net to make maintaining multiple build systems easier - -Daniel Stenberg (30 Sep 2016) -- dist: add ares_library_initialized.* to the tarball - -David Drysdale (30 Sep 2016) -- test: check ares_create_query with too-long name - -Daniel Stenberg (30 Sep 2016) -- man pages: minor formatting edits - -Brad House (29 Sep 2016) -- merge fc7917e from @daviddrysdale ... travis build updates for cmake - -- cleanups as per @gjasny ... Use naked IF statements and use NOT DEFINED - -Version 1.12.0 (29 Sep 2016) - -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 - -Brad House (29 Sep 2016) -- CMake: Unify library versioning with the libtool methodology to make keeping library versions in sync easier with the autotools build system - -Daniel Stenberg (29 Sep 2016) -- 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 - -Brad House (28 Sep 2016) -- XCode v8 introduced clock_gettime() for iOS v10. However, it is a weak symbol, which means when earlier iOS versions try to use clock_gettime() it results in a crash due to the missing symbol. Detect this condition and do not set HAVE_CLOCK_GETTIME_MONOTONIC. - -- Adds cmake build system support to C-Ares. - - The patch does not modify any source files, it only adds 3 new files - (CMakelists.txt, ares_build.h.cmake, ares_config.h.cmake) which form the - build system. I've tried to go through as much of the autotools tests and - extracted what I thought was appropriate, though many of the tests aren't - as in-depth in CMake as they are for autotools ... it is unclear why some - of them exist at all, I'm guessing for legacy systems that CMake probably - doesn't support anyhow. - - Building the library, and examples (adig, ahost, acountry) plus installation - should work across a large number of tested platforms. The tests have not - yet been integrated. - -Daniel Stenberg (27 Sep 2016) -- 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.14.0 (16 Feb 2018) + +Daniel Stenberg (16 Feb 2018) +- ares_android.c: fix warning: ISO C forbids an empty translation unit + +- RELEASE-NOTES: some more work we did and people who helped + +Brad House (16 Feb 2018) +- travis: skip Autotools style testing for cmake + + Fix cmake test build by skipping autotools portion of test script. + +- travis: standardize CMake test off of Autotools tests + + Instead of running 'make test', run the tests directly like autotools + does. It provides more verbose output. + +- travis: Enable building tests for CMake + + Travis should auto-build and run tests for cmake builds now that + PR #168 is merged. + +- fix version in pkgconfig + +- Add version update to CMakeLists in maketgz + +- Release prep. Add support for pkgconfig in cmake, set versions appropriately + +Gregor Jasny (15 Feb 2018) +- CMake: Add tests + +Brad House (14 Feb 2018) +- [Gregor Jasny brought this change] + + Use cmake3 package provided by Ubuntu (#182) + +- Cmake 3.1 instead of 3.2.1 should be the minimum + +- Update RELEASE-NOTES and RELEASE-PROCEDURE.md to prepare for next release + +- get rid of c++ style comments + +- Use trusty for all builds, precise is EOL. Update clang and cmake versions. + +- Current CMakeLists.txt doesn't support 2.8.12 anymore, we need to bump the version to 3.2.1 minimum + +- Re-organize sections in INSTALL.md and add CMake section + +- [Sergey Kolomenkin brought this change] + + remove compilation warnings in MSVC (#47) + +- document handling of timeouts for ares_process and ares_process_fd to close PR #57 + +- As per Issue #155, since we do not require gethostname() during init, if it fails, there's no reason for init to fail as it is only used to populate the domain + +GitHub (7 Feb 2018) +- [David Drysdale brought this change] + + Document WSAStartup requirement (#180) + +David Drysdale (6 Feb 2018) +- [Antonio Tajuelo brought this change] + + Added coderelease.io badge to readme.md for letting people subscribe to new versions (#174) + +- [Sheel Bedi brought this change] + + Update year in LICENSE.md to 2018 (#170) + +GitHub (4 Feb 2018) +- [David Drysdale brought this change] + + travis: use VM not container for {L,A}SAN builds (#177) + + As per https://github.com/travis-ci/travis-ci/issues/9033, container + based builds do not currently allow ptrace, which is used by LSAN and + ASAN. + +Brad House (3 Feb 2018) +- [acthompson-google-com brought this change] + + Android JNI code leaks local references in some cases (#175) + + * Add Google LLC to AUTHORS. + + * android: Explicitly delete all JNI local references, and cache JNI method IDs at initialization. + + * android: Only return ARES_ENOTINITIALIZED on failures in initialization code. + +Gregor Jasny (2 Jan 2018) +- Embed fused Google Test 1.8.0 + +Brad House (21 Dec 2017) +- [John Schember brought this change] + + android: Check returns for obj and classes are not NULL. Document API levels for various Android functions and objects used. (#166) + +- CARES_CHECK_TYPE should reference variable so a warning is not produced for -Werror compatibility + +- [Brad Spencer brought this change] + + Fix computation of IPv6 blacklist mask for values of netmask > 8. (#164) + +David Drysdale (14 Dec 2017) +- travis: Only do coverage/distcheck on normal build + +- travis: only do pip install on Linux + +- travis: only test in IPv4 mode + + Travis' Trusty environment does not support IPv6. + +- test: allow restriction to one IP address family + +- [Roman Teterin brought this change] + + Fix a typo in init_by_resolv_conf (#160) + +Brad House (11 Dec 2017) +- @gvanem says MSVC -RTCc option fails, looks erroneous to me, but the additional mask is harmless + +- Fix some other mingw warnings + +- Issue #143, get rid of windows build warning due to passing 'char **' to argument expecting 'const char **' + +- [Gregor Jasny brought this change] + + Distribute CMake files (#130) + +- Android variants may not have __system_property_get + + Some android systems like ARM64 may not have the __system_property_get + symbol in libc (but still have it in the public headers). Detect this + condition at build time. The __system_property_get method of retrieving + name servers is deprecated as of Oreo so should strictly be a fallback + mechanism anyhow. + +David Drysdale (9 Nov 2017) +- [David Hotham brought this change] + + Wrong function name throughout man page (#154) + +- ares_data.c: iterate through substructs when freeing + + Previous code recursed into substructures, which makes it more likely + that large/heavily-nested responses could use up lots of stack. + +- test: test ares_free_data on long chain of structs + +- [Felix Yan brought this change] + + Fix a typo in inet_ntop.c (#151) + +Daniel Stenberg (29 Sep 2017) +- ares_gethostbyname.3: fix callback status values + + - ARES_ENOTFOUND means the _name_ wasn't found + + - ARES_ENODATA can be returned when a resolve fails + + Reported-by: Jakub Hrozek + Bug: https://c-ares.haxx.se/mail/c-ares-archive-2011-06/0012.shtml + +Brad House (28 Sep 2017) +- [John Schember brought this change] + + Fix DNS server lookup breaking with Android O due to Android removing access to net.dns# system properties. (#148) + + As of Android 8 (Oreo) access to net.dns# has been removed (https://developer.android.com/about/versions/oreo/android-8.0-changes.html). The reasoning given is that it, "improves privacy on the platform". Currently c-ares uses this to get the list of DNS servers. + + Now the only way to access the DNS server list is by using the Connectivity Manager though Java. This adds the necessary JNI code to use the Connectivity Manager and pull the DNS server list. The old way using __system_property_get with net.dns# remains for compatibilty. + + Using the Connectivity Manager requires the ACCESS_NETWORK_STATE permission to be set on the app. Existing applications most likely are not setting this and keeping the previous method as a fallback will at the very least ensure those apps don't break on older versions of Android. They will need to add this permission for Android 8 compatibility. + + Included in the patch are two initalization functions which are required. The JVM must be registered as well as the Connectivity Manager itself. There is no way to get the Connectivity Manager except though Java. Either being passed down to C directly or by passing in an Android Context which can be used to get the Connectivity Manager. Examples are provided in the documentation. + +- [Konstantinos Sofokleous brought this change] + + allow linking against the static msvc runtime library (#133) + + allow linking against the static msvc runtime library + +- [Gergely Nagy brought this change] + + Force using the ANSI versions of WinAPI functions (#142) + + When compiling c-ares with a build system that defines UNICODE, + bad versions of WinAPI functions are used causing failures or even + crashes. When windows.h is included in MBCS mode (like in the default + build system), the ..A versions are the same as using the one without + any suffix. + +- [cmake] build fix on Solaris + +GitHub (11 Sep 2017) +- [Brad House brought this change] + + Win32 exclude legacy ipv6 subnets (#144) + + win32 ipv6: add infrastructure to exclude ipv6 subnets that are known to cause issues + +- [David Drysdale brought this change] + + windows: only look for ancient compilers (#146) + + Also drop the use of a versioned output directory; just use + .\msvc + +- [David Drysdale brought this change] + + ares_init_options.3: match up sock_state_cb args (#141) + + Fixes #140 + +Daniel Stenberg (25 Aug 2017) +- [Anna Henningsen brought this change] + + gethostbyaddr: fail with `ECANCELLED` for `ares_cancel()` + + When `ares_cancel()` was invoked, `ares_gethostbyaddr()` + queries would fail with `ENOTFOUND` instead of `ECANCELLED`. + + It seems appropriate to treat `ares_cancel()` like `ares_destroy()`, + but I would appreciate review of the correctness of this change. + + Ref: https://github.com/nodejs/node/issues/14814 + + Closes #138 + +David Drysdale (18 Aug 2017) +- [David Hotham brought this change] + + support most recent Visual Studio 2017 + +Brad House (26 Jul 2017) +- Preserve original DNS server order on Windows for equal metrics. + + qsort is not stable, in order to make it stable we need to record + the original index and add it as a secondary sort value when the + metrics are equal to prevent using DNS servers that may not work + at all as reported by some users. + +David Drysdale (15 Jul 2017) +- [Anna Henningsen brought this change] + + ares_parse_naptr_reply: make buffer length check more accurate + + 9478908a490a6bf009ba58d81de8c1d06d50a117 introduced a length check + for records parsed by `ares_parse_naptr_reply()`. However, that + function is designed to parse replies which also contain non-NAPTR + records; for A records, the `rr_len > 7` check will fail as there + are only 4 bytes of payload. + In particular, parsing ANY replies for NAPTR records was broken + by that patch. + + Fix that by moving the check into the case in which it is already + known that the record is a NAPTR record. + +- appveyor: run dnsdump as a sanity check + +- travis: run dnsdump as a sanity check + +- test: use ares_free_string() throughout + + As pointed out by Gisle Vanem in #125. + +Daniel Stenberg (3 Jul 2017) +- RELEASE-PROCEDURE.md: how to release + + Fixes #115 + Closes #116 + +David Drysdale (2 Jul 2017) +- test: Build dnsdump on Windows too + + Thanks to Gisle Vanem for showing the way: + https://github.com/c-ares/c-ares/commit/b701af8a24cf9d173b1dbe5faedcea34642e92da#commitcomment-22830845 + +Brad House (26 Jun 2017) +- [Christian Ammer brought this change] + + fix statement like #define - ares ssize_t define had a trailing semicolon (#120) + +David Drysdale (21 Jun 2017) +- test: distribute the fuzzcheck.sh script + + The TESTS target runs fuzzcheck.sh so make sure it is included + in the distributed tarball. + + (The test itself will be pointless when run on a distribution, because + the fuzzing corpus directories are not shipped, but at least this + means that `make -C test test` should work.) + +- test: run the name-parsing corpus check too + +Daniel Stenberg (21 Jun 2017) +- dist: don't build/ship PDF versions in release archives + + ... experience says very few read them and they can still get build by + those who want them.a + +- ares_version.h: bump version + +Version 1.13.0 (20 Jun 2017) + +Daniel Stenberg (20 Jun 2017) +- RELEASE-NOTES: 1.13.0 + +- ares_set_socket_functions.3: added in 1.13.0 + +David Drysdale (18 Jun 2017) +- ares_parse_naptr_reply: check sufficient data + + Check that there is enough data for the required elements + of an NAPTR record (2 int16, 3 bytes for string lengths) + before processing a record. + +- test: Feed in short NAPTR + +- test: Add fuzz input with short NAPTR + +- test: add ares_parse_naptr_reply to fuzzer + +- [noiz brought this change] + + Update ares.h to support compiling with QNX + +- [Dionna Glaze brought this change] + + Simple changes to appease stricter compilers. + + ares_process.c uses htonl, which needs <arpa/inet.h> included. + ares_getnameinfo.c uses a dynamically selected format string for + sprintf, which -Wformat-literal doesn't like. Usually one would use + inttypes.h and a format string "%" PRIu32, but C99 is too new for some + supported platforms. + +GitHub (16 Jun 2017) +- [Gregor Jasny brought this change] + + CMake: Emulate interface library on import (#108) + + Closes: #104 + Signed-off-by: Gregor Jasny <gjasny@googlemail.com> + +Brad House (6 Jun 2017) +- [ChristianAmmer brought this change] + + Added support for Windows DNS Suffix Search List (#93) + + This change solves issue #53. + + Support for suffix search lists was already built in for Linux. The search list could be set via set_search. With this change the suffix search list from Windows is read from the registry and then set into the ares configuration via set_search. There are two sources for the search list: + + The global DNS suffix search list. + The primary and connection specific DNS suffixes if the global is not available. + + Contributed by @ChristianAmmer + +Daniel Stenberg (25 May 2017) +- [Thomas Köckerbauer brought this change] + + configure: do not heck for ar if specified manually + + Closes #62 + +David Drysdale (23 May 2017) +- ares_expand_name: limit number of indirections + +- test: fuzz input file that takes a while to process + +- test: copy data in fuzz regression driver + + Oops. + +GitHub (23 May 2017) +- [David Drysdale brought this change] + + Convert char from ISO-8859-1 to UTF-8 (#99) + + Fixes #97 + +- [Gregor Jasny brought this change] + + travis: Use trusty for cmake builds (#109) + + kubuntu-backports dropped the CMake package for Precise + +David Drysdale (2 May 2017) +- [David Hotham brought this change] + + msvc_ver.inc support most recent Visual Studio 2017 (#101) + +- test: use io.h not unistd.h for Windows + +- test: try building fuzz binaries on Windows + +- test: stick to int in ares-fuzz.c + + Using int rather than ares_ssize_t means this file + needs no c-ares dependency - it's a general driver for + any libFuzzer-style entrypoint. + +- test: force ARES_OPT_NOROTATE for no-rotate tests + +- test: check expected NOROTATE value + +- ares_create_query: use ares_free not naked free + + Accidentally added in commit 65c71be1cbe5 + ("ares_create_query: avoid single-byte buffer overwrite") + +Brad House (17 Mar 2017) +- Need ares.h for ares_ssize_t + +- tests should not use ssize_t, use ares_ssize_t + +GitHub (16 Mar 2017) +- [Brad House brought this change] + + Portability updates for legacy systems. (#92) + + Socklen_t should not be used in code, instead ares_socklen_t should be used. + Convert ssize_t to ares_ssize_t for portability since the public API now exposes this. + +David Drysdale (14 Mar 2017) +- [Michael Osei brought this change] + + Update msvc_ver.inc (#91) + + For Visual Studio 2017 builds + +Daniel Stenberg (13 Mar 2017) +- [Brad House brought this change] + + Windows DNS server sorting (#81) + + Original Patch From Brad Spencer: + https://c-ares.haxx.se/mail/c-ares-archive-2016-04/0000.shtml + + My modifications include: + * Dynamically find GetBestRoute2 since it is a Windows Vista+ symbol, and will fall back to prior behavior when not available. + * Prefer get_DNS_AdaptersAddresses as the modifications should alleviate the concerns which caused us to prefer get_DNS_NetworkParams + * Update AppVeyor to use MinGW-w64 instead of the legacy MinGW + * Fix compile error in test suite for Windows. + + Original message from patch below: + + From: Brad Spencer <bspencer@blackberry.com> + Date: Fri, 29 Apr 2016 14:26:23 -0300 + + On Windows, the c-ares DNS resolver tries first to get a full list of + DNS server addresses by enumerating the system's IPv4/v6 interfaces and + then getting the per-interface DNS server lists from those interfaces + and joining them together. The OS, at least in the way the c-ares + prefers to query them (which also may be the only or best way in some + environments), does not provide a unified list of DNS servers ordered + according to "current network conditions". Currently, c-ares will then + try to use them in whatever order the nested enumeration produces, which + may result in DNS requests being sent to servers on one interface + (hosting the current default route, for example) that are only intended + to be used via another interface (intended to be used when the first + interface is not available, for example). This, in turn, can lead to + spurious failures and timeouts simply because of the server address + order that resulted because of the enumeration process. + + This patch makes the (safe?) assumption that there is no other better + rule to chose which interface's DNS server list should be prioritized. + After all, a DNS lookup isn't something "per network"; applications + don't look up "these DNS names on this interface and those DNS names on + that interface". There is a single resource pool of DNS servers and the + application should presume that any server will give it the "right" + answer. However, even if all DNS servers are assumed to give equally + useful responses, it is reasonable to expect that some DNS servers will + not accept requests on all interfaces. This patch avoids the problem by + sorting the DNS server addresses using the Windows IPv4/v6 routing tables. + + For example, a request to DNS server C on interface 2 that is actually + sent over interface 1 (which may happen to have the default route) may + be rejected by or not delivered to DNS server C. So, better to use DNS + servers A and B associated with interface 1, at least as a first try. + + By using the metric of the route to the DNS server itself as a proxy for + priority of the DNS server in the list, this patch is able to adapt + dynamically to changes in the interface list, the DNS server lists per + interface, which interfaces are active, the routing table, and so on, + while always picking a good "best" DNS server first. + + In cases where any DNS server on any interface will do, this patch still + seems useful because it will prioritize a lower-metric route's (and thus + interface's) servers. + +David Drysdale (22 Feb 2017) +- [Sergii Pylypenko brought this change] + + docs: fixed references to ares_set_local_ip4 and ares_set_local_ip6 + +- [Calle Wilund brought this change] + + ares test: fix win32 build errors with virtual socket function tests + + The added api requires both some typedefs not previously imported + into the test build + the test code did not fully deal with + socket differences on windows. + +- [Calle Wilund brought this change] + + ares_process: fix return type of socket_create function (win32 warning) + +Daniel Stenberg (31 Jan 2017) +- [Calle Wilund brought this change] + + ares_set_socket_functions: Add man page + + Providing some rudimentary documentation for the added functionality + + Closes #72 + +- [Calle Wilund brought this change] + + ares-test: Add test helpers and cases for virtual socket IO + + * Added test case macro to automatically run tests twice, once "normal", + once with virtual IO. + * Changed most "live" query tests to run in dual mode to verify + at least simple socket IO via virtual functions + * Added test case for settings/duping socket functions & callback data + +- [elcallio brought this change] + + Implement using virtual socket IO functions when set + + Uses virtual socket IO functions when set on a channel. + Note that no socket options are set, nor is any binding + done by the library in this case, since the client defining + these is probably more suited to deal with this. + +- [elcallio brought this change] + + Add virtual function set for socket IO + + Defines a structure of basic create, close, read/write + functions as virtual function calls, settable for individual + c-ares channels. + +David Drysdale (30 Jan 2017) +- test: ignore aresfuzzname binary + +Gregor Jasny (14 Jan 2017) +- [Stephen Sorley brought this change] + + Always use check_symbol_exists instead of check_function_exists. + +- Also add includes to TARGETS_INST_DEST + +- [Stephen Sorley brought this change] + + Windows build fixes + +- CMake: Export targets + +- CMake: Use GNUInstallDirs for install location defaults + +David Drysdale (11 Jan 2017) +- Update Makefile.am for renamed INSTALL.md + +GitHub (11 Jan 2017) +- [David Drysdale brought this change] + + docs: convert INSTALL to MarkDown & tweak (#83) + +- [Gregor Jasny brought this change] + + Merge pull request #77 from stephen-sorley/cmake_modernize + + Updated CMake minimum version to 2.8.12. + +Stephen Sorley (4 Jan 2017) +- Changed executables to depend directly on internal libcares target, instead of against + the external-facing alias targets. + +- Updated Travis to pull CMake 2.8.12 from kubuntu-backports ppa. + +- Updated CMake minimum version to 2.8.12. + + Changed the way usage requirements (include dirs, compile defs, dependent libraries) are specified, to match the recommended standard practice for modern CMake. This involves using target-specific functions (target_include_directories, target_compile_definitions, etc.), along with the PUBLIC, PRIVATE or INTERFACE modifiers. + + Updated chain-building support to imitate new-style Find modules (import libs), instead of old-style Find modules (cache variables). + +David Drysdale (26 Dec 2016) +- [Chris Araman brought this change] + + configure: clock_gettime workaround (#75) + + Commits 7518c26, c41726b, and bc14ee7 brought this workaround to the CMake build system. This expands it to the autoconf build system. + + Fixes #71 + +- test: add fuzz entrypoint for ares_create_query() + +- test: Add gTest/gMock files to SOURCES + + Built tarballs are not including all of the files needed + to build the test suite because they are missing from the + <target>_SOURCES variable in Makefile.am. + +- travis: Move build scripts under travis/ + + Travis doesn't always propagate errors in inline multi-line + scripts, so move them all to be explicit shell scripts, each + with set -e. + +- travis: check distributed tarball builds + +Daniel Stenberg (25 Oct 2016) +- dist: ship msvc_ver.inc too + + Reported-by: Bruce Stephens + + Fixes #69 + +- [Aaron Bieber brought this change] + + fix build on OpenBSD + +- ares_version.h: bump, working on 1.12.1 now + +GitHub (18 Oct 2016) +- [Gregor Jasny brought this change] + + Merge pull request #64 from bradh352/master + + Add CMake build system support to C-Ares. + +Brad House (5 Oct 2016) +- suggested PROJECT_NAME change broke chain building as it needs the magic PROJECT_NAME set in the ADD_LIBRARY for matching. Fix to make both goals work + +- update MacOSX 10.12 detection + +- Expand XCode clock_gettime fix to include MacOS 10.12, not just iOS10 + +David Drysdale (4 Oct 2016) +- Revert "travis: work around bug in PyCParser" + + This reverts commit a24a10a348fc00b8cfd684d91894a1df14880ea9. + +- travis: work around bug in PyCParser + + See https://github.com/pyca/cryptography/issues/3187 + +Brad House (3 Oct 2016) +- PROJECT_SOURCE_DIR instead of CMAKE_CURRENT_SOURCE_DIR as per @gjasny + +- use a project name of c-ares as per @gjasny + +- Import curl conversion of Makefile.inc to cmake form dynamically as per bdoetsch@ameritech.net to make maintaining multiple build systems easier + +Daniel Stenberg (30 Sep 2016) +- dist: add ares_library_initialized.* to the tarball + +David Drysdale (30 Sep 2016) +- test: check ares_create_query with too-long name + +Daniel Stenberg (30 Sep 2016) +- man pages: minor formatting edits + +Brad House (29 Sep 2016) +- merge fc7917e from @daviddrysdale ... travis build updates for cmake + +- cleanups as per @gjasny ... Use naked IF statements and use NOT DEFINED + +Version 1.12.0 (29 Sep 2016) + +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 + +Brad House (29 Sep 2016) +- CMake: Unify library versioning with the libtool methodology to make keeping library versions in sync easier with the autotools build system + +Daniel Stenberg (29 Sep 2016) +- 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 + +Brad House (28 Sep 2016) +- XCode v8 introduced clock_gettime() for iOS v10. However, it is a weak symbol, which means when earlier iOS versions try to use clock_gettime() it results in a crash due to the missing symbol. Detect this condition and do not set HAVE_CLOCK_GETTIME_MONOTONIC. + +- Adds cmake build system support to C-Ares. + + The patch does not modify any source files, it only adds 3 new files + (CMakelists.txt, ares_build.h.cmake, ares_config.h.cmake) which form the + build system. I've tried to go through as much of the autotools tests and + extracted what I thought was appropriate, though many of the tests aren't + as in-depth in CMake as they are for autotools ... it is unclear why some + of them exist at all, I'm guessing for legacy systems that CMake probably + doesn't support anyhow. + + Building the library, and examples (adig, ahost, acountry) plus installation + should work across a large number of tested platforms. The tests have not + yet been integrated. + +Daniel Stenberg (27 Sep 2016) +- 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) diff --git a/contrib/libs/c-ares/INSTALL.md b/contrib/libs/c-ares/INSTALL.md index cbf1fc8f9b..e8a36773e4 100644 --- a/contrib/libs/c-ares/INSTALL.md +++ b/contrib/libs/c-ares/INSTALL.md @@ -1,415 +1,415 @@ ** This file is adapted from libcurl and not yet fully rewritten for c-ares! ** -``` - ___ __ _ _ __ ___ ___ +``` + ___ __ _ _ __ ___ ___ / __| ___ / _` | '__/ _ \/ __| | (_ |___| (_| | | | __/\__ \ \___| \__,_|_| \___||___/ How To Compile -``` +``` Installing Binary Packages ========================== -Lots of people download binary distributions of c-ares. This document -does not describe how to install c-ares using such a binary package. -This document describes how to compile, build and install c-ares from -source code. +Lots of people download binary distributions of c-ares. This document +does not describe how to install c-ares using such a binary package. +This document describes how to compile, build and install c-ares from +source code. -Building from Git +Building from Git ================= -If you get your code off a Git repository rather than an official -release tarball, see the [GIT-INFO](GIT-INFO) file in the root directory -for specific instructions on how to proceed. +If you get your code off a Git repository rather than an official +release tarball, see the [GIT-INFO](GIT-INFO) file in the root directory +for specific instructions on how to proceed. -In particular, if not using CMake you will need to run `./buildconf` (Unix) or -`buildconf.bat` (Windows) to generate build files, and for the former -you will need a local installation of Autotools. If using CMake the steps are -the same for both Git and official release tarballs. +In particular, if not using CMake you will need to run `./buildconf` (Unix) or +`buildconf.bat` (Windows) to generate build files, and for the former +you will need a local installation of Autotools. If using CMake the steps are +the same for both Git and official release tarballs. -AutoTools Build -=============== +AutoTools Build +=============== -### General Information, works on most Unix Platforms (Linux, FreeBSD, etc) +### General Information, works on most Unix Platforms (Linux, FreeBSD, etc) -A normal Unix installation is made in three or four steps (after you've -unpacked the source archive): +A normal Unix installation is made in three or four steps (after you've +unpacked the source archive): - ./configure - make - make ahost adig acountry (optional) - make install + ./configure + make + make ahost adig acountry (optional) + make install -You probably need to be root when doing the last command. +You probably need to be root when doing the last command. -If you have checked out the sources from the git repository, read the -[GIT-INFO](GIT_INFO) on how to proceed. +If you have checked out the sources from the git repository, read the +[GIT-INFO](GIT_INFO) on how to proceed. -Get a full listing of all available configure options by invoking it like: +Get a full listing of all available configure options by invoking it like: - ./configure --help + ./configure --help -If you want to install c-ares in a different file hierarchy than /usr/local, -you need to specify that already when running configure: +If you want to install c-ares in a different file hierarchy than /usr/local, +you need to specify that already when running configure: - ./configure --prefix=/path/to/c-ares/tree + ./configure --prefix=/path/to/c-ares/tree -If you happen to have write permission in that directory, you can do `make -install` without being root. An example of this would be to make a local -install in your own home directory: +If you happen to have write permission in that directory, you can do `make +install` without being root. An example of this would be to make a local +install in your own home directory: - ./configure --prefix=$HOME - make - make install + ./configure --prefix=$HOME + make + make install -### More Options +### More Options -To force configure to use the standard cc compiler if both cc and gcc are -present, run configure like +To force configure to use the standard cc compiler if both cc and gcc are +present, run configure like - CC=cc ./configure - # or - env CC=cc ./configure + CC=cc ./configure + # or + env CC=cc ./configure -To force a static library compile, disable the shared library creation -by running configure like: +To force a static library compile, disable the shared library creation +by running configure like: - ./configure --disable-shared + ./configure --disable-shared -If you're a c-ares developer and use gcc, you might want to enable more -debug options with the `--enable-debug` option. +If you're a c-ares developer and use gcc, you might want to enable more +debug options with the `--enable-debug` option. -### Special Cases +### Special Cases -Some versions of uClibc require configuring with `CPPFLAGS=-D_GNU_SOURCE=1` -to get correct large file support. +Some versions of uClibc require configuring with `CPPFLAGS=-D_GNU_SOURCE=1` +to get correct large file support. -The Open Watcom C compiler on Linux requires configuring with the variables: +The Open Watcom C compiler on Linux requires configuring with the variables: - ./configure CC=owcc AR="$WATCOM/binl/wlib" AR_FLAGS=-q \ - RANLIB=/bin/true STRIP="$WATCOM/binl/wstrip" CFLAGS=-Wextra + ./configure CC=owcc AR="$WATCOM/binl/wlib" AR_FLAGS=-q \ + RANLIB=/bin/true STRIP="$WATCOM/binl/wstrip" CFLAGS=-Wextra -### CROSS COMPILE +### CROSS COMPILE -(This section was graciously brought to us by Jim Duey, with additions by -Dan Fandrich) +(This section was graciously brought to us by Jim Duey, with additions by +Dan Fandrich) -Download and unpack the c-ares package. +Download and unpack the c-ares package. -`cd` to the new directory. (e.g. `cd c-ares-1.7.6`) +`cd` to the new directory. (e.g. `cd c-ares-1.7.6`) -Set environment variables to point to the cross-compile toolchain and call -configure with any options you need. Be sure and specify the `--host` and -`--build` parameters at configuration time. The following script is an -example of cross-compiling for the IBM 405GP PowerPC processor using the -toolchain from MonteVista for Hardhat Linux. +Set environment variables to point to the cross-compile toolchain and call +configure with any options you need. Be sure and specify the `--host` and +`--build` parameters at configuration time. The following script is an +example of cross-compiling for the IBM 405GP PowerPC processor using the +toolchain from MonteVista for Hardhat Linux. -```sh -#! /bin/sh +```sh +#! /bin/sh -export PATH=$PATH:/opt/hardhat/devkit/ppc/405/bin -export CPPFLAGS="-I/opt/hardhat/devkit/ppc/405/target/usr/include" -export AR=ppc_405-ar -export AS=ppc_405-as -export LD=ppc_405-ld -export RANLIB=ppc_405-ranlib -export CC=ppc_405-gcc -export NM=ppc_405-nm +export PATH=$PATH:/opt/hardhat/devkit/ppc/405/bin +export CPPFLAGS="-I/opt/hardhat/devkit/ppc/405/target/usr/include" +export AR=ppc_405-ar +export AS=ppc_405-as +export LD=ppc_405-ld +export RANLIB=ppc_405-ranlib +export CC=ppc_405-gcc +export NM=ppc_405-nm -./configure --target=powerpc-hardhat-linux \ - --host=powerpc-hardhat-linux \ - --build=i586-pc-linux-gnu \ - --prefix=/opt/hardhat/devkit/ppc/405/target/usr/local \ - --exec-prefix=/usr/local -``` +./configure --target=powerpc-hardhat-linux \ + --host=powerpc-hardhat-linux \ + --build=i586-pc-linux-gnu \ + --prefix=/opt/hardhat/devkit/ppc/405/target/usr/local \ + --exec-prefix=/usr/local +``` -You may also need to provide a parameter like `--with-random=/dev/urandom` -to configure as it cannot detect the presence of a random number -generating device for a target system. The `--prefix` parameter -specifies where c-ares will be installed. If `configure` completes -successfully, do `make` and `make install` as usual. +You may also need to provide a parameter like `--with-random=/dev/urandom` +to configure as it cannot detect the presence of a random number +generating device for a target system. The `--prefix` parameter +specifies where c-ares will be installed. If `configure` completes +successfully, do `make` and `make install` as usual. -In some cases, you may be able to simplify the above commands to as -little as: +In some cases, you may be able to simplify the above commands to as +little as: - ./configure --host=ARCH-OS + ./configure --host=ARCH-OS -### Cygwin (Windows) +### Cygwin (Windows) -Almost identical to the unix installation. Run the configure script in the -c-ares root with `sh configure`. Make sure you have the sh executable in -`/bin/` or you'll see the configure fail toward the end. +Almost identical to the unix installation. Run the configure script in the +c-ares root with `sh configure`. Make sure you have the sh executable in +`/bin/` or you'll see the configure fail toward the end. -Run `make` +Run `make` -### QNX +### QNX -(This section was graciously brought to us by David Bentham) +(This section was graciously brought to us by David Bentham) -As QNX is targeted for resource constrained environments, the QNX headers -set conservative limits. This includes the `FD_SETSIZE` macro, set by default -to 32. Socket descriptors returned within the c-ares library may exceed this, -resulting in memory faults/SIGSEGV crashes when passed into `select(..)` -calls using `fd_set` macros. +As QNX is targeted for resource constrained environments, the QNX headers +set conservative limits. This includes the `FD_SETSIZE` macro, set by default +to 32. Socket descriptors returned within the c-ares library may exceed this, +resulting in memory faults/SIGSEGV crashes when passed into `select(..)` +calls using `fd_set` macros. -A good all-round solution to this is to override the default when building -c-ares, by overriding `CFLAGS` during configure, example: +A good all-round solution to this is to override the default when building +c-ares, by overriding `CFLAGS` during configure, example: - # configure CFLAGS='-DFD_SETSIZE=64 -g -O2' + # configure CFLAGS='-DFD_SETSIZE=64 -g -O2' -### RISC OS +### RISC OS -The library can be cross-compiled using gccsdk as follows: +The library can be cross-compiled using gccsdk as follows: - CC=riscos-gcc AR=riscos-ar RANLIB='riscos-ar -s' ./configure \ - --host=arm-riscos-aof --without-random --disable-shared - make + CC=riscos-gcc AR=riscos-ar RANLIB='riscos-ar -s' ./configure \ + --host=arm-riscos-aof --without-random --disable-shared + make -where `riscos-gcc` and `riscos-ar` are links to the gccsdk tools. -You can then link your program with `c-ares/lib/.libs/libcares.a`. +where `riscos-gcc` and `riscos-ar` are links to the gccsdk tools. +You can then link your program with `c-ares/lib/.libs/libcares.a`. -### Android +### Android -Method using a configure cross-compile (tested with Android NDK r7b): +Method using a configure cross-compile (tested with Android NDK r7b): - - prepare the toolchain of the Android NDK for standalone use; this can - be done by invoking the script: + - prepare the toolchain of the Android NDK for standalone use; this can + be done by invoking the script: - ./tools/make-standalone-toolchain.sh + ./tools/make-standalone-toolchain.sh - which creates a usual cross-compile toolchain. Lets assume that you put - this toolchain below `/opt` then invoke configure with something - like: + which creates a usual cross-compile toolchain. Lets assume that you put + this toolchain below `/opt` then invoke configure with something + like: - ``` - export PATH=/opt/arm-linux-androideabi-4.4.3/bin:$PATH - ./configure --host=arm-linux-androideabi [more configure options] + ``` + export PATH=/opt/arm-linux-androideabi-4.4.3/bin:$PATH + ./configure --host=arm-linux-androideabi [more configure options] make - ``` - - if you want to compile directly from our GIT repo you might run into - this issue with older automake stuff: - - ``` - checking host system type... - Invalid configuration `arm-linux-androideabi': - system `androideabi' not recognized - configure: error: /bin/sh ./config.sub arm-linux-androideabi failed - ``` - this issue can be fixed with using more recent versions of `config.sub` - and `config.guess` which can be obtained here: - http://git.savannah.gnu.org/gitweb/?p=config.git;a=tree - you need to replace your system-own versions which usually can be - found in your automake folder: - `find /usr -name config.sub` - - -CMake builds -============ - -Current releases of c-ares introduce a CMake v3+ build system that has been -tested on most platforms including Windows, Linux, FreeBSD, MacOS, AIX and -Solaris. - -In the most basic form, building with CMake might look like: - -```sh -cd /path/to/cmake/source -mkdir build -cd build -cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local/cares .. -make -sudo make install -``` - -Options -------- - -Options to CMake are passed on the command line using "-D${OPTION}=${VALUE}". -The values defined are all boolean and take values like On, Off, True, False. - -* CARES_STATIC - Build the static library (off by default) -* CARES_SHARED - Build the shared library (on by default) -* CARES_INSTALL - Hook in installation, useful to disable if chain building -* CARES_STATIC_PIC - Build the static library as position-independent (off by - default) - - -Ninja ------ - -Ninja is the next-generation build system meant for generators like CMake that -heavily parallize builds. Its use is very similar to the normal build: - -```sh -cd /path/to/cmake/source -mkdir build -cd build -cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local/cares -G "Ninja" .. -ninja -sudo ninja install -``` - -Windows MSVC Command Line -------------------------- - -``` -cd \path\to\cmake\source -mkdir build -cd build -cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=C:\cares -G "NMake Makefiles" .. -nmake -nmake install -``` - -Windows MinGW-w64 Command Line via MSYS ---------------------------------------- -``` -cd \path\to\cmake\source -mkdir build -cd build -cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=C:\cares -G "MSYS Makefiles" .. -make -make install -``` - - -Platform-specific build systems -=============================== - -Win32 ------ - -### Building Windows DLLs and C run-time (CRT) linkage issues - -As a general rule, building a DLL with static CRT linkage is highly -discouraged, and intermixing CRTs in the same app is something to -avoid at any cost. - -Reading and comprehension of Microsoft Knowledge Base articles -KB94248 and KB140584 is a must for any Windows developer. Especially -important is full understanding if you are not going to follow the -advice given above. - - - [KB94248](http://support.microsoft.com/kb/94248/en-us) - How To Use the C Run-Time - - - [KB140584](http://support.microsoft.com/kb/140584/en-us) - How to link with the correct C Run-Time (CRT) library - - - [KB190799](http://msdn.microsoft.com/en-us/library/ms235460) - Potential Errors Passing CRT Objects Across DLL Boundaries - -If your app is misbehaving in some strange way, or it is suffering -from memory corruption, before asking for further help, please try -first to rebuild every single library your app uses as well as your -app using the debug multithreaded dynamic C runtime. - - -### MingW32 - -Make sure that MinGW32's bin dir is in the search path, for example: - - set PATH=c:\mingw32\bin;%PATH% - -then run 'make -f Makefile.m32' in the root dir. - - -### MSVC 6 caveats - -If you use MSVC 6 it is required that you use the February 2003 edition PSDK: -http://www.microsoft.com/msdownload/platformsdk/sdkupdate/psdk-full.htm - - -### MSVC from command line - -Run the `vcvars32.bat` file to get a proper environment. The -`vcvars32.bat` file is part of the Microsoft development environment and -you may find it in `C:\Program Files\Microsoft Visual Studio\vc98\bin` -provided that you installed Visual C/C++ 6 in the default directory. - -Further details in [README.msvc](README.msvc) - - -### MSVC IDEs - -Details in [README.msvc](README.msvc) - - -### Important static c-ares usage note - -When building an application that uses the static c-ares library, you must -add `-DCARES_STATICLIB` to your `CFLAGS`. Otherwise the linker will look for -dynamic import symbols. - - -IBM OS/2 --------- - -Building under OS/2 is not much different from building under unix. -You need: - - - emx 0.9d - - GNU make - - GNU patch - - ksh - - GNU bison - - GNU file utilities - - GNU sed - - autoconf 2.13 - -If during the linking you get an error about `_errno` being an undefined -symbol referenced from the text segment, you need to add `-D__ST_MT_ERRNO__` -in your definitions. - -If you're getting huge binaries, probably your makefiles have the `-g` in -`CFLAGS`. - - -NetWare -------- - -To compile `libcares.a` / `libcares.lib` you need: - - - either any gcc / nlmconv, or CodeWarrior 7 PDK 4 or later. - - gnu make and awk running on the platform you compile on; - native Win32 versions can be downloaded from: - http://www.gknw.net/development/prgtools/ - - recent Novell LibC SDK available from: - http://developer.novell.com/ndk/libc.htm - - or recent Novell CLib SDK available from: - http://developer.novell.com/ndk/clib.htm - -Set a search path to your compiler, linker and tools; on Linux make -sure that the var `OSTYPE` contains the string 'linux'; set the var -`NDKBASE` to point to the base of your Novell NDK; and then type -`make -f Makefile.netware` from the top source directory; - - + ``` + - if you want to compile directly from our GIT repo you might run into + this issue with older automake stuff: + + ``` + checking host system type... + Invalid configuration `arm-linux-androideabi': + system `androideabi' not recognized + configure: error: /bin/sh ./config.sub arm-linux-androideabi failed + ``` + this issue can be fixed with using more recent versions of `config.sub` + and `config.guess` which can be obtained here: + http://git.savannah.gnu.org/gitweb/?p=config.git;a=tree + you need to replace your system-own versions which usually can be + found in your automake folder: + `find /usr -name config.sub` + + +CMake builds +============ + +Current releases of c-ares introduce a CMake v3+ build system that has been +tested on most platforms including Windows, Linux, FreeBSD, MacOS, AIX and +Solaris. + +In the most basic form, building with CMake might look like: + +```sh +cd /path/to/cmake/source +mkdir build +cd build +cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local/cares .. +make +sudo make install +``` + +Options +------- + +Options to CMake are passed on the command line using "-D${OPTION}=${VALUE}". +The values defined are all boolean and take values like On, Off, True, False. + +* CARES_STATIC - Build the static library (off by default) +* CARES_SHARED - Build the shared library (on by default) +* CARES_INSTALL - Hook in installation, useful to disable if chain building +* CARES_STATIC_PIC - Build the static library as position-independent (off by + default) + + +Ninja +----- + +Ninja is the next-generation build system meant for generators like CMake that +heavily parallize builds. Its use is very similar to the normal build: + +```sh +cd /path/to/cmake/source +mkdir build +cd build +cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local/cares -G "Ninja" .. +ninja +sudo ninja install +``` + +Windows MSVC Command Line +------------------------- + +``` +cd \path\to\cmake\source +mkdir build +cd build +cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=C:\cares -G "NMake Makefiles" .. +nmake +nmake install +``` + +Windows MinGW-w64 Command Line via MSYS +--------------------------------------- +``` +cd \path\to\cmake\source +mkdir build +cd build +cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=C:\cares -G "MSYS Makefiles" .. +make +make install +``` + + +Platform-specific build systems +=============================== + +Win32 +----- + +### Building Windows DLLs and C run-time (CRT) linkage issues + +As a general rule, building a DLL with static CRT linkage is highly +discouraged, and intermixing CRTs in the same app is something to +avoid at any cost. + +Reading and comprehension of Microsoft Knowledge Base articles +KB94248 and KB140584 is a must for any Windows developer. Especially +important is full understanding if you are not going to follow the +advice given above. + + - [KB94248](http://support.microsoft.com/kb/94248/en-us) - How To Use the C Run-Time + + - [KB140584](http://support.microsoft.com/kb/140584/en-us) - How to link with the correct C Run-Time (CRT) library + + - [KB190799](http://msdn.microsoft.com/en-us/library/ms235460) - Potential Errors Passing CRT Objects Across DLL Boundaries + +If your app is misbehaving in some strange way, or it is suffering +from memory corruption, before asking for further help, please try +first to rebuild every single library your app uses as well as your +app using the debug multithreaded dynamic C runtime. + + +### MingW32 + +Make sure that MinGW32's bin dir is in the search path, for example: + + set PATH=c:\mingw32\bin;%PATH% + +then run 'make -f Makefile.m32' in the root dir. + + +### MSVC 6 caveats + +If you use MSVC 6 it is required that you use the February 2003 edition PSDK: +http://www.microsoft.com/msdownload/platformsdk/sdkupdate/psdk-full.htm + + +### MSVC from command line + +Run the `vcvars32.bat` file to get a proper environment. The +`vcvars32.bat` file is part of the Microsoft development environment and +you may find it in `C:\Program Files\Microsoft Visual Studio\vc98\bin` +provided that you installed Visual C/C++ 6 in the default directory. + +Further details in [README.msvc](README.msvc) + + +### MSVC IDEs + +Details in [README.msvc](README.msvc) + + +### Important static c-ares usage note + +When building an application that uses the static c-ares library, you must +add `-DCARES_STATICLIB` to your `CFLAGS`. Otherwise the linker will look for +dynamic import symbols. + + +IBM OS/2 +-------- + +Building under OS/2 is not much different from building under unix. +You need: + + - emx 0.9d + - GNU make + - GNU patch + - ksh + - GNU bison + - GNU file utilities + - GNU sed + - autoconf 2.13 + +If during the linking you get an error about `_errno` being an undefined +symbol referenced from the text segment, you need to add `-D__ST_MT_ERRNO__` +in your definitions. + +If you're getting huge binaries, probably your makefiles have the `-g` in +`CFLAGS`. + + +NetWare +------- + +To compile `libcares.a` / `libcares.lib` you need: + + - either any gcc / nlmconv, or CodeWarrior 7 PDK 4 or later. + - gnu make and awk running on the platform you compile on; + native Win32 versions can be downloaded from: + http://www.gknw.net/development/prgtools/ + - recent Novell LibC SDK available from: + http://developer.novell.com/ndk/libc.htm + - or recent Novell CLib SDK available from: + http://developer.novell.com/ndk/clib.htm + +Set a search path to your compiler, linker and tools; on Linux make +sure that the var `OSTYPE` contains the string 'linux'; set the var +`NDKBASE` to point to the base of your Novell NDK; and then type +`make -f Makefile.netware` from the top source directory; + + PORTS ===== -This is a probably incomplete list of known hardware and operating systems -that c-ares has been compiled for. If you know a system c-ares compiles and -runs on, that isn't listed, please let us know! - - - Alpha Tru64 v5.0 5.1 - - ARM Android 1.5, 2.1, 2.3 - - MIPS IRIX 6.2, 6.5 - - Power AIX 3.2.5, 4.2, 4.3.1, 4.3.2, 5.1, 5.2 - - i386 Linux 1.3, 2.0, 2.2, 2.3, 2.4, 2.6 - - i386 Novell NetWare - - i386 Windows 95, 98, ME, NT, 2000, XP, 2003 - - x86_64 Linux - - +This is a probably incomplete list of known hardware and operating systems +that c-ares has been compiled for. If you know a system c-ares compiles and +runs on, that isn't listed, please let us know! + + - Alpha Tru64 v5.0 5.1 + - ARM Android 1.5, 2.1, 2.3 + - MIPS IRIX 6.2, 6.5 + - Power AIX 3.2.5, 4.2, 4.3.1, 4.3.2, 5.1, 5.2 + - i386 Linux 1.3, 2.0, 2.2, 2.3, 2.4, 2.6 + - i386 Novell NetWare + - i386 Windows 95, 98, ME, NT, 2000, XP, 2003 + - x86_64 Linux + + Useful URLs =========== - - c-ares: https://c-ares.haxx.se/ - - MingW: http://www.mingw.org/ - - MinGW-w64: http://mingw-w64.sourceforge.net/ - - OpenWatcom: http://www.openwatcom.org/ + - c-ares: https://c-ares.haxx.se/ + - MingW: http://www.mingw.org/ + - MinGW-w64: http://mingw-w64.sourceforge.net/ + - OpenWatcom: http://www.openwatcom.org/ diff --git a/contrib/libs/c-ares/LICENSE.md b/contrib/libs/c-ares/LICENSE.md index ad6bb52b72..40f31550a4 100644 --- a/contrib/libs/c-ares/LICENSE.md +++ b/contrib/libs/c-ares/LICENSE.md @@ -1,15 +1,15 @@ -# c-ares license - -Copyright (c) 2007 - 2018, 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 -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. +# c-ares license + +Copyright (c) 2007 - 2018, 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 +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. diff --git a/contrib/libs/c-ares/README.cares b/contrib/libs/c-ares/README.cares index 4dee46eabf..664f153907 100644 --- a/contrib/libs/c-ares/README.cares +++ b/contrib/libs/c-ares/README.cares @@ -1,15 +1,15 @@ c-ares ====== -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 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 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. +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 -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 +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/contrib/libs/c-ares/README.md b/contrib/libs/c-ares/README.md index 148338f9e1..7e4e282b00 100644 --- a/contrib/libs/c-ares/README.md +++ b/contrib/libs/c-ares/README.md @@ -1,22 +1,22 @@ c-ares ====== -[![Build Status](https://travis-ci.org/c-ares/c-ares.svg?branch=master)](https://travis-ci.org/c-ares/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/aevgc5914tm72pvs/branch/master?svg=true)](https://ci.appveyor.com/project/c-ares/c-ares/branch/master) -[![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) +[![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) [![Fuzzing Status](https://oss-fuzz-build-logs.storage.googleapis.com/badges/c-ares.svg)](https://bugs.chromium.org/p/oss-fuzz/issues/list?sort=-opened&can=1&q=proj:c-ares) -[![Releases](https://coderelease.io/badge/c-ares/c-ares)](https://coderelease.io/github/repository/c-ares/c-ares) - +[![Releases](https://coderelease.io/badge/c-ares/c-ares)](https://coderelease.io/github/repository/c-ares/c-ares) + 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 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](https://c-ares.haxx.se/download/), -and in a git repository: http://github.com/c-ares/c-ares. See the -[INSTALL.md](INSTALL.md) file for build information. +The full source code is available in the ['c-ares' release archives](https://c-ares.haxx.se/download/), +and in a git repository: http://github.com/c-ares/c-ares. See the +[INSTALL.md](INSTALL.md) file for build information. 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 @@ -26,34 +26,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: - https://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 to compile 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 @@ -64,4 +64,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. +* Try to keep line lengths below 80 columns. diff --git a/contrib/libs/c-ares/RELEASE-NOTES b/contrib/libs/c-ares/RELEASE-NOTES index 7a9d75fe78..c11eefeeb7 100644 --- a/contrib/libs/c-ares/RELEASE-NOTES +++ b/contrib/libs/c-ares/RELEASE-NOTES @@ -10,7 +10,7 @@ Changes: version.bind, version.server, authoris.bind, hostname.bind, and id.server. [3] -Bug fixes: +Bug fixes: o Fix Windows Unicode incompatibilities with ares_getaddrinfo() [1] o Silence false cast-align compiler warnings due to valid casts of struct sockaddr to struct sockaddr_in and struct sockaddr_in6. @@ -24,7 +24,7 @@ Thanks go to these friendly people for their efforts and contributions: Jann Horn, Shelly Vohr, Teemu R (@rytilahti) (6 contributors) -References to bug reports and discussions on issues: +References to bug reports and discussions on issues: [1] = https://github.com/c-ares/c-ares/pull/328 [2] = https://github.com/c-ares/c-ares/pull/323 [3] = https://github.com/c-ares/c-ares/pull/321 diff --git a/contrib/libs/c-ares/acountry.c b/contrib/libs/c-ares/acountry.c index c486824434..dea373aff7 100644 --- a/contrib/libs/c-ares/acountry.c +++ b/contrib/libs/c-ares/acountry.c @@ -15,7 +15,7 @@ * * Ref: http://countries.nerd.dk/more.html * - * Written by G. Vanem <gvanem@yahoo.no> 2006, 2007 + * Written by G. Vanem <gvanem@yahoo.no> 2006, 2007 * * NB! This program may not be big-endian aware. * @@ -76,8 +76,8 @@ static const char *usage = "acountry [-?hdv] {host|addr} ...\n"; static const char nerd_fmt[] = "%u.%u.%u.%u.zz.countries.nerd.dk"; -static const char *nerd_ver1 = nerd_fmt + 14; /* .countries.nerd.dk */ -static const char *nerd_ver2 = nerd_fmt + 11; /* .zz.countries.nerd.dk */ +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 { \ @@ -205,9 +205,9 @@ static void wait_ares(ares_channel channel) if (nfds == 0) break; tvp = ares_timeout(channel, NULL, &tv); - nfds = select(nfds, &read_fds, &write_fds, NULL, tvp); - if (nfds < 0) - continue; + nfds = select(nfds, &read_fds, &write_fds, NULL, tvp); + if (nfds < 0) + continue; ares_process(channel, &read_fds, &write_fds); } } @@ -278,7 +278,7 @@ static const struct search_list *list_lookup(int number, const struct search_lis */ static const struct search_list country_list[] = { { 4, "af", "Afghanistan" }, - { 248, "ax", "Åland Island" }, + { 248, "ax", "Åland Island" }, { 8, "al", "Albania" }, { 12, "dz", "Algeria" }, { 16, "as", "American Samoa" }, @@ -566,10 +566,10 @@ static void find_country_from_cname(const char *cname, struct in_addr addr) if (ver_1) { const char *dot = strchr(cname, '.'); - if (dot != cname+4) + if (dot != cname+4) { printf("Unexpected CNAME %s (ver_1)\n", cname); - free(ccopy); + free(ccopy); return; } } @@ -580,14 +580,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); + free(ccopy); return; } } else { printf("Unexpected CNAME %s (ver?)\n", cname); - free(ccopy); + free(ccopy); return; } diff --git a/contrib/libs/c-ares/ahost.c b/contrib/libs/c-ares/ahost.c index 89a7c14fcb..6bbf0a38c8 100644 --- a/contrib/libs/c-ares/ahost.c +++ b/contrib/libs/c-ares/ahost.c @@ -52,8 +52,8 @@ static void usage(void); int main(int argc, char **argv) { - struct ares_options options; - int optmask = 0; + struct ares_options options; + int optmask = 0; ares_channel channel; int status, nfds, c, addr_family = AF_INET; fd_set read_fds, write_fds; @@ -67,8 +67,8 @@ int main(int argc, char **argv) WSAStartup(wVersionRequested, &wsaData); #endif - memset(&options, 0, sizeof(options)); - + memset(&options, 0, sizeof(options)); + status = ares_library_init(ARES_LIB_INIT_ALL); if (status != ARES_SUCCESS) { @@ -76,7 +76,7 @@ int main(int argc, char **argv) return 1; } - while ((c = ares_getopt(argc,argv,"dt:hs:")) != -1) + while ((c = ares_getopt(argc,argv,"dt:hs:")) != -1) { switch (c) { @@ -85,20 +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 '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 if (!strcasecmp(optarg,"u")) + addr_family = AF_UNSPEC; else usage(); break; @@ -114,7 +114,7 @@ int main(int argc, char **argv) if (argc < 1) usage(); - status = ares_init_options(&channel, &options, optmask); + status = ares_init_options(&channel, &options, optmask); if (status != ARES_SUCCESS) { fprintf(stderr, "ares_init: %s\n", ares_strerror(status)); @@ -143,16 +143,16 @@ int main(int argc, char **argv) /* Wait for all queries to complete. */ for (;;) { - int res; + 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); - res = select(nfds, &read_fds, &write_fds, NULL, tvp); - if (-1 == res) - break; + res = select(nfds, &read_fds, &write_fds, NULL, tvp); + if (-1 == res) + break; ares_process(channel, &read_fds, &write_fds); } diff --git a/contrib/libs/c-ares/ares.h b/contrib/libs/c-ares/ares.h index 3f8a6954d0..4ce47e105c 100644 --- a/contrib/libs/c-ares/ares.h +++ b/contrib/libs/c-ares/ares.h @@ -38,8 +38,8 @@ require it! */ #if defined(_AIX) || defined(__NOVELL_LIBC__) || defined(__NetBSD__) || \ defined(__minix) || defined(__SYMBIAN32__) || defined(__INTEGRITY) || \ - defined(ANDROID) || defined(__ANDROID__) || defined(__OpenBSD__) || \ - defined(__QNXNTO__) + defined(ANDROID) || defined(__ANDROID__) || defined(__OpenBSD__) || \ + defined(__QNXNTO__) #include <sys/select.h> #endif #if (defined(NETWARE) && !defined(__NOVELL_LIBC__)) @@ -68,10 +68,10 @@ # include <netinet/in.h> #endif -#if defined(ANDROID) || defined(__ANDROID__) -#include <jni.h> -#endif - +#if defined(ANDROID) || defined(__ANDROID__) +#include <jni.h> +#endif + #ifdef __cplusplus extern "C" { #endif @@ -166,7 +166,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) +#define ARES_OPT_NOROTATE (1 << 16) #define ARES_OPT_RESOLVCONF (1 << 17) #define ARES_OPT_MAXTIMEOUTMS (1 << 18) #define ARES_OPT_JITTER (1 << 19) @@ -314,10 +314,10 @@ 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); - +typedef int (*ares_sock_config_callback)(ares_socket_t socket_fd, + int type, + void *data); + typedef void (*ares_addrinfo_callback)(void *arg, int status, int timeouts, @@ -325,19 +325,19 @@ typedef void (*ares_addrinfo_callback)(void *arg, 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)); - -#if defined(ANDROID) || defined(__ANDROID__) -CARES_EXTERN void ares_library_init_jvm(JavaVM *jvm); -CARES_EXTERN int ares_library_init_android(jobject connectivity_manager); -CARES_EXTERN int ares_library_android_initialized(void); -#endif - -CARES_EXTERN int ares_library_initialized(void); - +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)); + +#if defined(ANDROID) || defined(__ANDROID__) +CARES_EXTERN void ares_library_init_jvm(JavaVM *jvm); +CARES_EXTERN int ares_library_init_android(jobject connectivity_manager); +CARES_EXTERN int ares_library_android_initialized(void); +#endif + +CARES_EXTERN int ares_library_initialized(void); + CARES_EXTERN void ares_library_cleanup(void); CARES_EXTERN const char *ares_version(int *version); @@ -379,13 +379,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_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_getaddrinfo(ares_channel channel, const char* node, const char* service, @@ -395,27 +395,27 @@ CARES_EXTERN void ares_getaddrinfo(ares_channel channel, CARES_EXTERN void ares_freeaddrinfo(struct ares_addrinfo* ai); -/* - * Virtual function set to have user-managed socket IO. - * Note that all functions need to be defined, and when - * set, the library will not do any bind nor set any - * socket options, assuming the client handles these - * through either socket creation or the - * ares_sock_config_callback call. - */ -struct iovec; -struct ares_socket_functions { - ares_socket_t(*asocket)(int, int, int, void *); - int(*aclose)(ares_socket_t, void *); - int(*aconnect)(ares_socket_t, const struct sockaddr *, ares_socklen_t, void *); - ares_ssize_t(*arecvfrom)(ares_socket_t, void *, size_t, int, struct sockaddr *, ares_socklen_t *, void *); - ares_ssize_t(*asendv)(ares_socket_t, const struct iovec *, int, void *); -}; - -CARES_EXTERN void ares_set_socket_functions(ares_channel channel, - const struct ares_socket_functions * funcs, - void *user_data); - +/* + * Virtual function set to have user-managed socket IO. + * Note that all functions need to be defined, and when + * set, the library will not do any bind nor set any + * socket options, assuming the client handles these + * through either socket creation or the + * ares_sock_config_callback call. + */ +struct iovec; +struct ares_socket_functions { + ares_socket_t(*asocket)(int, int, int, void *); + int(*aclose)(ares_socket_t, void *); + int(*aconnect)(ares_socket_t, const struct sockaddr *, ares_socklen_t, void *); + ares_ssize_t(*arecvfrom)(ares_socket_t, void *, size_t, int, struct sockaddr *, ares_socklen_t *, void *); + ares_ssize_t(*asendv)(ares_socket_t, const struct iovec *, int, void *); +}; + +CARES_EXTERN void ares_set_socket_functions(ares_channel channel, + const struct ares_socket_functions * funcs, + void *user_data); + CARES_EXTERN void ares_send(ares_channel channel, const unsigned char *qbuf, int qlen, @@ -539,35 +539,35 @@ struct ares_srv_reply { unsigned short priority; unsigned short weight; unsigned short port; - int ttl; + int ttl; }; struct ares_mx_reply { struct ares_mx_reply *next; char *host; unsigned short priority; - int ttl; + int ttl; }; struct ares_txt_reply { struct ares_txt_reply *next; unsigned char *txt; size_t length; /* length excludes null termination */ - int ttl; -}; - -/* 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; - int ttl; + int ttl; }; +/* 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; + int ttl; +}; + struct ares_naptr_reply { struct ares_naptr_reply *next; unsigned char *flags; @@ -576,7 +576,7 @@ struct ares_naptr_reply { char *replacement; unsigned short order; unsigned short preference; - int ttl; + int ttl; }; struct ares_soa_reply { @@ -587,7 +587,7 @@ struct ares_soa_reply { unsigned int retry; unsigned int expire; unsigned int minttl; - int ttl; + int ttl; }; /* @@ -653,8 +653,8 @@ CARES_EXTERN int ares_parse_ptr_reply(const unsigned char *abuf, const void *addr, int addrlen, int family, - struct hostent **host, - int *hostttl); + struct hostent **host, + int *hostttl); CARES_EXTERN int ares_parse_ns_reply(const unsigned char *abuf, int alen, @@ -672,10 +672,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_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); @@ -701,32 +701,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; -}; - +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); +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_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 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/contrib/libs/c-ares/ares__close_sockets.c b/contrib/libs/c-ares/ares__close_sockets.c index 0477174e3e..bd77a4fac0 100644 --- a/contrib/libs/c-ares/ares__close_sockets.c +++ b/contrib/libs/c-ares/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) - ares_free(sendreq->data_storage); - ares_free(sendreq); + ares_free(sendreq->data_storage); + ares_free(sendreq); } server->qtail = NULL; /* Reset any existing input buffer. */ if (server->tcp_buffer) - ares_free(server->tcp_buffer); + ares_free(server->tcp_buffer); server->tcp_buffer = NULL; server->tcp_lenbuf_pos = 0; diff --git a/contrib/libs/c-ares/ares__get_hostent.c b/contrib/libs/c-ares/ares__get_hostent.c index 367f39037b..f9e19ce221 100644 --- a/contrib/libs/c-ares/ares__get_hostent.c +++ b/contrib/libs/c-ares/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; /* LCOV_EXCL_LINE: trailing whitespace already stripped */ + continue; /* LCOV_EXCL_LINE: trailing whitespace already stripped */ /* Pointer to start of host name. */ txthost = p; @@ -163,7 +163,7 @@ int ares__get_hostent(FILE *fp, int family, struct hostent **host) */ /* Allocate memory for the hostent structure. */ - hostent = ares_malloc(sizeof(struct hostent)); + hostent = ares_malloc(sizeof(struct hostent)); if (!hostent) break; @@ -172,16 +172,16 @@ int ares__get_hostent(FILE *fp, int family, struct hostent **host) hostent->h_addr_list = NULL; /* Copy official host name. */ - hostent->h_name = ares_strdup(txthost); + hostent->h_name = ares_strdup(txthost); if (!hostent->h_name) break; /* Copy network address. */ - hostent->h_addr_list = ares_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] = ares_malloc(addrlen); + hostent->h_addr_list[0] = ares_malloc(addrlen); if (!hostent->h_addr_list[0]) break; if (addr.family == AF_INET) @@ -190,7 +190,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 = ares_malloc((naliases + 1) * sizeof(char *)); + hostent->h_aliases = ares_malloc((naliases + 1) * sizeof(char *)); if (!hostent->h_aliases) break; alias = hostent->h_aliases; @@ -206,7 +206,7 @@ int ares__get_hostent(FILE *fp, int family, struct hostent **host) while (*q && ISSPACE(*q)) q++; *p = '\0'; - if ((*alias = ares_strdup(txtalias)) == NULL) + if ((*alias = ares_strdup(txtalias)) == NULL) break; alias++; txtalias = *q ? q : NULL; @@ -220,7 +220,7 @@ int ares__get_hostent(FILE *fp, int family, struct hostent **host) hostent->h_length = aresx_uztoss(addrlen); /* Free line buffer. */ - ares_free(line); + ares_free(line); /* Return hostent successfully */ *host = hostent; @@ -230,7 +230,7 @@ int ares__get_hostent(FILE *fp, int family, struct hostent **host) /* If allocated, free line buffer. */ if (line) - ares_free(line); + ares_free(line); if (status == ARES_SUCCESS) { @@ -238,20 +238,20 @@ int ares__get_hostent(FILE *fp, int family, struct hostent **host) if (hostent) { if (hostent->h_name) - ares_free((char *) hostent->h_name); + ares_free((char *) hostent->h_name); if (hostent->h_aliases) { for (alias = hostent->h_aliases; *alias; alias++) - ares_free(*alias); - ares_free(hostent->h_aliases); + ares_free(*alias); + ares_free(hostent->h_aliases); } if (hostent->h_addr_list) { if (hostent->h_addr_list[0]) - ares_free(hostent->h_addr_list[0]); - ares_free(hostent->h_addr_list); + ares_free(hostent->h_addr_list[0]); + ares_free(hostent->h_addr_list); } - ares_free(hostent); + ares_free(hostent); } return ARES_ENOMEM; } diff --git a/contrib/libs/c-ares/ares__read_line.c b/contrib/libs/c-ares/ares__read_line.c index c62ad2a2b4..008b5155b5 100644 --- a/contrib/libs/c-ares/ares__read_line.c +++ b/contrib/libs/c-ares/ares__read_line.c @@ -36,7 +36,7 @@ int ares__read_line(FILE *fp, char **buf, size_t *bufsize) if (*buf == NULL) { - *buf = ares_malloc(128); + *buf = ares_malloc(128); if (!*buf) return ARES_ENOMEM; *bufsize = 128; @@ -59,13 +59,13 @@ int ares__read_line(FILE *fp, char **buf, size_t *bufsize) continue; /* Allocate more space. */ - newbuf = ares_realloc(*buf, *bufsize * 2); + newbuf = ares_realloc(*buf, *bufsize * 2); if (!newbuf) - { - ares_free(*buf); - *buf = NULL; - return ARES_ENOMEM; - } + { + ares_free(*buf); + *buf = NULL; + return ARES_ENOMEM; + } *buf = newbuf; *bufsize *= 2; } diff --git a/contrib/libs/c-ares/ares__timeval.c b/contrib/libs/c-ares/ares__timeval.c index 94efb7db1e..18e7960017 100644 --- a/contrib/libs/c-ares/ares__timeval.c +++ b/contrib/libs/c-ares/ares__timeval.c @@ -56,7 +56,7 @@ struct timeval ares__tvnow(void) */ #ifdef HAVE_GETTIMEOFDAY else - (void)gettimeofday(&now, NULL); /* LCOV_EXCL_LINE */ + (void)gettimeofday(&now, NULL); /* LCOV_EXCL_LINE */ #else else { now.tv_sec = (long)time(NULL); diff --git a/contrib/libs/c-ares/ares_android.c b/contrib/libs/c-ares/ares_android.c index 5b00b8065c..4690fa8d50 100644 --- a/contrib/libs/c-ares/ares_android.c +++ b/contrib/libs/c-ares/ares_android.c @@ -1,356 +1,356 @@ -/* Copyright (C) 2017 by John Schember <john@nachtimwald.com> - * - * 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. - */ -#if defined(ANDROID) || defined(__ANDROID__) - -#include <jni.h> - -#include "ares_setup.h" -#include "ares.h" -#include "ares_android.h" -#include "ares_private.h" - -static JavaVM *android_jvm = NULL; -static jobject android_connectivity_manager = NULL; - -/* ConnectivityManager.getActiveNetwork */ -static jmethodID android_cm_active_net_mid = NULL; -/* ConnectivityManager.getLinkProperties */ -static jmethodID android_cm_link_props_mid = NULL; -/* LinkProperties.getDnsServers */ -static jmethodID android_lp_dns_servers_mid = NULL; +/* Copyright (C) 2017 by John Schember <john@nachtimwald.com> + * + * 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. + */ +#if defined(ANDROID) || defined(__ANDROID__) + +#include <jni.h> + +#include "ares_setup.h" +#include "ares.h" +#include "ares_android.h" +#include "ares_private.h" + +static JavaVM *android_jvm = NULL; +static jobject android_connectivity_manager = NULL; + +/* ConnectivityManager.getActiveNetwork */ +static jmethodID android_cm_active_net_mid = NULL; +/* ConnectivityManager.getLinkProperties */ +static jmethodID android_cm_link_props_mid = NULL; +/* LinkProperties.getDnsServers */ +static jmethodID android_lp_dns_servers_mid = NULL; /* LinkProperties.getDomains */ static jmethodID android_lp_domains_mid = NULL; -/* List.size */ -static jmethodID android_list_size_mid = NULL; -/* List.get */ -static jmethodID android_list_get_mid = NULL; -/* InetAddress.getHostAddress */ -static jmethodID android_ia_host_addr_mid = NULL; - -static jclass jni_get_class(JNIEnv *env, const char *path) -{ - jclass cls = NULL; - - if (env == NULL || path == NULL || *path == '\0') - return NULL; - - cls = (*env)->FindClass(env, path); - if ((*env)->ExceptionOccurred(env)) { - (*env)->ExceptionClear(env); - return NULL; - } - return cls; -} - -static jmethodID jni_get_method_id(JNIEnv *env, jclass cls, - const char *func_name, const char *signature) -{ - jmethodID mid = NULL; - - if (env == NULL || cls == NULL || func_name == NULL || *func_name == '\0' || - signature == NULL || *signature == '\0') - { - return NULL; - } - - mid = (*env)->GetMethodID(env, cls, func_name, signature); - if ((*env)->ExceptionOccurred(env)) - { - (*env)->ExceptionClear(env); - return NULL; - } - - return mid; -} - -void ares_library_init_jvm(JavaVM *jvm) -{ - android_jvm = jvm; -} - -int ares_library_init_android(jobject connectivity_manager) -{ - JNIEnv *env = NULL; - int need_detatch = 0; - int res; - int ret = ARES_ENOTINITIALIZED; - jclass obj_cls = NULL; - - if (android_jvm == NULL) - goto cleanup; - - res = (*android_jvm)->GetEnv(android_jvm, (void **)&env, JNI_VERSION_1_6); - if (res == JNI_EDETACHED) - { - env = NULL; - res = (*android_jvm)->AttachCurrentThread(android_jvm, &env, NULL); - need_detatch = 1; - } - if (res != JNI_OK || env == NULL) - goto cleanup; - - android_connectivity_manager = - (*env)->NewGlobalRef(env, connectivity_manager); - if (android_connectivity_manager == NULL) - goto cleanup; - - /* Initialization has succeeded. Now attempt to cache the methods that will be - * called by ares_get_android_server_list. */ - ret = ARES_SUCCESS; - - /* ConnectivityManager in API 1. */ - obj_cls = jni_get_class(env, "android/net/ConnectivityManager"); - if (obj_cls == NULL) - goto cleanup; - - /* ConnectivityManager.getActiveNetwork in API 23. */ - android_cm_active_net_mid = - jni_get_method_id(env, obj_cls, "getActiveNetwork", - "()Landroid/net/Network;"); - if (android_cm_active_net_mid == NULL) - goto cleanup; - - /* ConnectivityManager.getLinkProperties in API 21. */ - android_cm_link_props_mid = - jni_get_method_id(env, obj_cls, "getLinkProperties", - "(Landroid/net/Network;)Landroid/net/LinkProperties;"); - if (android_cm_link_props_mid == NULL) - goto cleanup; - - /* LinkProperties in API 21. */ - (*env)->DeleteLocalRef(env, obj_cls); - obj_cls = jni_get_class(env, "android/net/LinkProperties"); - if (obj_cls == NULL) - goto cleanup; - - /* getDnsServers in API 21. */ - android_lp_dns_servers_mid = jni_get_method_id(env, obj_cls, "getDnsServers", - "()Ljava/util/List;"); - if (android_lp_dns_servers_mid == NULL) - goto cleanup; - +/* List.size */ +static jmethodID android_list_size_mid = NULL; +/* List.get */ +static jmethodID android_list_get_mid = NULL; +/* InetAddress.getHostAddress */ +static jmethodID android_ia_host_addr_mid = NULL; + +static jclass jni_get_class(JNIEnv *env, const char *path) +{ + jclass cls = NULL; + + if (env == NULL || path == NULL || *path == '\0') + return NULL; + + cls = (*env)->FindClass(env, path); + if ((*env)->ExceptionOccurred(env)) { + (*env)->ExceptionClear(env); + return NULL; + } + return cls; +} + +static jmethodID jni_get_method_id(JNIEnv *env, jclass cls, + const char *func_name, const char *signature) +{ + jmethodID mid = NULL; + + if (env == NULL || cls == NULL || func_name == NULL || *func_name == '\0' || + signature == NULL || *signature == '\0') + { + return NULL; + } + + mid = (*env)->GetMethodID(env, cls, func_name, signature); + if ((*env)->ExceptionOccurred(env)) + { + (*env)->ExceptionClear(env); + return NULL; + } + + return mid; +} + +void ares_library_init_jvm(JavaVM *jvm) +{ + android_jvm = jvm; +} + +int ares_library_init_android(jobject connectivity_manager) +{ + JNIEnv *env = NULL; + int need_detatch = 0; + int res; + int ret = ARES_ENOTINITIALIZED; + jclass obj_cls = NULL; + + if (android_jvm == NULL) + goto cleanup; + + res = (*android_jvm)->GetEnv(android_jvm, (void **)&env, JNI_VERSION_1_6); + if (res == JNI_EDETACHED) + { + env = NULL; + res = (*android_jvm)->AttachCurrentThread(android_jvm, &env, NULL); + need_detatch = 1; + } + if (res != JNI_OK || env == NULL) + goto cleanup; + + android_connectivity_manager = + (*env)->NewGlobalRef(env, connectivity_manager); + if (android_connectivity_manager == NULL) + goto cleanup; + + /* Initialization has succeeded. Now attempt to cache the methods that will be + * called by ares_get_android_server_list. */ + ret = ARES_SUCCESS; + + /* ConnectivityManager in API 1. */ + obj_cls = jni_get_class(env, "android/net/ConnectivityManager"); + if (obj_cls == NULL) + goto cleanup; + + /* ConnectivityManager.getActiveNetwork in API 23. */ + android_cm_active_net_mid = + jni_get_method_id(env, obj_cls, "getActiveNetwork", + "()Landroid/net/Network;"); + if (android_cm_active_net_mid == NULL) + goto cleanup; + + /* ConnectivityManager.getLinkProperties in API 21. */ + android_cm_link_props_mid = + jni_get_method_id(env, obj_cls, "getLinkProperties", + "(Landroid/net/Network;)Landroid/net/LinkProperties;"); + if (android_cm_link_props_mid == NULL) + goto cleanup; + + /* LinkProperties in API 21. */ + (*env)->DeleteLocalRef(env, obj_cls); + obj_cls = jni_get_class(env, "android/net/LinkProperties"); + if (obj_cls == NULL) + goto cleanup; + + /* getDnsServers in API 21. */ + android_lp_dns_servers_mid = jni_get_method_id(env, obj_cls, "getDnsServers", + "()Ljava/util/List;"); + if (android_lp_dns_servers_mid == NULL) + goto cleanup; + /* getDomains in API 21. */ android_lp_domains_mid = jni_get_method_id(env, obj_cls, "getDomains", "()Ljava/lang/String;"); if (android_lp_domains_mid == NULL) goto cleanup; - (*env)->DeleteLocalRef(env, obj_cls); - obj_cls = jni_get_class(env, "java/util/List"); - if (obj_cls == NULL) - goto cleanup; - - android_list_size_mid = jni_get_method_id(env, obj_cls, "size", "()I"); - if (android_list_size_mid == NULL) - goto cleanup; - - android_list_get_mid = jni_get_method_id(env, obj_cls, "get", - "(I)Ljava/lang/Object;"); - if (android_list_get_mid == NULL) - goto cleanup; - - (*env)->DeleteLocalRef(env, obj_cls); - obj_cls = jni_get_class(env, "java/net/InetAddress"); - if (obj_cls == NULL) - goto cleanup; - - android_ia_host_addr_mid = jni_get_method_id(env, obj_cls, "getHostAddress", - "()Ljava/lang/String;"); - if (android_ia_host_addr_mid == NULL) - goto cleanup; - - (*env)->DeleteLocalRef(env, obj_cls); - goto done; - -cleanup: - if (obj_cls != NULL) - (*env)->DeleteLocalRef(env, obj_cls); - - android_cm_active_net_mid = NULL; - android_cm_link_props_mid = NULL; - android_lp_dns_servers_mid = NULL; + (*env)->DeleteLocalRef(env, obj_cls); + obj_cls = jni_get_class(env, "java/util/List"); + if (obj_cls == NULL) + goto cleanup; + + android_list_size_mid = jni_get_method_id(env, obj_cls, "size", "()I"); + if (android_list_size_mid == NULL) + goto cleanup; + + android_list_get_mid = jni_get_method_id(env, obj_cls, "get", + "(I)Ljava/lang/Object;"); + if (android_list_get_mid == NULL) + goto cleanup; + + (*env)->DeleteLocalRef(env, obj_cls); + obj_cls = jni_get_class(env, "java/net/InetAddress"); + if (obj_cls == NULL) + goto cleanup; + + android_ia_host_addr_mid = jni_get_method_id(env, obj_cls, "getHostAddress", + "()Ljava/lang/String;"); + if (android_ia_host_addr_mid == NULL) + goto cleanup; + + (*env)->DeleteLocalRef(env, obj_cls); + goto done; + +cleanup: + if (obj_cls != NULL) + (*env)->DeleteLocalRef(env, obj_cls); + + android_cm_active_net_mid = NULL; + android_cm_link_props_mid = NULL; + android_lp_dns_servers_mid = NULL; android_lp_domains_mid = NULL; - android_list_size_mid = NULL; - android_list_get_mid = NULL; - android_ia_host_addr_mid = NULL; - -done: - if (need_detatch) - (*android_jvm)->DetachCurrentThread(android_jvm); - - return ret; -} - -int ares_library_android_initialized(void) -{ - if (android_jvm == NULL || android_connectivity_manager == NULL) - return ARES_ENOTINITIALIZED; - return ARES_SUCCESS; -} - -void ares_library_cleanup_android(void) -{ - JNIEnv *env = NULL; - int need_detatch = 0; - int res; - - if (android_jvm == NULL || android_connectivity_manager == NULL) - return; - - res = (*android_jvm)->GetEnv(android_jvm, (void **)&env, JNI_VERSION_1_6); - if (res == JNI_EDETACHED) - { - env = NULL; - res = (*android_jvm)->AttachCurrentThread(android_jvm, &env, NULL); - need_detatch = 1; - } - if (res != JNI_OK || env == NULL) - return; - - android_cm_active_net_mid = NULL; - android_cm_link_props_mid = NULL; - android_lp_dns_servers_mid = NULL; + android_list_size_mid = NULL; + android_list_get_mid = NULL; + android_ia_host_addr_mid = NULL; + +done: + if (need_detatch) + (*android_jvm)->DetachCurrentThread(android_jvm); + + return ret; +} + +int ares_library_android_initialized(void) +{ + if (android_jvm == NULL || android_connectivity_manager == NULL) + return ARES_ENOTINITIALIZED; + return ARES_SUCCESS; +} + +void ares_library_cleanup_android(void) +{ + JNIEnv *env = NULL; + int need_detatch = 0; + int res; + + if (android_jvm == NULL || android_connectivity_manager == NULL) + return; + + res = (*android_jvm)->GetEnv(android_jvm, (void **)&env, JNI_VERSION_1_6); + if (res == JNI_EDETACHED) + { + env = NULL; + res = (*android_jvm)->AttachCurrentThread(android_jvm, &env, NULL); + need_detatch = 1; + } + if (res != JNI_OK || env == NULL) + return; + + android_cm_active_net_mid = NULL; + android_cm_link_props_mid = NULL; + android_lp_dns_servers_mid = NULL; android_lp_domains_mid = NULL; - android_list_size_mid = NULL; - android_list_get_mid = NULL; - android_ia_host_addr_mid = NULL; - - (*env)->DeleteGlobalRef(env, android_connectivity_manager); - android_connectivity_manager = NULL; - - if (need_detatch) - (*android_jvm)->DetachCurrentThread(android_jvm); -} - -char **ares_get_android_server_list(size_t max_servers, - size_t *num_servers) -{ - JNIEnv *env = NULL; - jobject active_network = NULL; - jobject link_properties = NULL; - jobject server_list = NULL; - jobject server = NULL; - jstring str = NULL; - jint nserv; - const char *ch_server_address; - int res; - size_t i; - char **dns_list = NULL; - int need_detatch = 0; - - if (android_jvm == NULL || android_connectivity_manager == NULL || - max_servers == 0 || num_servers == NULL) - { - return NULL; - } - - if (android_cm_active_net_mid == NULL || android_cm_link_props_mid == NULL || - android_lp_dns_servers_mid == NULL || android_list_size_mid == NULL || - android_list_get_mid == NULL || android_ia_host_addr_mid == NULL) - { - return NULL; - } - - res = (*android_jvm)->GetEnv(android_jvm, (void **)&env, JNI_VERSION_1_6); - if (res == JNI_EDETACHED) - { - env = NULL; - res = (*android_jvm)->AttachCurrentThread(android_jvm, &env, NULL); - need_detatch = 1; - } - if (res != JNI_OK || env == NULL) - goto done; - - /* JNI below is equivalent to this Java code. - import android.content.Context; - import android.net.ConnectivityManager; - import android.net.LinkProperties; - import android.net.Network; - import java.net.InetAddress; - import java.util.List; - - ConnectivityManager cm = (ConnectivityManager)this.getApplicationContext() - .getSystemService(Context.CONNECTIVITY_SERVICE); - Network an = cm.getActiveNetwork(); - LinkProperties lp = cm.getLinkProperties(an); - List<InetAddress> dns = lp.getDnsServers(); - for (InetAddress ia: dns) { - String ha = ia.getHostAddress(); - } - - Note: The JNI ConnectivityManager object and all method IDs were previously - initialized in ares_library_init_android. - */ - - active_network = (*env)->CallObjectMethod(env, android_connectivity_manager, - android_cm_active_net_mid); - if (active_network == NULL) - goto done; - - link_properties = - (*env)->CallObjectMethod(env, android_connectivity_manager, - android_cm_link_props_mid, active_network); - if (link_properties == NULL) - goto done; - - server_list = (*env)->CallObjectMethod(env, link_properties, - android_lp_dns_servers_mid); - if (server_list == NULL) - goto done; - - nserv = (*env)->CallIntMethod(env, server_list, android_list_size_mid); - if (nserv > (jint)max_servers) - nserv = (jint)max_servers; - if (nserv <= 0) - goto done; - *num_servers = (size_t)nserv; - - dns_list = ares_malloc(sizeof(*dns_list)*(*num_servers)); - for (i=0; i<*num_servers; i++) - { - server = (*env)->CallObjectMethod(env, server_list, android_list_get_mid, - (jint)i); - dns_list[i] = ares_malloc(64); - dns_list[i][0] = 0; - if (server == NULL) - { - continue; - } - str = (*env)->CallObjectMethod(env, server, android_ia_host_addr_mid); - ch_server_address = (*env)->GetStringUTFChars(env, str, 0); - strncpy(dns_list[i], ch_server_address, 64); - (*env)->ReleaseStringUTFChars(env, str, ch_server_address); - (*env)->DeleteLocalRef(env, str); - (*env)->DeleteLocalRef(env, server); - } - -done: - if ((*env)->ExceptionOccurred(env)) - (*env)->ExceptionClear(env); - - if (server_list != NULL) - (*env)->DeleteLocalRef(env, server_list); - if (link_properties != NULL) - (*env)->DeleteLocalRef(env, link_properties); - if (active_network != NULL) - (*env)->DeleteLocalRef(env, active_network); - - if (need_detatch) - (*android_jvm)->DetachCurrentThread(android_jvm); - return dns_list; -} + android_list_size_mid = NULL; + android_list_get_mid = NULL; + android_ia_host_addr_mid = NULL; + + (*env)->DeleteGlobalRef(env, android_connectivity_manager); + android_connectivity_manager = NULL; + + if (need_detatch) + (*android_jvm)->DetachCurrentThread(android_jvm); +} + +char **ares_get_android_server_list(size_t max_servers, + size_t *num_servers) +{ + JNIEnv *env = NULL; + jobject active_network = NULL; + jobject link_properties = NULL; + jobject server_list = NULL; + jobject server = NULL; + jstring str = NULL; + jint nserv; + const char *ch_server_address; + int res; + size_t i; + char **dns_list = NULL; + int need_detatch = 0; + + if (android_jvm == NULL || android_connectivity_manager == NULL || + max_servers == 0 || num_servers == NULL) + { + return NULL; + } + + if (android_cm_active_net_mid == NULL || android_cm_link_props_mid == NULL || + android_lp_dns_servers_mid == NULL || android_list_size_mid == NULL || + android_list_get_mid == NULL || android_ia_host_addr_mid == NULL) + { + return NULL; + } + + res = (*android_jvm)->GetEnv(android_jvm, (void **)&env, JNI_VERSION_1_6); + if (res == JNI_EDETACHED) + { + env = NULL; + res = (*android_jvm)->AttachCurrentThread(android_jvm, &env, NULL); + need_detatch = 1; + } + if (res != JNI_OK || env == NULL) + goto done; + + /* JNI below is equivalent to this Java code. + import android.content.Context; + import android.net.ConnectivityManager; + import android.net.LinkProperties; + import android.net.Network; + import java.net.InetAddress; + import java.util.List; + + ConnectivityManager cm = (ConnectivityManager)this.getApplicationContext() + .getSystemService(Context.CONNECTIVITY_SERVICE); + Network an = cm.getActiveNetwork(); + LinkProperties lp = cm.getLinkProperties(an); + List<InetAddress> dns = lp.getDnsServers(); + for (InetAddress ia: dns) { + String ha = ia.getHostAddress(); + } + + Note: The JNI ConnectivityManager object and all method IDs were previously + initialized in ares_library_init_android. + */ + + active_network = (*env)->CallObjectMethod(env, android_connectivity_manager, + android_cm_active_net_mid); + if (active_network == NULL) + goto done; + + link_properties = + (*env)->CallObjectMethod(env, android_connectivity_manager, + android_cm_link_props_mid, active_network); + if (link_properties == NULL) + goto done; + + server_list = (*env)->CallObjectMethod(env, link_properties, + android_lp_dns_servers_mid); + if (server_list == NULL) + goto done; + + nserv = (*env)->CallIntMethod(env, server_list, android_list_size_mid); + if (nserv > (jint)max_servers) + nserv = (jint)max_servers; + if (nserv <= 0) + goto done; + *num_servers = (size_t)nserv; + + dns_list = ares_malloc(sizeof(*dns_list)*(*num_servers)); + for (i=0; i<*num_servers; i++) + { + server = (*env)->CallObjectMethod(env, server_list, android_list_get_mid, + (jint)i); + dns_list[i] = ares_malloc(64); + dns_list[i][0] = 0; + if (server == NULL) + { + continue; + } + str = (*env)->CallObjectMethod(env, server, android_ia_host_addr_mid); + ch_server_address = (*env)->GetStringUTFChars(env, str, 0); + strncpy(dns_list[i], ch_server_address, 64); + (*env)->ReleaseStringUTFChars(env, str, ch_server_address); + (*env)->DeleteLocalRef(env, str); + (*env)->DeleteLocalRef(env, server); + } + +done: + if ((*env)->ExceptionOccurred(env)) + (*env)->ExceptionClear(env); + + if (server_list != NULL) + (*env)->DeleteLocalRef(env, server_list); + if (link_properties != NULL) + (*env)->DeleteLocalRef(env, link_properties); + if (active_network != NULL) + (*env)->DeleteLocalRef(env, active_network); + + if (need_detatch) + (*android_jvm)->DetachCurrentThread(android_jvm); + return dns_list; +} char *ares_get_android_search_domains_list(void) { @@ -438,7 +438,7 @@ done: (*android_jvm)->DetachCurrentThread(android_jvm); return domain_list; } -#else -/* warning: ISO C forbids an empty translation unit */ -typedef int dummy_make_iso_compilers_happy; -#endif +#else +/* warning: ISO C forbids an empty translation unit */ +typedef int dummy_make_iso_compilers_happy; +#endif diff --git a/contrib/libs/c-ares/ares_android.h b/contrib/libs/c-ares/ares_android.h index 93fb75f585..4f53815e49 100644 --- a/contrib/libs/c-ares/ares_android.h +++ b/contrib/libs/c-ares/ares_android.h @@ -1,27 +1,27 @@ -/* Copyright (C) 2017 by John Schember <john@nachtimwald.com> - * - * 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. - */ - -#ifndef __ARES_ANDROID_H__ -#define __ARES_ANDROID_H__ - -#if defined(ANDROID) || defined(__ANDROID__) - -char **ares_get_android_server_list(size_t max_servers, size_t *num_servers); +/* Copyright (C) 2017 by John Schember <john@nachtimwald.com> + * + * 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. + */ + +#ifndef __ARES_ANDROID_H__ +#define __ARES_ANDROID_H__ + +#if defined(ANDROID) || defined(__ANDROID__) + +char **ares_get_android_server_list(size_t max_servers, size_t *num_servers); char *ares_get_android_search_domains_list(void); -void ares_library_cleanup_android(void); - -#endif - -#endif /* __ARES_ANDROID_H__ */ +void ares_library_cleanup_android(void); + +#endif + +#endif /* __ARES_ANDROID_H__ */ diff --git a/contrib/libs/c-ares/ares_build.h b/contrib/libs/c-ares/ares_build.h index e0a2ed784b..763c4bac28 100644 --- a/contrib/libs/c-ares/ares_build.h +++ b/contrib/libs/c-ares/ares_build.h @@ -2,7 +2,7 @@ #define __CARES_BUILD_H -/* Copyright (C) 2009 - 2013 by Daniel Stenberg et al +/* Copyright (C) 2009 - 2013 by Daniel Stenberg et al * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, provided @@ -23,20 +23,20 @@ * NOTE 1: * ------- * - * See file ares_build.h.in, run configure, and forget that this file - * exists it is only used for non-configure systems. - * But you can keep reading if you want ;-) - * - */ - -/* ================================================================ */ -/* NOTES FOR NON-CONFIGURE SYSTEMS */ -/* ================================================================ */ - -/* - * NOTE 1: - * ------- - * + * See file ares_build.h.in, run configure, and forget that this file + * exists it is only used for non-configure systems. + * But you can keep reading if you want ;-) + * + */ + +/* ================================================================ */ +/* NOTES FOR NON-CONFIGURE SYSTEMS */ +/* ================================================================ */ + +/* + * NOTE 1: + * ------- + * * Nothing in this file is intended to be modified or adjusted by the * c-ares library user nor by the c-ares library builder. * @@ -44,39 +44,39 @@ * or fixed in this file, then, report it on the c-ares development * mailing list: http://cool.haxx.se/mailman/listinfo/c-ares/ * - * Try to keep one section per platform, compiler and architecture, - * otherwise, if an existing section is reused for a different one and - * later on the original is adjusted, probably the piggybacking one can - * be adversely changed. - * - * In order to differentiate between platforms/compilers/architectures - * use only compiler built in predefined preprocessor symbols. - * + * Try to keep one section per platform, compiler and architecture, + * otherwise, if an existing section is reused for a different one and + * later on the original is adjusted, probably the piggybacking one can + * be adversely changed. + * + * In order to differentiate between platforms/compilers/architectures + * use only compiler built in predefined preprocessor symbols. + * * This header file shall only export symbols which are 'cares' or 'CARES' * prefixed, otherwise public name space would be polluted. * * NOTE 2: * ------- * - * Right now you might be staring at file ares_build.h.dist or ares_build.h, - * this is due to the following reason: file ares_build.h.dist is renamed - * to ares_build.h when the c-ares source code distribution archive file is - * created. - * - * File ares_build.h.dist is not included in the distribution archive. - * File ares_build.h is not present in the git tree. - * - * The distributed ares_build.h file is only intended to be used on systems - * which can not run the also distributed configure script. + * Right now you might be staring at file ares_build.h.dist or ares_build.h, + * this is due to the following reason: file ares_build.h.dist is renamed + * to ares_build.h when the c-ares source code distribution archive file is + * created. * + * File ares_build.h.dist is not included in the distribution archive. + * File ares_build.h is not present in the git tree. + * + * The distributed ares_build.h file is only intended to be used on systems + * which can not run the also distributed configure script. + * * On systems capable of running the configure script, the configure process * will overwrite the distributed ares_build.h file with one that is suitable * and specific to the library being configured and built, which is generated * from the ares_build.h.in template file. * - * If you check out from git on a non-configure platform, you must run the - * appropriate buildconf* script to set up ares_build.h and other local files. - * + * 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. + * */ /* ================================================================ */ @@ -89,98 +89,98 @@ #endif /* ================================================================ */ -/* EXTERNAL INTERFACE SETTINGS FOR NON-CONFIGURE SYSTEMS ONLY */ +/* EXTERNAL INTERFACE SETTINGS FOR NON-CONFIGURE SYSTEMS ONLY */ /* ================================================================ */ -#if defined(__DJGPP__) || defined(__GO32__) -# define CARES_TYPEOF_ARES_SOCKLEN_T int - -#elif defined(__SALFORDC__) -# define CARES_TYPEOF_ARES_SOCKLEN_T int - -#elif defined(__BORLANDC__) -# define CARES_TYPEOF_ARES_SOCKLEN_T int - -#elif defined(__TURBOC__) -# define CARES_TYPEOF_ARES_SOCKLEN_T int - -#elif defined(__WATCOMC__) -# define CARES_TYPEOF_ARES_SOCKLEN_T int - -#elif defined(__POCC__) -# define CARES_TYPEOF_ARES_SOCKLEN_T int - -#elif defined(__LCC__) -# define CARES_TYPEOF_ARES_SOCKLEN_T int - -#elif defined(__SYMBIAN32__) -# define CARES_TYPEOF_ARES_SOCKLEN_T unsigned int - -#elif defined(__MWERKS__) -# define CARES_TYPEOF_ARES_SOCKLEN_T int - -#elif defined(_WIN32_WCE) -# define CARES_TYPEOF_ARES_SOCKLEN_T int - -#elif defined(__MINGW32__) -# define CARES_TYPEOF_ARES_SOCKLEN_T int - -#elif defined(__VMS) -# define CARES_TYPEOF_ARES_SOCKLEN_T unsigned int - -#elif defined(__OS400__) -# if defined(__ILEC400__) -# define CARES_TYPEOF_ARES_SOCKLEN_T socklen_t -# define CARES_PULL_SYS_TYPES_H 1 -# define CARES_PULL_SYS_SOCKET_H 1 +#if defined(__DJGPP__) || defined(__GO32__) +# define CARES_TYPEOF_ARES_SOCKLEN_T int + +#elif defined(__SALFORDC__) +# define CARES_TYPEOF_ARES_SOCKLEN_T int + +#elif defined(__BORLANDC__) +# define CARES_TYPEOF_ARES_SOCKLEN_T int + +#elif defined(__TURBOC__) +# define CARES_TYPEOF_ARES_SOCKLEN_T int + +#elif defined(__WATCOMC__) +# define CARES_TYPEOF_ARES_SOCKLEN_T int + +#elif defined(__POCC__) +# define CARES_TYPEOF_ARES_SOCKLEN_T int + +#elif defined(__LCC__) +# define CARES_TYPEOF_ARES_SOCKLEN_T int + +#elif defined(__SYMBIAN32__) +# define CARES_TYPEOF_ARES_SOCKLEN_T unsigned int + +#elif defined(__MWERKS__) +# define CARES_TYPEOF_ARES_SOCKLEN_T int + +#elif defined(_WIN32_WCE) +# define CARES_TYPEOF_ARES_SOCKLEN_T int + +#elif defined(__MINGW32__) +# define CARES_TYPEOF_ARES_SOCKLEN_T int + +#elif defined(__VMS) +# define CARES_TYPEOF_ARES_SOCKLEN_T unsigned int + +#elif defined(__OS400__) +# if defined(__ILEC400__) +# define CARES_TYPEOF_ARES_SOCKLEN_T socklen_t +# define CARES_PULL_SYS_TYPES_H 1 +# define CARES_PULL_SYS_SOCKET_H 1 # endif - -#elif defined(__MVS__) -# if defined(__IBMC__) || defined(__IBMCPP__) -# define CARES_TYPEOF_ARES_SOCKLEN_T socklen_t -# define CARES_PULL_SYS_TYPES_H 1 -# define CARES_PULL_SYS_SOCKET_H 1 -# endif - -#elif defined(__370__) -# if defined(__IBMC__) || defined(__IBMCPP__) -# define CARES_TYPEOF_ARES_SOCKLEN_T socklen_t -# define CARES_PULL_SYS_TYPES_H 1 -# define CARES_PULL_SYS_SOCKET_H 1 -# endif - -#elif defined(TPF) -# define CARES_TYPEOF_ARES_SOCKLEN_T int - -/* ===================================== */ -/* KEEP MSVC THE PENULTIMATE ENTRY */ -/* ===================================== */ - -#elif defined(_MSC_VER) -# define CARES_TYPEOF_ARES_SOCKLEN_T int - -/* ===================================== */ -/* KEEP GENERIC GCC THE LAST ENTRY */ -/* ===================================== */ - -#elif defined(__GNUC__) -# define CARES_TYPEOF_ARES_SOCKLEN_T socklen_t -# define CARES_PULL_SYS_TYPES_H 1 -# define CARES_PULL_SYS_SOCKET_H 1 - -#else -# error "Unknown non-configure build target!" - Error Compilation_aborted_Unknown_non_configure_build_target + +#elif defined(__MVS__) +# if defined(__IBMC__) || defined(__IBMCPP__) +# define CARES_TYPEOF_ARES_SOCKLEN_T socklen_t +# define CARES_PULL_SYS_TYPES_H 1 +# define CARES_PULL_SYS_SOCKET_H 1 +# endif + +#elif defined(__370__) +# if defined(__IBMC__) || defined(__IBMCPP__) +# define CARES_TYPEOF_ARES_SOCKLEN_T socklen_t +# define CARES_PULL_SYS_TYPES_H 1 +# define CARES_PULL_SYS_SOCKET_H 1 +# endif + +#elif defined(TPF) +# define CARES_TYPEOF_ARES_SOCKLEN_T int + +/* ===================================== */ +/* KEEP MSVC THE PENULTIMATE ENTRY */ +/* ===================================== */ + +#elif defined(_MSC_VER) +# define CARES_TYPEOF_ARES_SOCKLEN_T int + +/* ===================================== */ +/* KEEP GENERIC GCC THE LAST ENTRY */ +/* ===================================== */ + +#elif defined(__GNUC__) +# define CARES_TYPEOF_ARES_SOCKLEN_T socklen_t +# define CARES_PULL_SYS_TYPES_H 1 +# define CARES_PULL_SYS_SOCKET_H 1 + +#else +# error "Unknown non-configure build target!" + Error Compilation_aborted_Unknown_non_configure_build_target #endif -/* CARES_PULL_SYS_TYPES_H is defined above when inclusion of header file */ -/* sys/types.h is required here to properly make type definitions below. */ +/* CARES_PULL_SYS_TYPES_H is defined above when inclusion of header file */ +/* sys/types.h is required here to properly make type definitions below. */ #ifdef CARES_PULL_SYS_TYPES_H # include <sys/types.h> #endif -/* CARES_PULL_SYS_SOCKET_H is defined above when inclusion of header file */ -/* sys/socket.h is required here to properly make type definitions below. */ +/* CARES_PULL_SYS_SOCKET_H is defined above when inclusion of header file */ +/* sys/socket.h is required here to properly make type definitions below. */ #ifdef CARES_PULL_SYS_SOCKET_H #ifdef _WIN32 # include <ws2tcpip.h> @@ -189,23 +189,23 @@ #endif #endif -/* Data type definition of ares_socklen_t. */ - -#ifdef CARES_TYPEOF_ARES_SOCKLEN_T - typedef CARES_TYPEOF_ARES_SOCKLEN_T ares_socklen_t; -#endif - -/* Data type definition of ares_ssize_t. */ -#ifdef _WIN32 -# ifdef _WIN64 -# define CARES_TYPEOF_ARES_SSIZE_T __int64 -# else -# define CARES_TYPEOF_ARES_SSIZE_T long -# endif +/* Data type definition of ares_socklen_t. */ + +#ifdef CARES_TYPEOF_ARES_SOCKLEN_T + typedef CARES_TYPEOF_ARES_SOCKLEN_T ares_socklen_t; +#endif + +/* Data type definition of ares_ssize_t. */ +#ifdef _WIN32 +# ifdef _WIN64 +# define CARES_TYPEOF_ARES_SSIZE_T __int64 +# else +# define CARES_TYPEOF_ARES_SSIZE_T long +# endif #else -# define CARES_TYPEOF_ARES_SSIZE_T ssize_t +# define CARES_TYPEOF_ARES_SSIZE_T ssize_t #endif -typedef CARES_TYPEOF_ARES_SSIZE_T ares_ssize_t; +typedef CARES_TYPEOF_ARES_SSIZE_T ares_ssize_t; #endif /* __CARES_BUILD_H */ diff --git a/contrib/libs/c-ares/ares_create_query.c b/contrib/libs/c-ares/ares_create_query.c index 9efce17cfa..6ed21f8091 100644 --- a/contrib/libs/c-ares/ares_create_query.c +++ b/contrib/libs/c-ares/ares_create_query.c @@ -85,14 +85,14 @@ */ int ares_create_query(const char *name, int dnsclass, int type, - unsigned short id, int rd, unsigned char **bufp, - int *buflenp, int max_udp_size) + unsigned short id, int rd, unsigned char **bufp, + int *buflenp, int max_udp_size) { - size_t len; + size_t len; unsigned char *q; const char *p; - size_t buflen; - unsigned char *buf; + size_t buflen; + unsigned char *buf; /* Set our results early, in case we bail out early with an error. */ *buflenp = 0; @@ -102,18 +102,18 @@ int ares_create_query(const char *name, int dnsclass, int type, if (ares__is_onion_domain(name)) return ARES_ENOTFOUND; - /* Allocate a memory area for the maximum size this packet might need. +2 - * is for the length byte and zero termination if no dots or ecscaping is - * used. + /* Allocate a memory area for the maximum size this packet might need. +2 + * is for the length byte and zero termination if no dots or ecscaping is + * used. */ - len = strlen(name) + 2 + HFIXEDSZ + QFIXEDSZ + - (max_udp_size ? EDNSFIXEDSZ : 0); - buf = ares_malloc(len); - if (!buf) - return ARES_ENOMEM; + len = strlen(name) + 2 + HFIXEDSZ + QFIXEDSZ + + (max_udp_size ? EDNSFIXEDSZ : 0); + buf = ares_malloc(len); + if (!buf) + return ARES_ENOMEM; /* Set up the header. */ - q = buf; + q = buf; memset(q, 0, HFIXEDSZ); DNS_HEADER_SET_QID(q, id); DNS_HEADER_SET_OPCODE(q, QUERY); @@ -137,10 +137,10 @@ int ares_create_query(const char *name, int dnsclass, int type, q += HFIXEDSZ; while (*name) { - if (*name == '.') { - ares_free (buf); + if (*name == '.') { + ares_free (buf); return ARES_EBADNAME; - } + } /* Count the number of bytes in this label. */ len = 0; @@ -150,10 +150,10 @@ int ares_create_query(const char *name, int dnsclass, int type, p++; len++; } - if (len > MAXLABEL) { - ares_free (buf); + if (len > MAXLABEL) { + ares_free (buf); return ARES_EBADNAME; - } + } /* Encode the length and copy the data. */ *q++ = (unsigned char)len; @@ -177,30 +177,30 @@ int ares_create_query(const char *name, int dnsclass, int type, DNS_QUESTION_SET_TYPE(q, type); DNS_QUESTION_SET_CLASS(q, dnsclass); - q += QFIXEDSZ; + q += QFIXEDSZ; if (max_udp_size) { memset(q, 0, EDNSFIXEDSZ); 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); + buflen = (q - buf); - /* Reject names that are longer than the maximum of 255 bytes that's - * specified in RFC 1035 ("To simplify implementations, the total length of - * a domain name (i.e., label octets and label length octets) is restricted - * to 255 octets or less."). */ + /* Reject names that are longer than the maximum of 255 bytes that's + * specified in RFC 1035 ("To simplify implementations, the total length of + * a domain name (i.e., label octets and label length octets) is restricted + * to 255 octets or less."). */ if (buflen > (size_t)(MAXCDNAME + HFIXEDSZ + QFIXEDSZ + - (max_udp_size ? EDNSFIXEDSZ : 0))) { - ares_free (buf); - return ARES_EBADNAME; - } - - /* we know this fits in an int at this point */ - *buflenp = (int) buflen; - *bufp = buf; - + (max_udp_size ? EDNSFIXEDSZ : 0))) { + ares_free (buf); + return ARES_EBADNAME; + } + + /* we know this fits in an int at this point */ + *buflenp = (int) buflen; + *bufp = buf; + return ARES_SUCCESS; } diff --git a/contrib/libs/c-ares/ares_data.c b/contrib/libs/c-ares/ares_data.c index 18dd650c7b..34db47fcbd 100644 --- a/contrib/libs/c-ares/ares_data.c +++ b/contrib/libs/c-ares/ares_data.c @@ -40,9 +40,9 @@ void ares_free_data(void *dataptr) { - while (dataptr != NULL) { - struct ares_data *ptr; - void *next_data = NULL; + while (dataptr != NULL) { + struct ares_data *ptr; + void *next_data = NULL; #ifdef __INTEL_COMPILER # pragma warning(push) @@ -50,82 +50,82 @@ void ares_free_data(void *dataptr) /* 1684: conversion from pointer to same-sized integral type */ #endif - ptr = (void *)((char *)dataptr - offsetof(struct ares_data, data)); + ptr = (void *)((char *)dataptr - offsetof(struct ares_data, data)); #ifdef __INTEL_COMPILER # pragma warning(pop) #endif - if (ptr->mark != ARES_DATATYPE_MARK) - return; - - switch (ptr->type) - { - case ARES_DATATYPE_MX_REPLY: - - if (ptr->data.mx_reply.next) - next_data = ptr->data.mx_reply.next; - if (ptr->data.mx_reply.host) - ares_free(ptr->data.mx_reply.host); - break; - - case ARES_DATATYPE_SRV_REPLY: - - if (ptr->data.srv_reply.next) - next_data = ptr->data.srv_reply.next; - if (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) - next_data = ptr->data.txt_reply.next; - if (ptr->data.txt_reply.txt) - ares_free(ptr->data.txt_reply.txt); - break; - - case ARES_DATATYPE_ADDR_NODE: - - if (ptr->data.addr_node.next) - next_data = ptr->data.addr_node.next; - break; - - case ARES_DATATYPE_ADDR_PORT_NODE: - - if (ptr->data.addr_port_node.next) - next_data = ptr->data.addr_port_node.next; - break; - - case ARES_DATATYPE_NAPTR_REPLY: - - if (ptr->data.naptr_reply.next) - next_data = ptr->data.naptr_reply.next; - if (ptr->data.naptr_reply.flags) - ares_free(ptr->data.naptr_reply.flags); - if (ptr->data.naptr_reply.service) - ares_free(ptr->data.naptr_reply.service); - if (ptr->data.naptr_reply.regexp) - ares_free(ptr->data.naptr_reply.regexp); - if (ptr->data.naptr_reply.replacement) - ares_free(ptr->data.naptr_reply.replacement); - break; - - case ARES_DATATYPE_SOA_REPLY: - if (ptr->data.soa_reply.nsname) - ares_free(ptr->data.soa_reply.nsname); - if (ptr->data.soa_reply.hostmaster) - ares_free(ptr->data.soa_reply.hostmaster); - break; - - default: - return; - } - - ares_free(ptr); - dataptr = next_data; - } + if (ptr->mark != ARES_DATATYPE_MARK) + return; + + switch (ptr->type) + { + case ARES_DATATYPE_MX_REPLY: + + if (ptr->data.mx_reply.next) + next_data = ptr->data.mx_reply.next; + if (ptr->data.mx_reply.host) + ares_free(ptr->data.mx_reply.host); + break; + + case ARES_DATATYPE_SRV_REPLY: + + if (ptr->data.srv_reply.next) + next_data = ptr->data.srv_reply.next; + if (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) + next_data = ptr->data.txt_reply.next; + if (ptr->data.txt_reply.txt) + ares_free(ptr->data.txt_reply.txt); + break; + + case ARES_DATATYPE_ADDR_NODE: + + if (ptr->data.addr_node.next) + next_data = ptr->data.addr_node.next; + break; + + case ARES_DATATYPE_ADDR_PORT_NODE: + + if (ptr->data.addr_port_node.next) + next_data = ptr->data.addr_port_node.next; + break; + + case ARES_DATATYPE_NAPTR_REPLY: + + if (ptr->data.naptr_reply.next) + next_data = ptr->data.naptr_reply.next; + if (ptr->data.naptr_reply.flags) + ares_free(ptr->data.naptr_reply.flags); + if (ptr->data.naptr_reply.service) + ares_free(ptr->data.naptr_reply.service); + if (ptr->data.naptr_reply.regexp) + ares_free(ptr->data.naptr_reply.regexp); + if (ptr->data.naptr_reply.replacement) + ares_free(ptr->data.naptr_reply.replacement); + break; + + case ARES_DATATYPE_SOA_REPLY: + if (ptr->data.soa_reply.nsname) + ares_free(ptr->data.soa_reply.nsname); + if (ptr->data.soa_reply.hostmaster) + ares_free(ptr->data.soa_reply.hostmaster); + break; + + default: + return; + } + + ares_free(ptr); + dataptr = next_data; + } } @@ -144,7 +144,7 @@ void *ares_malloc_data(ares_datatype type) { struct ares_data *ptr; - ptr = ares_malloc(sizeof(struct ares_data)); + ptr = ares_malloc(sizeof(struct ares_data)); if (!ptr) return NULL; @@ -164,10 +164,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_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; @@ -181,15 +181,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_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; @@ -211,7 +211,7 @@ void *ares_malloc_data(ares_datatype type) break; default: - ares_free(ptr); + ares_free(ptr); return NULL; } diff --git a/contrib/libs/c-ares/ares_data.h b/contrib/libs/c-ares/ares_data.h index ee54a4b1f5..16756a8420 100644 --- a/contrib/libs/c-ares/ares_data.h +++ b/contrib/libs/c-ares/ares_data.h @@ -19,7 +19,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_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 */ @@ -30,7 +30,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_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; @@ -58,14 +58,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_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; + 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/contrib/libs/c-ares/ares_destroy.c b/contrib/libs/c-ares/ares_destroy.c index fed2009ab3..447abd51ac 100644 --- a/contrib/libs/c-ares/ares_destroy.c +++ b/contrib/libs/c-ares/ares_destroy.c @@ -27,15 +27,15 @@ void ares_destroy_options(struct ares_options *options) int i; if(options->servers) - ares_free(options->servers); + ares_free(options->servers); for (i = 0; i < options->ndomains; i++) - ares_free(options->domains[i]); + ares_free(options->domains[i]); if(options->domains) - ares_free(options->domains); + ares_free(options->domains); if(options->sortlist) - ares_free(options->sortlist); + ares_free(options->sortlist); if(options->lookups) - ares_free(options->lookups); + ares_free(options->lookups); if(options->resolvconf_path) ares_free(options->resolvconf_path); } @@ -77,20 +77,20 @@ void ares_destroy(ares_channel channel) if (channel->domains) { for (i = 0; i < channel->ndomains; i++) - ares_free(channel->domains[i]); - ares_free(channel->domains); + ares_free(channel->domains[i]); + ares_free(channel->domains); } if(channel->sortlist) - ares_free(channel->sortlist); + ares_free(channel->sortlist); if (channel->lookups) - ares_free(channel->lookups); + ares_free(channel->lookups); if (channel->resolvconf_path) ares_free(channel->resolvconf_path); - ares_free(channel); + ares_free(channel); } void ares__destroy_servers_state(ares_channel channel) @@ -106,7 +106,7 @@ void ares__destroy_servers_state(ares_channel channel) ares__close_sockets(channel, server); assert(ares__is_list_empty(&server->queries_to_server)); } - ares_free(channel->servers); + ares_free(channel->servers); channel->servers = NULL; } channel->nservers = -1; diff --git a/contrib/libs/c-ares/ares_expand_name.c b/contrib/libs/c-ares/ares_expand_name.c index 3a38e6737e..9d7594f3f7 100644 --- a/contrib/libs/c-ares/ares_expand_name.c +++ b/contrib/libs/c-ares/ares_expand_name.c @@ -32,9 +32,9 @@ #include "ares_nowarn.h" #include "ares_private.h" /* for the memdebug */ -/* Maximum number of indirections allowed for a name */ -#define MAX_INDIRS 50 - +/* Maximum number of indirections allowed for a name */ +#define MAX_INDIRS 50 + static int name_length(const unsigned char *encoded, const unsigned char *abuf, int alen); @@ -69,7 +69,7 @@ int ares_expand_name(const unsigned char *encoded, const unsigned char *abuf, char *q; const unsigned char *p; union { - ares_ssize_t sig; + ares_ssize_t sig; size_t uns; } nlen; @@ -77,7 +77,7 @@ int ares_expand_name(const unsigned char *encoded, const unsigned char *abuf, if (nlen.sig < 0) return ARES_EBADNAME; - *s = ares_malloc(nlen.uns + 1); + *s = ares_malloc(nlen.uns + 1); if (!*s) return ARES_ENOMEM; q = *s; @@ -132,7 +132,7 @@ int ares_expand_name(const unsigned char *encoded, const unsigned char *abuf, if (q > *s) *(q - 1) = 0; else - *q = 0; /* zero terminate; LCOV_EXCL_LINE: empty names exit above */ + *q = 0; /* zero terminate; LCOV_EXCL_LINE: empty names exit above */ return ARES_SUCCESS; } @@ -143,7 +143,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, top; + 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) @@ -151,8 +151,8 @@ static int name_length(const unsigned char *encoded, const unsigned char *abuf, while (*encoded) { - top = (*encoded & INDIR_MASK); - if (top == INDIR_MASK) + top = (*encoded & INDIR_MASK); + if (top == INDIR_MASK) { /* Check the offset and go there. */ if (encoded + 1 >= abuf + alen) @@ -165,11 +165,11 @@ static int name_length(const unsigned char *encoded, const unsigned char *abuf, /* If we've seen more indirects than the message length, * then there's a loop. */ - ++indir; - if (indir > alen || indir > MAX_INDIRS) + ++indir; + if (indir > alen || indir > MAX_INDIRS) return -1; } - else if (top == 0x00) + else if (top == 0x00) { offset = *encoded; if (encoded + offset + 1 >= abuf + alen) @@ -182,13 +182,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; - } + 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/contrib/libs/c-ares/ares_expand_string.c b/contrib/libs/c-ares/ares_expand_string.c index d35df75248..af9629cce8 100644 --- a/contrib/libs/c-ares/ares_expand_string.c +++ b/contrib/libs/c-ares/ares_expand_string.c @@ -41,7 +41,7 @@ int ares_expand_string(const unsigned char *encoded, { unsigned char *q; union { - ares_ssize_t sig; + ares_ssize_t sig; size_t uns; } elen; @@ -54,7 +54,7 @@ int ares_expand_string(const unsigned char *encoded, encoded++; - *s = ares_malloc(elen.uns+1); + *s = ares_malloc(elen.uns+1); if (*s == NULL) return ARES_ENOMEM; q = *s; diff --git a/contrib/libs/c-ares/ares_free_hostent.c b/contrib/libs/c-ares/ares_free_hostent.c index cfc5f81feb..6e8a26dd55 100644 --- a/contrib/libs/c-ares/ares_free_hostent.c +++ b/contrib/libs/c-ares/ares_free_hostent.c @@ -30,12 +30,12 @@ void ares_free_hostent(struct hostent *host) if (!host) return; - ares_free((char *)(host->h_name)); + ares_free((char *)(host->h_name)); for (p = host->h_aliases; *p; p++) - ares_free(*p); - ares_free(host->h_aliases); - ares_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 */ - ares_free(host->h_addr_list); - ares_free(host); + ares_free(host->h_addr_list); + ares_free(host); } diff --git a/contrib/libs/c-ares/ares_free_string.c b/contrib/libs/c-ares/ares_free_string.c index 024992e1c2..063cfe0296 100644 --- a/contrib/libs/c-ares/ares_free_string.c +++ b/contrib/libs/c-ares/ares_free_string.c @@ -21,5 +21,5 @@ void ares_free_string(void *str) { - ares_free(str); + ares_free(str); } diff --git a/contrib/libs/c-ares/ares_gethostbyaddr.c b/contrib/libs/c-ares/ares_gethostbyaddr.c index f37fb8b815..75f281173c 100644 --- a/contrib/libs/c-ares/ares_gethostbyaddr.c +++ b/contrib/libs/c-ares/ares_gethostbyaddr.c @@ -82,7 +82,7 @@ void ares_gethostbyaddr(ares_channel channel, const void *addr, int addrlen, return; } - aquery = ares_malloc(sizeof(struct addr_query)); + aquery = ares_malloc(sizeof(struct addr_query)); if (!aquery) { callback(arg, ARES_ENOMEM, 0, NULL); @@ -150,17 +150,17 @@ static void addr_callback(void *arg, int status, int timeouts, { addrlen = sizeof(aquery->addr.addrV4); status = ares_parse_ptr_reply(abuf, alen, &aquery->addr.addrV4, - (int)addrlen, AF_INET, &host, NULL); + (int)addrlen, AF_INET, &host, NULL); } else { addrlen = sizeof(aquery->addr.addrV6); status = ares_parse_ptr_reply(abuf, alen, &aquery->addr.addrV6, - (int)addrlen, AF_INET6, &host, NULL); + (int)addrlen, AF_INET6, &host, NULL); } end_aquery(aquery, status, host); } - else if (status == ARES_EDESTRUCTION || status == ARES_ECANCELLED) + else if (status == ARES_EDESTRUCTION || status == ARES_ECANCELLED) end_aquery(aquery, status, NULL); else next_lookup(aquery); @@ -172,7 +172,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); - ares_free(aquery); + ares_free(aquery); } static int file_lookup(struct ares_addr *addr, struct hostent **host) @@ -193,18 +193,18 @@ static int file_lookup(struct ares_addr *addr, struct hostent **host) char tmp[MAX_PATH]; HKEY hkeyHosts; - if (RegOpenKeyExA(HKEY_LOCAL_MACHINE, WIN_NS_NT_KEY, 0, KEY_READ, + if (RegOpenKeyExA(HKEY_LOCAL_MACHINE, WIN_NS_NT_KEY, 0, KEY_READ, &hkeyHosts) == ERROR_SUCCESS) { DWORD dwLength = MAX_PATH; - RegQueryValueExA(hkeyHosts, DATABASEPATH, NULL, NULL, (LPBYTE)tmp, + RegQueryValueExA(hkeyHosts, DATABASEPATH, NULL, NULL, (LPBYTE)tmp, &dwLength); - ExpandEnvironmentStringsA(tmp, PATH_HOSTS, MAX_PATH); + ExpandEnvironmentStringsA(tmp, PATH_HOSTS, MAX_PATH); RegCloseKey(hkeyHosts); } } else if (platform == WIN_9X) - GetWindowsDirectoryA(PATH_HOSTS, MAX_PATH); + GetWindowsDirectoryA(PATH_HOSTS, MAX_PATH); else return ARES_ENOTFOUND; @@ -298,4 +298,4 @@ static void ptr_rr_name(char *name, const struct ares_addr *addr) #undef next_lookup #undef file_lookup - + diff --git a/contrib/libs/c-ares/ares_gethostbyname.c b/contrib/libs/c-ares/ares_gethostbyname.c index ecd03e7931..00962d5400 100644 --- a/contrib/libs/c-ares/ares_gethostbyname.c +++ b/contrib/libs/c-ares/ares_gethostbyname.c @@ -106,18 +106,18 @@ void ares_gethostbyname(ares_channel channel, const char *name, int family, return; /* Allocate and fill in the host query structure. */ - hquery = ares_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 = ares_strdup(name); + hquery->name = ares_strdup(name); hquery->want_family = family; hquery->sent_family = -1; /* nothing is sent yet */ if (!hquery->name) { - ares_free(hquery); + ares_free(hquery); callback(arg, ARES_ENOMEM, 0, NULL); return; } @@ -195,14 +195,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 || - (status == ARES_SUCCESS && host && host->h_addr_list[0] == NULL)) && - 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); + if (host) + ares_free_hostent(host); hquery->sent_family = AF_INET; ares_search(hquery->channel, hquery->name, C_IN, T_A, host_callback, hquery); @@ -241,8 +241,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); - ares_free(hquery->name); - ares_free(hquery); + ares_free(hquery->name); + ares_free(hquery); } /* If the name looks like an IP address, fake up a host entry, end the @@ -301,7 +301,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 = ares_strdup(name); + hostent.h_name = ares_strdup(name); if (!hostent.h_name) { callback(arg, ARES_ENOMEM, 0, NULL); @@ -315,7 +315,7 @@ static int fake_hostent(const char *name, int family, hostent.h_addr_list = addrs; callback(arg, ARES_SUCCESS, 0, &hostent); - ares_free((char *)(hostent.h_name)); + ares_free((char *)(hostent.h_name)); return 1; } @@ -365,18 +365,18 @@ static int file_lookup(const char *name, int family, struct hostent **host) char tmp[MAX_PATH]; HKEY hkeyHosts; - if (RegOpenKeyExA(HKEY_LOCAL_MACHINE, WIN_NS_NT_KEY, 0, KEY_READ, + if (RegOpenKeyExA(HKEY_LOCAL_MACHINE, WIN_NS_NT_KEY, 0, KEY_READ, &hkeyHosts) == ERROR_SUCCESS) { DWORD dwLength = MAX_PATH; - RegQueryValueExA(hkeyHosts, DATABASEPATH, NULL, NULL, (LPBYTE)tmp, + RegQueryValueExA(hkeyHosts, DATABASEPATH, NULL, NULL, (LPBYTE)tmp, &dwLength); - ExpandEnvironmentStringsA(tmp, PATH_HOSTS, MAX_PATH); + ExpandEnvironmentStringsA(tmp, PATH_HOSTS, MAX_PATH); RegCloseKey(hkeyHosts); } } else if (platform == WIN_9X) - GetWindowsDirectoryA(PATH_HOSTS, MAX_PATH); + GetWindowsDirectoryA(PATH_HOSTS, MAX_PATH); else return ARES_ENOTFOUND; diff --git a/contrib/libs/c-ares/ares_getnameinfo.c b/contrib/libs/c-ares/ares_getnameinfo.c index 53f91ca845..20990866fa 100644 --- a/contrib/libs/c-ares/ares_getnameinfo.c +++ b/contrib/libs/c-ares/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_TESTABLE 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 = ares_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); - ares_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); - ares_free(niquery); + ares_free(niquery); return; } niquery->callback(niquery->arg, status, niquery->timeouts, NULL, NULL); - ares_free(niquery); + ares_free(niquery); } static char *lookup_service(unsigned short port, int flags, @@ -281,8 +281,8 @@ static char *lookup_service(unsigned short port, int flags, struct servent se; #endif char tmpbuf[4096]; - char *name; - size_t name_len; + char *name; + size_t name_len; if (port) { @@ -299,13 +299,13 @@ static char *lookup_service(unsigned short port, int flags, else proto = "tcp"; #ifdef HAVE_GETSERVBYPORT_R - memset(&se, 0, sizeof(se)); + 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; /* LCOV_EXCL_LINE: buffer large so this never fails */ + 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)); @@ -326,23 +326,23 @@ static char *lookup_service(unsigned short port, int flags, #endif } if (sep && sep->s_name) - { - /* get service name */ - name = sep->s_name; - } + { + /* get service name */ + name = sep->s_name; + } else - { - /* get port as a string */ - sprintf(tmpbuf, "%u", (unsigned int)ntohs(port)); - name = tmpbuf; - } - name_len = strlen(name); - if (name_len < 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 */ - memcpy(buf, name, name_len + 1); + memcpy(buf, name, name_len + 1); else /* avoid reusing previous one */ - buf[0] = '\0'; /* LCOV_EXCL_LINE: no real service names are too big */ + buf[0] = '\0'; /* LCOV_EXCL_LINE: no real service names are too big */ return buf; } buf[0] = '\0'; @@ -358,7 +358,7 @@ static void append_scopeid(struct sockaddr_in6 *addr6, unsigned int flags, #endif char tmpbuf[IF_NAMESIZE + 2]; size_t bufl; - int is_scope_long = sizeof(addr6->sin6_scope_id) > sizeof(unsigned int); + int is_scope_long = sizeof(addr6->sin6_scope_id) > sizeof(unsigned int); tmpbuf[0] = '%'; @@ -368,38 +368,38 @@ static void append_scopeid(struct sockaddr_in6 *addr6, unsigned int flags, if ((flags & ARES_NI_NUMERICSCOPE) || (!is_ll && !is_mcll)) { - if (is_scope_long) - { - sprintf(&tmpbuf[1], "%lu", (unsigned long)addr6->sin6_scope_id); - } - else - { - sprintf(&tmpbuf[1], "%u", (unsigned int)addr6->sin6_scope_id); - } + if (is_scope_long) + { + sprintf(&tmpbuf[1], "%lu", (unsigned long)addr6->sin6_scope_id); + } + else + { + sprintf(&tmpbuf[1], "%u", (unsigned int)addr6->sin6_scope_id); + } } else { if (if_indextoname(addr6->sin6_scope_id, &tmpbuf[1]) == NULL) - { - if (is_scope_long) - { - sprintf(&tmpbuf[1], "%lu", (unsigned long)addr6->sin6_scope_id); - } - else - { - sprintf(&tmpbuf[1], "%u", (unsigned int)addr6->sin6_scope_id); - } - } + { + if (is_scope_long) + { + sprintf(&tmpbuf[1], "%lu", (unsigned long)addr6->sin6_scope_id); + } + else + { + sprintf(&tmpbuf[1], "%u", (unsigned int)addr6->sin6_scope_id); + } + } } #else - if (is_scope_long) - { - sprintf(&tmpbuf[1], "%lu", (unsigned long)addr6->sin6_scope_id); - } - else - { - sprintf(&tmpbuf[1], "%u", (unsigned int)addr6->sin6_scope_id); - } + if (is_scope_long) + { + sprintf(&tmpbuf[1], "%lu", (unsigned long)addr6->sin6_scope_id); + } + else + { + sprintf(&tmpbuf[1], "%u", (unsigned int)addr6->sin6_scope_id); + } (void) flags; #endif tmpbuf[IF_NAMESIZE + 1] = '\0'; @@ -412,7 +412,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_TESTABLE 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; @@ -438,7 +438,7 @@ STATIC_TESTABLE char *ares_striendstr(const char *s1, const char *s2) c2++; } } - return (char *)c1_begin; + return (char *)c1_begin; } int ares__is_onion_domain(const char *name) diff --git a/contrib/libs/c-ares/ares_getsock.c b/contrib/libs/c-ares/ares_getsock.c index 22d344679f..708fef5d0e 100644 --- a/contrib/libs/c-ares/ares_getsock.c +++ b/contrib/libs/c-ares/ares_getsock.c @@ -30,7 +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; i++) + for (i = 0; i < channel->nservers; i++) { server = &channel->servers[i]; /* We only need to register interest in UDP sockets if we have @@ -38,7 +38,7 @@ int ares_getsock(ares_channel channel, */ if (active_queries && server->udp_socket != ARES_SOCKET_BAD) { - if(sockindex >= numsocks || sockindex >= ARES_GETSOCK_MAXNUM) + if(sockindex >= numsocks || sockindex >= ARES_GETSOCK_MAXNUM) break; socks[sockindex] = server->udp_socket; bitmap |= ARES_GETSOCK_READABLE(setbits, sockindex); @@ -50,7 +50,7 @@ int ares_getsock(ares_channel channel, */ if (server->tcp_socket != ARES_SOCKET_BAD) { - if(sockindex >= numsocks || sockindex >= ARES_GETSOCK_MAXNUM) + if(sockindex >= numsocks || sockindex >= ARES_GETSOCK_MAXNUM) break; socks[sockindex] = server->tcp_socket; bitmap |= ARES_GETSOCK_READABLE(setbits, sockindex); diff --git a/contrib/libs/c-ares/ares_init.c b/contrib/libs/c-ares/ares_init.c index e06265c6a2..fad0c52b36 100644 --- a/contrib/libs/c-ares/ares_init.c +++ b/contrib/libs/c-ares/ares_init.c @@ -44,16 +44,16 @@ #if defined(ANDROID) || defined(__ANDROID__) #include <sys/system_properties.h> -#include "ares_android.h" +#include "ares_android.h" /* From the Bionic sources */ #define DNS_PROP_NAME_PREFIX "net.dns" #define MAX_DNS_PROPERTIES 8 #endif -#if defined(CARES_USE_LIBRESOLV) -#include <resolv.h> -#endif - +#if defined(CARES_USE_LIBRESOLV) +#include <resolv.h> +#endif + #include "ares.h" #include "ares_inet_net_pton.h" #include "ares_library_init.h" @@ -81,18 +81,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); -static int config_sortlist(struct apattern **sortlist, int *nsort, - const char *str); +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, ares_ssize_t len, struct in_addr *addr); +static int ip_addr(const char *s, ares_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) +#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 *altbindch, - const char *filech); + const char *bindch, const char *altbindch, + const char *filech); static char *try_config(char *s, const char *opt, char scc); #endif @@ -130,9 +130,9 @@ int ares_init_options(ares_channel *channelptr, struct ares_options *options, #endif if (ares_library_initialized() != ARES_SUCCESS) - return ARES_ENOTINITIALIZED; /* LCOV_EXCL_LINE: n/a on non-WinSock */ + return ARES_ENOTINITIALIZED; /* LCOV_EXCL_LINE: n/a on non-WinSock */ - channel = ares_malloc(sizeof(struct ares_channeldata)); + channel = ares_malloc(sizeof(struct ares_channeldata)); if (!channel) { *channelptr = NULL; return ARES_ENOMEM; @@ -168,10 +168,10 @@ 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->sock_funcs = NULL; - channel->sock_func_cb_data = NULL; + channel->sock_config_cb = NULL; + channel->sock_config_cb_data = NULL; + channel->sock_funcs = NULL; + channel->sock_func_cb_data = NULL; channel->resolvconf_path = NULL; channel->last_server = 0; @@ -196,17 +196,17 @@ int ares_init_options(ares_channel *channelptr, struct ares_options *options, * precedence to lowest. */ - 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_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))); + 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) @@ -234,21 +234,21 @@ int ares_init_options(ares_channel *channelptr, struct ares_options *options, ares_strerror(status))); } -done: +done: if (status != ARES_SUCCESS) { /* Something failed; clean up memory we may have allocated. */ if (channel->servers) - ares_free(channel->servers); + ares_free(channel->servers); if (channel->ndomains != -1) ares_strsplit_free(channel->domains, channel->ndomains); if (channel->sortlist) - ares_free(channel->sortlist); + ares_free(channel->sortlist); if(channel->lookups) - ares_free(channel->lookups); + ares_free(channel->lookups); if(channel->resolvconf_path) ares_free(channel->resolvconf_path); - ares_free(channel); + ares_free(channel); return status; } @@ -267,8 +267,8 @@ done: int ares_dup(ares_channel *dest, ares_channel src) { struct ares_options opts; - struct ares_addr_port_node *servers; - int non_v4_default_port = 0; + struct ares_addr_port_node *servers; + int non_v4_default_port = 0; int i, rc; int optmask; @@ -278,10 +278,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); + { + ares_destroy_options(&opts); return rc; - } + } /* Then create the new channel with those options */ rc = ares_init_options(dest, &opts, optmask); @@ -295,40 +295,40 @@ 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; - (*dest)->sock_funcs = src->sock_funcs; - (*dest)->sock_func_cb_data = src->sock_func_cb_data; + (*dest)->sock_config_cb = src->sock_config_cb; + (*dest)->sock_config_cb_data = src->sock_config_cb_data; + (*dest)->sock_funcs = src->sock_funcs; + (*dest)->sock_func_cb_data = src->sock_func_cb_data; strncpy((*dest)->local_dev_name, src->local_dev_name, sizeof((*dest)->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 if there is a non-IPv4, or non-default port, nameserver */ + /* 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) || - (src->servers[i].addr.udp_port != 0) || - (src->servers[i].addr.tcp_port != 0)) { - non_v4_default_port++; + 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 (non_v4_default_port) { - rc = ares_get_servers_ports(src, &servers); - if (rc != ARES_SUCCESS) { - ares_destroy(*dest); - *dest = NULL; + 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_ports(*dest, servers); + } + rc = ares_set_servers_ports(*dest, servers); ares_free_data(servers); - if (rc != ARES_SUCCESS) { - ares_destroy(*dest); - *dest = NULL; + if (rc != ARES_SUCCESS) { + ares_destroy(*dest); + *dest = NULL; return rc; - } + } } return ARES_SUCCESS; /* everything went fine */ @@ -355,7 +355,7 @@ int ares_save_options(ares_channel channel, struct ares_options *options, ARES_OPT_SERVERS|ARES_OPT_DOMAINS|ARES_OPT_LOOKUPS| ARES_OPT_SORTLIST|ARES_OPT_TIMEOUTMS|ARES_OPT_MAXTIMEOUTMS| ARES_OPT_JITTER); - (*optmask) |= (channel->rotate ? ARES_OPT_ROTATE : ARES_OPT_NOROTATE); + (*optmask) |= (channel->rotate ? ARES_OPT_ROTATE : ARES_OPT_NOROTATE); if (channel->resolvconf_path) (*optmask) |= ARES_OPT_RESOLVCONF; @@ -376,24 +376,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 that use the default port */ + /* 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) && - (channel->servers[i].addr.udp_port == 0) && - (channel->servers[i].addr.tcp_port == 0)) + 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 = ares_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) && - (channel->servers[i].addr.udp_port == 0) && - (channel->servers[i].addr.tcp_port == 0)) + 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)); @@ -404,14 +404,14 @@ int ares_save_options(ares_channel channel, struct ares_options *options, /* copy domains */ if (channel->ndomains) { - options->domains = ares_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] = ares_strdup(channel->domains[i]); + options->domains[i] = ares_strdup(channel->domains[i]); if (!options->domains[i]) return ARES_ENOMEM; } @@ -420,14 +420,14 @@ int ares_save_options(ares_channel channel, struct ares_options *options, /* copy lookups */ if (channel->lookups) { - options->lookups = ares_strdup(channel->lookups); + options->lookups = ares_strdup(channel->lookups); if (!options->lookups && channel->lookups) return ARES_ENOMEM; } /* copy sortlist */ if (channel->nsort) { - options->sortlist = ares_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++) @@ -471,8 +471,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_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) @@ -499,14 +499,14 @@ static int init_by_options(ares_channel channel, if (options->nservers > 0) { channel->servers = - ares_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; + 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)); @@ -523,13 +523,13 @@ static int init_by_options(ares_channel channel, /* Avoid zero size allocations at any cost */ if (options->ndomains > 0) { - channel->domains = ares_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] = ares_strdup(options->domains[i]); + channel->domains[i] = ares_strdup(options->domains[i]); if (!channel->domains[i]) return ARES_ENOMEM; } @@ -540,20 +540,20 @@ static int init_by_options(ares_channel channel, /* Set lookups, if given. */ if ((optmask & ARES_OPT_LOOKUPS) && !channel->lookups) { - channel->lookups = ares_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)) { - 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]; - } + 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; } @@ -588,7 +588,7 @@ static int init_by_environment(ares_channel channel) { status = set_options(channel, res_options); if (status != ARES_SUCCESS) - return status; /* LCOV_EXCL_LINE: set_options() never fails */ + return status; /* LCOV_EXCL_LINE: set_options() never fails */ } return ARES_SUCCESS; @@ -617,22 +617,22 @@ static int get_REG_SZ(HKEY hKey, const char *leafKeyName, char **outptr) *outptr = NULL; /* Find out size of string stored in registry */ - res = RegQueryValueExA(hKey, leafKeyName, 0, NULL, NULL, &size); + res = RegQueryValueExA(hKey, leafKeyName, 0, NULL, NULL, &size); if ((res != ERROR_SUCCESS && res != ERROR_MORE_DATA) || !size) return 0; /* Allocate buffer of indicated size plus one given that string might have been stored without null termination */ - *outptr = ares_malloc(size+1); + *outptr = ares_malloc(size+1); if (!*outptr) return 0; /* Get the value for real */ - res = RegQueryValueExA(hKey, leafKeyName, 0, NULL, + res = RegQueryValueExA(hKey, leafKeyName, 0, NULL, (unsigned char *)*outptr, &size); if ((res != ERROR_SUCCESS) || (size == 1)) { - ares_free(*outptr); + ares_free(*outptr); *outptr = NULL; return 0; } @@ -659,22 +659,22 @@ static int get_REG_SZ_9X(HKEY hKey, const char *leafKeyName, char **outptr) *outptr = NULL; /* Find out size of string stored in registry */ - res = RegQueryValueExA(hKey, leafKeyName, 0, &dataType, NULL, &size); + res = RegQueryValueExA(hKey, leafKeyName, 0, &dataType, NULL, &size); if ((res != ERROR_SUCCESS && res != ERROR_MORE_DATA) || !size) return 0; /* Allocate buffer of indicated size plus one given that string might have been stored without null termination */ - *outptr = ares_malloc(size+1); + *outptr = ares_malloc(size+1); if (!*outptr) return 0; /* Get the value for real */ - res = RegQueryValueExA(hKey, leafKeyName, 0, &dataType, + res = RegQueryValueExA(hKey, leafKeyName, 0, &dataType, (unsigned char *)*outptr, &size); if ((res != ERROR_SUCCESS) || (size == 1)) { - ares_free(*outptr); + ares_free(*outptr); *outptr = NULL; return 0; } @@ -715,11 +715,11 @@ static int get_enum_REG_SZ(HKEY hKeyParent, const char *leafKeyName, for(;;) { enumKeyNameBuffSize = sizeof(enumKeyName); - res = RegEnumKeyExA(hKeyParent, enumKeyIdx++, enumKeyName, + res = RegEnumKeyExA(hKeyParent, enumKeyIdx++, enumKeyName, &enumKeyNameBuffSize, 0, NULL, NULL, NULL); if (res != ERROR_SUCCESS) break; - res = RegOpenKeyExA(hKeyParent, enumKeyName, 0, KEY_QUERY_VALUE, + res = RegOpenKeyExA(hKeyParent, enumKeyName, 0, KEY_QUERY_VALUE, &hKeyEnum); if (res != ERROR_SUCCESS) continue; @@ -750,7 +750,7 @@ static int get_DNS_Registry_9X(char **outptr) *outptr = NULL; - res = RegOpenKeyExA(HKEY_LOCAL_MACHINE, WIN_NS_9X, 0, KEY_READ, + res = RegOpenKeyExA(HKEY_LOCAL_MACHINE, WIN_NS_9X, 0, KEY_READ, &hKey_VxD_MStcp); if (res != ERROR_SUCCESS) return 0; @@ -782,7 +782,7 @@ static int get_DNS_Registry_NT(char **outptr) *outptr = NULL; - res = RegOpenKeyExA(HKEY_LOCAL_MACHINE, WIN_NS_NT_KEY, 0, KEY_READ, + res = RegOpenKeyExA(HKEY_LOCAL_MACHINE, WIN_NS_NT_KEY, 0, KEY_READ, &hKey_Tcpip_Parameters); if (res != ERROR_SUCCESS) return 0; @@ -804,7 +804,7 @@ static int get_DNS_Registry_NT(char **outptr) goto done; /* Try adapter specific parameters */ - res = RegOpenKeyExA(hKey_Tcpip_Parameters, "Interfaces", 0, + res = RegOpenKeyExA(hKey_Tcpip_Parameters, "Interfaces", 0, KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS, &hKey_Interfaces); if (res != ERROR_SUCCESS) @@ -864,24 +864,24 @@ static int get_DNS_Registry(char **outptr) return 1; } -static void commanjoin(char** dst, const char* const src, const size_t len) -{ - char *newbuf; - size_t newsize; - - /* 1 for terminating 0 and 2 for , and terminating 0 */ - newsize = len + (*dst ? (strlen(*dst) + 2) : 1); - newbuf = ares_realloc(*dst, newsize); - if (!newbuf) - return; - if (*dst == NULL) - *newbuf = '\0'; - *dst = newbuf; - if (strlen(*dst) != 0) - strcat(*dst, ","); - strncat(*dst, src, len); -} - +static void commanjoin(char** dst, const char* const src, const size_t len) +{ + char *newbuf; + size_t newsize; + + /* 1 for terminating 0 and 2 for , and terminating 0 */ + newsize = len + (*dst ? (strlen(*dst) + 2) : 1); + newbuf = ares_realloc(*dst, newsize); + if (!newbuf) + return; + if (*dst == NULL) + *newbuf = '\0'; + *dst = newbuf; + if (strlen(*dst) != 0) + strcat(*dst, ","); + strncat(*dst, src, len); +} + /* * commajoin() * @@ -889,7 +889,7 @@ static void commanjoin(char** dst, const char* const src, const size_t len) */ static void commajoin(char **dst, const char *src) { - commanjoin(dst, src, strlen(src)); + commanjoin(dst, src, strlen(src)); } /* @@ -923,7 +923,7 @@ static int get_DNS_NetworkParams(char **outptr) if (ares_fpGetNetworkParams == ZERO_NULL) return 0; - fi = ares_malloc(size); + fi = ares_malloc(size); if (!fi) return 0; @@ -931,7 +931,7 @@ static int get_DNS_NetworkParams(char **outptr) if ((res != ERROR_BUFFER_OVERFLOW) && (res != ERROR_SUCCESS)) goto done; - newfi = ares_realloc(fi, size); + newfi = ares_realloc(fi, size); if (!newfi) goto done; @@ -968,7 +968,7 @@ static int get_DNS_NetworkParams(char **outptr) done: if (fi) - ares_free(fi); + ares_free(fi); if (!*outptr) return 0; @@ -976,131 +976,131 @@ done: return 1; } -static BOOL ares_IsWindowsVistaOrGreater(void) -{ - OSVERSIONINFO vinfo; - memset(&vinfo, 0, sizeof(vinfo)); - vinfo.dwOSVersionInfoSize = sizeof(vinfo); -#ifdef _MSC_VER -#pragma warning(push) -#pragma warning(disable:4996) /* warning C4996: 'GetVersionExW': was declared deprecated */ -#endif - if (!GetVersionEx(&vinfo) || vinfo.dwMajorVersion < 6) - return FALSE; - return TRUE; -#ifdef _MSC_VER -#pragma warning(pop) -#endif -} - -/* A structure to hold the string form of IPv4 and IPv6 addresses so we can - * sort them by a metric. - */ -typedef struct -{ - /* The metric we sort them by. */ - ULONG metric; - - /* Original index of the item, used as a secondary sort parameter to make - * qsort() stable if the metrics are equal */ - size_t orig_idx; - - /* Room enough for the string form of any IPv4 or IPv6 address that - * ares_inet_ntop() will create. Based on the existing c-ares practice. - */ - char text[sizeof("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255")]; -} Address; - -/* Sort Address values \a left and \a right by metric, returning the usual - * indicators for qsort(). - */ -static int compareAddresses(const void *arg1, - const void *arg2) -{ - const Address * const left = arg1; - const Address * const right = arg2; - /* Lower metric the more preferred */ - if(left->metric < right->metric) return -1; - if(left->metric > right->metric) return 1; - /* If metrics are equal, lower original index more preferred */ - if(left->orig_idx < right->orig_idx) return -1; - if(left->orig_idx > right->orig_idx) return 1; - return 0; -} - -/* There can be multiple routes to "the Internet". And there can be different - * DNS servers associated with each of the interfaces that offer those routes. - * We have to assume that any DNS server can serve any request. But, some DNS - * servers may only respond if requested over their associated interface. But - * we also want to use "the preferred route to the Internet" whenever possible - * (and not use DNS servers on a non-preferred route even by forcing request - * to go out on the associated non-preferred interface). i.e. We want to use - * the DNS servers associated with the same interface that we would use to - * make a general request to anything else. - * - * But, Windows won't sort the DNS servers by the metrics associated with the - * routes and interfaces _even_ though it obviously sends IP packets based on - * those same routes and metrics. So, we must do it ourselves. - * - * So, we sort the DNS servers by the same metric values used to determine how - * an outgoing IP packet will go, thus effectively using the DNS servers - * associated with the interface that the DNS requests themselves will - * travel. This gives us optimal routing and avoids issues where DNS servers - * won't respond to requests that don't arrive via some specific subnetwork - * (and thus some specific interface). - * - * This function computes the metric we use to sort. On the interface - * identified by \a luid, it determines the best route to \a dest and combines - * that route's metric with \a interfaceMetric to compute a metric for the - * destination address on that interface. This metric can be used as a weight - * to sort the DNS server addresses associated with each interface (lower is - * better). - * - * Note that by restricting the route search to the specific interface with - * which the DNS servers are associated, this function asks the question "What - * is the metric for sending IP packets to this DNS server?" which allows us - * to sort the DNS servers correctly. - */ -static ULONG getBestRouteMetric(IF_LUID * const luid, /* Can't be const :( */ - const SOCKADDR_INET * const dest, - const ULONG interfaceMetric) -{ - /* On this interface, get the best route to that destination. */ - MIB_IPFORWARD_ROW2 row; - SOCKADDR_INET ignored; - if(!ares_fpGetBestRoute2 || - ares_fpGetBestRoute2(/* The interface to use. The index is ignored since we are - * passing a LUID. - */ - luid, 0, - /* No specific source address. */ - NULL, - /* Our destination address. */ - dest, - /* No options. */ - 0, - /* The route row. */ - &row, - /* The best source address, which we don't need. */ - &ignored) != NO_ERROR - /* If the metric is "unused" (-1) or too large for us to add the two - * metrics, use the worst possible, thus sorting this last. - */ - || row.Metric == (ULONG)-1 - || row.Metric > ((ULONG)-1) - interfaceMetric) { - /* Return the worst possible metric. */ - return (ULONG)-1; - } - - /* Return the metric value from that row, plus the interface metric. - * - * See - * http://msdn.microsoft.com/en-us/library/windows/desktop/aa814494(v=vs.85).aspx - * which describes the combination as a "sum". - */ - return row.Metric + interfaceMetric; -} - +static BOOL ares_IsWindowsVistaOrGreater(void) +{ + OSVERSIONINFO vinfo; + memset(&vinfo, 0, sizeof(vinfo)); + vinfo.dwOSVersionInfoSize = sizeof(vinfo); +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable:4996) /* warning C4996: 'GetVersionExW': was declared deprecated */ +#endif + if (!GetVersionEx(&vinfo) || vinfo.dwMajorVersion < 6) + return FALSE; + return TRUE; +#ifdef _MSC_VER +#pragma warning(pop) +#endif +} + +/* A structure to hold the string form of IPv4 and IPv6 addresses so we can + * sort them by a metric. + */ +typedef struct +{ + /* The metric we sort them by. */ + ULONG metric; + + /* Original index of the item, used as a secondary sort parameter to make + * qsort() stable if the metrics are equal */ + size_t orig_idx; + + /* Room enough for the string form of any IPv4 or IPv6 address that + * ares_inet_ntop() will create. Based on the existing c-ares practice. + */ + char text[sizeof("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255")]; +} Address; + +/* Sort Address values \a left and \a right by metric, returning the usual + * indicators for qsort(). + */ +static int compareAddresses(const void *arg1, + const void *arg2) +{ + const Address * const left = arg1; + const Address * const right = arg2; + /* Lower metric the more preferred */ + if(left->metric < right->metric) return -1; + if(left->metric > right->metric) return 1; + /* If metrics are equal, lower original index more preferred */ + if(left->orig_idx < right->orig_idx) return -1; + if(left->orig_idx > right->orig_idx) return 1; + return 0; +} + +/* There can be multiple routes to "the Internet". And there can be different + * DNS servers associated with each of the interfaces that offer those routes. + * We have to assume that any DNS server can serve any request. But, some DNS + * servers may only respond if requested over their associated interface. But + * we also want to use "the preferred route to the Internet" whenever possible + * (and not use DNS servers on a non-preferred route even by forcing request + * to go out on the associated non-preferred interface). i.e. We want to use + * the DNS servers associated with the same interface that we would use to + * make a general request to anything else. + * + * But, Windows won't sort the DNS servers by the metrics associated with the + * routes and interfaces _even_ though it obviously sends IP packets based on + * those same routes and metrics. So, we must do it ourselves. + * + * So, we sort the DNS servers by the same metric values used to determine how + * an outgoing IP packet will go, thus effectively using the DNS servers + * associated with the interface that the DNS requests themselves will + * travel. This gives us optimal routing and avoids issues where DNS servers + * won't respond to requests that don't arrive via some specific subnetwork + * (and thus some specific interface). + * + * This function computes the metric we use to sort. On the interface + * identified by \a luid, it determines the best route to \a dest and combines + * that route's metric with \a interfaceMetric to compute a metric for the + * destination address on that interface. This metric can be used as a weight + * to sort the DNS server addresses associated with each interface (lower is + * better). + * + * Note that by restricting the route search to the specific interface with + * which the DNS servers are associated, this function asks the question "What + * is the metric for sending IP packets to this DNS server?" which allows us + * to sort the DNS servers correctly. + */ +static ULONG getBestRouteMetric(IF_LUID * const luid, /* Can't be const :( */ + const SOCKADDR_INET * const dest, + const ULONG interfaceMetric) +{ + /* On this interface, get the best route to that destination. */ + MIB_IPFORWARD_ROW2 row; + SOCKADDR_INET ignored; + if(!ares_fpGetBestRoute2 || + ares_fpGetBestRoute2(/* The interface to use. The index is ignored since we are + * passing a LUID. + */ + luid, 0, + /* No specific source address. */ + NULL, + /* Our destination address. */ + dest, + /* No options. */ + 0, + /* The route row. */ + &row, + /* The best source address, which we don't need. */ + &ignored) != NO_ERROR + /* If the metric is "unused" (-1) or too large for us to add the two + * metrics, use the worst possible, thus sorting this last. + */ + || row.Metric == (ULONG)-1 + || row.Metric > ((ULONG)-1) - interfaceMetric) { + /* Return the worst possible metric. */ + return (ULONG)-1; + } + + /* Return the metric value from that row, plus the interface metric. + * + * See + * http://msdn.microsoft.com/en-us/library/windows/desktop/aa814494(v=vs.85).aspx + * which describes the combination as a "sum". + */ + return row.Metric + interfaceMetric; +} + /* * get_DNS_AdaptersAddresses() * @@ -1127,13 +1127,13 @@ static int get_DNS_AdaptersAddresses(char **outptr) int trying = IPAA_MAX_TRIES; int res; - /* The capacity of addresses, in elements. */ - size_t addressesSize; - /* The number of elements in addresses. */ - size_t addressesIndex = 0; - /* The addresses we will sort. */ - Address *addresses; - + /* The capacity of addresses, in elements. */ + size_t addressesSize; + /* The number of elements in addresses. */ + size_t addressesIndex = 0; + /* The addresses we will sort. */ + Address *addresses; + union { struct sockaddr *sa; struct sockaddr_in *sa4; @@ -1146,21 +1146,21 @@ static int get_DNS_AdaptersAddresses(char **outptr) if (ares_fpGetAdaptersAddresses == ZERO_NULL) return 0; - ipaa = ares_malloc(Bufsz); + ipaa = ares_malloc(Bufsz); if (!ipaa) return 0; - /* Start with enough room for a few DNS server addresses and we'll grow it - * as we encounter more. - */ - addressesSize = 4; - addresses = (Address*)ares_malloc(sizeof(Address) * addressesSize); - if(addresses == NULL) { - /* We need room for at least some addresses to function. */ - ares_free(ipaa); - return 0; - } - + /* Start with enough room for a few DNS server addresses and we'll grow it + * as we encounter more. + */ + addressesSize = 4; + addresses = (Address*)ares_malloc(sizeof(Address) * addressesSize); + if(addresses == NULL) { + /* We need room for at least some addresses to function. */ + ares_free(ipaa); + return 0; + } + /* Usually this call suceeds with initial buffer size */ res = (*ares_fpGetAdaptersAddresses) (AF_UNSPEC, AddrFlags, NULL, ipaa, &ReqBufsz); @@ -1171,7 +1171,7 @@ static int get_DNS_AdaptersAddresses(char **outptr) { if (Bufsz < ReqBufsz) { - newipaa = ares_realloc(ipaa, ReqBufsz); + newipaa = ares_realloc(ipaa, ReqBufsz); if (!newipaa) goto done; Bufsz = ReqBufsz; @@ -1187,15 +1187,15 @@ static int get_DNS_AdaptersAddresses(char **outptr) for (ipaaEntry = ipaa; ipaaEntry; ipaaEntry = ipaaEntry->Next) { - if(ipaaEntry->OperStatus != IfOperStatusUp) - continue; - - /* For each interface, find any associated DNS servers as IPv4 or IPv6 - * addresses. For each found address, find the best route to that DNS - * server address _on_ _that_ _interface_ (at this moment in time) and - * compute the resulting total metric, just as Windows routing will do. - * Then, sort all the addresses found by the metric. - */ + if(ipaaEntry->OperStatus != IfOperStatusUp) + continue; + + /* For each interface, find any associated DNS servers as IPv4 or IPv6 + * addresses. For each found address, find the best route to that DNS + * server address _on_ _that_ _interface_ (at this moment in time) and + * compute the resulting total metric, just as Windows routing will do. + * Then, sort all the addresses found by the metric. + */ for (ipaDNSAddr = ipaaEntry->FirstDnsServerAddress; ipaDNSAddr; ipaDNSAddr = ipaDNSAddr->Next) @@ -1207,124 +1207,124 @@ static int get_DNS_AdaptersAddresses(char **outptr) if ((namesrvr.sa4->sin_addr.S_un.S_addr == INADDR_ANY) || (namesrvr.sa4->sin_addr.S_un.S_addr == INADDR_NONE)) continue; - - /* Allocate room for another address, if necessary, else skip. */ - if(addressesIndex == addressesSize) { - const size_t newSize = addressesSize + 4; + + /* Allocate room for another address, if necessary, else skip. */ + if(addressesIndex == addressesSize) { + const size_t newSize = addressesSize + 4; Address * const newMem = - (Address*)ares_realloc(addresses, sizeof(Address) * newSize); - if(newMem == NULL) { - continue; - } - addresses = newMem; - addressesSize = newSize; - } - - /* Vista required for Luid or Ipv4Metric */ - if (ares_IsWindowsVistaOrGreater()) - { - /* Save the address as the next element in addresses. */ - addresses[addressesIndex].metric = - getBestRouteMetric(&ipaaEntry->Luid, - (SOCKADDR_INET*)(namesrvr.sa), - ipaaEntry->Ipv4Metric); - } - else - { + (Address*)ares_realloc(addresses, sizeof(Address) * newSize); + if(newMem == NULL) { + continue; + } + addresses = newMem; + addressesSize = newSize; + } + + /* Vista required for Luid or Ipv4Metric */ + if (ares_IsWindowsVistaOrGreater()) + { + /* Save the address as the next element in addresses. */ + addresses[addressesIndex].metric = + getBestRouteMetric(&ipaaEntry->Luid, + (SOCKADDR_INET*)(namesrvr.sa), + ipaaEntry->Ipv4Metric); + } + else + { addresses[addressesIndex].metric = (ULONG)-1; - } - - /* Record insertion index to make qsort stable */ - addresses[addressesIndex].orig_idx = addressesIndex; - + } + + /* Record insertion index to make qsort stable */ + addresses[addressesIndex].orig_idx = addressesIndex; + if (! ares_inet_ntop(AF_INET, &namesrvr.sa4->sin_addr, - addresses[addressesIndex].text, - sizeof(addresses[0].text))) { + addresses[addressesIndex].text, + sizeof(addresses[0].text))) { continue; - } - ++addressesIndex; + } + ++addressesIndex; } else if (namesrvr.sa->sa_family == AF_INET6) { if (memcmp(&namesrvr.sa6->sin6_addr, &ares_in6addr_any, sizeof(namesrvr.sa6->sin6_addr)) == 0) continue; - - /* Allocate room for another address, if necessary, else skip. */ - if(addressesIndex == addressesSize) { - const size_t newSize = addressesSize + 4; - Address * const newMem = - (Address*)ares_realloc(addresses, sizeof(Address) * newSize); - if(newMem == NULL) { - continue; - } - addresses = newMem; - addressesSize = newSize; - } - - /* Vista required for Luid or Ipv4Metric */ - if (ares_IsWindowsVistaOrGreater()) - { - /* Save the address as the next element in addresses. */ - addresses[addressesIndex].metric = - getBestRouteMetric(&ipaaEntry->Luid, + + /* Allocate room for another address, if necessary, else skip. */ + if(addressesIndex == addressesSize) { + const size_t newSize = addressesSize + 4; + Address * const newMem = + (Address*)ares_realloc(addresses, sizeof(Address) * newSize); + if(newMem == NULL) { + continue; + } + addresses = newMem; + addressesSize = newSize; + } + + /* Vista required for Luid or Ipv4Metric */ + if (ares_IsWindowsVistaOrGreater()) + { + /* Save the address as the next element in addresses. */ + addresses[addressesIndex].metric = + getBestRouteMetric(&ipaaEntry->Luid, (SOCKADDR_INET*)(namesrvr.sa), - ipaaEntry->Ipv6Metric); - } - else - { + ipaaEntry->Ipv6Metric); + } + else + { addresses[addressesIndex].metric = (ULONG)-1; - } - - /* Record insertion index to make qsort stable */ - addresses[addressesIndex].orig_idx = addressesIndex; - + } + + /* Record insertion index to make qsort stable */ + addresses[addressesIndex].orig_idx = addressesIndex; + if (! ares_inet_ntop(AF_INET6, &namesrvr.sa6->sin6_addr, - addresses[addressesIndex].text, - sizeof(addresses[0].text))) { + addresses[addressesIndex].text, + sizeof(addresses[0].text))) { continue; - } - ++addressesIndex; + } + ++addressesIndex; } - else { - /* Skip non-IPv4/IPv6 addresses completely. */ + else { + /* Skip non-IPv4/IPv6 addresses completely. */ continue; - } - } - } - - /* Sort all of the textual addresses by their metric (and original index if - * metrics are equal). */ - qsort(addresses, addressesIndex, sizeof(*addresses), compareAddresses); - - /* Join them all into a single string, removing duplicates. */ - { - size_t i; - for(i = 0; i < addressesIndex; ++i) { - size_t j; - /* Look for this address text appearing previously in the results. */ - for(j = 0; j < i; ++j) { - if(strcmp(addresses[j].text, addresses[i].text) == 0) { - break; - } - } - /* Iff we didn't emit this address already, emit it now. */ - if(j == i) { - /* Add that to outptr (if we can). */ - commajoin(outptr, addresses[i].text); - } + } + } + } + + /* Sort all of the textual addresses by their metric (and original index if + * metrics are equal). */ + qsort(addresses, addressesIndex, sizeof(*addresses), compareAddresses); + + /* Join them all into a single string, removing duplicates. */ + { + size_t i; + for(i = 0; i < addressesIndex; ++i) { + size_t j; + /* Look for this address text appearing previously in the results. */ + for(j = 0; j < i; ++j) { + if(strcmp(addresses[j].text, addresses[i].text) == 0) { + break; + } + } + /* Iff we didn't emit this address already, emit it now. */ + if(j == i) { + /* Add that to outptr (if we can). */ + commajoin(outptr, addresses[i].text); + } } } done: - ares_free(addresses); + ares_free(addresses); if (ipaa) - ares_free(ipaa); + ares_free(ipaa); - if (!*outptr) { + if (!*outptr) { return 0; - } + } return 1; } @@ -1345,49 +1345,49 @@ done: */ static int get_DNS_Windows(char **outptr) { - /* Try using IP helper API GetAdaptersAddresses(). IPv4 + IPv6, also sorts - * DNS servers by interface route metrics to try to use the best DNS server. */ + /* Try using IP helper API GetAdaptersAddresses(). IPv4 + IPv6, also sorts + * DNS servers by interface route metrics to try to use the best DNS server. */ if (get_DNS_AdaptersAddresses(outptr)) return 1; - /* Try using IP helper API GetNetworkParams(). IPv4 only. */ + /* Try using IP helper API GetNetworkParams(). IPv4 only. */ if (get_DNS_NetworkParams(outptr)) return 1; /* Fall-back to registry information */ return get_DNS_Registry(outptr); } - -/* - * get_SuffixList_Windows() - * - * Reads the "DNS Suffix Search List" from registry and writes the list items - * whitespace separated to outptr. If the Search List is empty, the - * "Primary Dns Suffix" is written to outptr. - * - * Returns 0 and nullifies *outptr upon inability to return the suffix list. - * - * Returns 1 and sets *outptr when returning a dynamically allocated string. - * + +/* + * get_SuffixList_Windows() + * + * Reads the "DNS Suffix Search List" from registry and writes the list items + * whitespace separated to outptr. If the Search List is empty, the + * "Primary Dns Suffix" is written to outptr. + * + * Returns 0 and nullifies *outptr upon inability to return the suffix list. + * + * Returns 1 and sets *outptr when returning a dynamically allocated string. + * * Implementation supports Windows Server 2003 and newer - */ -static int get_SuffixList_Windows(char **outptr) -{ - HKEY hKey, hKeyEnum; - char keyName[256]; - DWORD keyNameBuffSize; - DWORD keyIdx = 0; - char *p = NULL; - - *outptr = NULL; - - if (ares__getplatform() != WIN_NT) - return 0; - - /* 1. Global DNS Suffix Search List */ - if (RegOpenKeyExA(HKEY_LOCAL_MACHINE, WIN_NS_NT_KEY, 0, - KEY_READ, &hKey) == ERROR_SUCCESS) - { + */ +static int get_SuffixList_Windows(char **outptr) +{ + HKEY hKey, hKeyEnum; + char keyName[256]; + DWORD keyNameBuffSize; + DWORD keyIdx = 0; + char *p = NULL; + + *outptr = NULL; + + if (ares__getplatform() != WIN_NT) + return 0; + + /* 1. Global DNS Suffix Search List */ + if (RegOpenKeyExA(HKEY_LOCAL_MACHINE, WIN_NS_NT_KEY, 0, + KEY_READ, &hKey) == ERROR_SUCCESS) + { get_REG_SZ(hKey, SEARCHLIST_KEY, outptr); if (get_REG_SZ(hKey, DOMAIN_KEY, &p)) { @@ -1395,9 +1395,9 @@ static int get_SuffixList_Windows(char **outptr) ares_free(p); p = NULL; } - RegCloseKey(hKey); - } - + RegCloseKey(hKey); + } + if (RegOpenKeyExA(HKEY_LOCAL_MACHINE, WIN_NT_DNSCLIENT, 0, KEY_READ, &hKey) == ERROR_SUCCESS) { @@ -1410,26 +1410,26 @@ static int get_SuffixList_Windows(char **outptr) RegCloseKey(hKey); } - /* 2. Connection Specific Search List composed of: - * a. Primary DNS Suffix */ - if (RegOpenKeyExA(HKEY_LOCAL_MACHINE, WIN_DNSCLIENT, 0, - KEY_READ, &hKey) == ERROR_SUCCESS) - { + /* 2. Connection Specific Search List composed of: + * a. Primary DNS Suffix */ + if (RegOpenKeyExA(HKEY_LOCAL_MACHINE, WIN_DNSCLIENT, 0, + KEY_READ, &hKey) == ERROR_SUCCESS) + { if (get_REG_SZ(hKey, PRIMARYDNSSUFFIX_KEY, &p)) { commajoin(outptr, p); ares_free(p); p = NULL; } - RegCloseKey(hKey); - } - - /* b. Interface SearchList, Domain, DhcpDomain */ + RegCloseKey(hKey); + } + + /* b. Interface SearchList, Domain, DhcpDomain */ if (RegOpenKeyExA(HKEY_LOCAL_MACHINE, WIN_NS_NT_KEY "\\" INTERFACES_KEY, 0, - KEY_READ, &hKey) == ERROR_SUCCESS) - { + KEY_READ, &hKey) == ERROR_SUCCESS) + { for(;;) - { + { keyNameBuffSize = sizeof(keyName); if (RegEnumKeyExA(hKey, keyIdx++, keyName, &keyNameBuffSize, 0, NULL, NULL, NULL) @@ -1438,13 +1438,13 @@ static int get_SuffixList_Windows(char **outptr) if (RegOpenKeyExA(hKey, keyName, 0, KEY_QUERY_VALUE, &hKeyEnum) != ERROR_SUCCESS) continue; - /* p can be comma separated (SearchList) */ + /* p can be comma separated (SearchList) */ if (get_REG_SZ(hKeyEnum, SEARCHLIST_KEY, &p)) - { + { commajoin(outptr, p); ares_free(p); p = NULL; - } + } if (get_REG_SZ(hKeyEnum, DOMAIN_KEY, &p)) { commajoin(outptr, p); @@ -1458,19 +1458,19 @@ static int get_SuffixList_Windows(char **outptr) p = NULL; } RegCloseKey(hKeyEnum); - } + } RegCloseKey(hKey); - } - - return *outptr != NULL; -} + } + return *outptr != NULL; +} + #endif static int init_by_resolv_conf(ares_channel channel) { -#if !defined(ANDROID) && !defined(__ANDROID__) && !defined(WATT32) && \ - !defined(CARES_USE_LIBRESOLV) +#if !defined(ANDROID) && !defined(__ANDROID__) && !defined(WATT32) && \ + !defined(CARES_USE_LIBRESOLV) char *line = NULL; #endif int status = -1, nservers = 0, nsort = 0; @@ -1485,15 +1485,15 @@ static int init_by_resolv_conf(ares_channel channel) if (get_DNS_Windows(&line)) { status = config_nameserver(&servers, &nservers, line); - ares_free(line); - } - - if (channel->ndomains == -1 && get_SuffixList_Windows(&line)) - { - status = set_search(channel, line); - ares_free(line); + ares_free(line); } + if (channel->ndomains == -1 && get_SuffixList_Windows(&line)) + { + status = set_search(channel, line); + ares_free(line); + } + if (status == ARES_SUCCESS) status = ARES_EOF; else @@ -1509,7 +1509,7 @@ static int init_by_resolv_conf(ares_channel channel) line = getenv("Inet$Resolvers"); status = ARES_EOF; if (line) { - char *resolvers = ares_strdup(line), *pos, *space; + char *resolvers = ares_strdup(line), *pos, *space; if (!resolvers) return ARES_ENOMEM; @@ -1528,7 +1528,7 @@ static int init_by_resolv_conf(ares_channel channel) if (status == ARES_SUCCESS) status = ARES_EOF; - ares_free(resolvers); + ares_free(resolvers); } #elif defined(WATT32) @@ -1541,136 +1541,136 @@ static int init_by_resolv_conf(ares_channel channel) return ARES_SUCCESS; /* use localhost DNS server */ nservers = i; - servers = ares_malloc(sizeof(struct server_state)); + servers = ares_malloc(sizeof(struct server_state)); if (!servers) return ARES_ENOMEM; - memset(servers, 0, sizeof(struct server_state)); + 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; + servers[i].addr.udp_port = 0; + servers[i].addr.tcp_port = 0; } status = ARES_EOF; #elif defined(ANDROID) || defined(__ANDROID__) unsigned int i; - char **dns_servers; + char **dns_servers; char *domains; - size_t num_servers; - - /* Use the Android connectivity manager to get a list - * of DNS servers. As of Android 8 (Oreo) net.dns# - * system properties are no longer available. Google claims this - * improves privacy. Apps now need the ACCESS_NETWORK_STATE - * permission and must use the ConnectivityManager which - * is Java only. */ - dns_servers = ares_get_android_server_list(MAX_DNS_PROPERTIES, &num_servers); - if (dns_servers != NULL) - { - for (i = 0; i < num_servers; i++) - { - status = config_nameserver(&servers, &nservers, dns_servers[i]); - if (status != ARES_SUCCESS) - break; + size_t num_servers; + + /* Use the Android connectivity manager to get a list + * of DNS servers. As of Android 8 (Oreo) net.dns# + * system properties are no longer available. Google claims this + * improves privacy. Apps now need the ACCESS_NETWORK_STATE + * permission and must use the ConnectivityManager which + * is Java only. */ + dns_servers = ares_get_android_server_list(MAX_DNS_PROPERTIES, &num_servers); + if (dns_servers != NULL) + { + for (i = 0; i < num_servers; i++) + { + status = config_nameserver(&servers, &nservers, dns_servers[i]); + if (status != ARES_SUCCESS) + break; status = ARES_EOF; } - for (i = 0; i < num_servers; i++) - { - ares_free(dns_servers[i]); - } - ares_free(dns_servers); - } + for (i = 0; i < num_servers; i++) + { + ares_free(dns_servers[i]); + } + ares_free(dns_servers); + } if (channel->ndomains == -1) { domains = ares_get_android_search_domains_list(); set_search(channel, domains); ares_free(domains); } - -# ifdef HAVE___SYSTEM_PROPERTY_GET - /* Old way using the system property still in place as - * a fallback. Older android versions can still use this. - * it's possible for older apps not not have added the new - * permission and we want to try to avoid breaking those. - * - * We'll only run this if we don't have any dns servers - * because this will get the same ones (if it works). */ - if (status != ARES_EOF) { + +# ifdef HAVE___SYSTEM_PROPERTY_GET + /* Old way using the system property still in place as + * a fallback. Older android versions can still use this. + * it's possible for older apps not not have added the new + * permission and we want to try to avoid breaking those. + * + * We'll only run this if we don't have any dns servers + * because this will get the same ones (if it works). */ + if (status != ARES_EOF) { char propname[PROP_NAME_MAX]; char propvalue[PROP_VALUE_MAX]=""; - for (i = 1; i <= MAX_DNS_PROPERTIES; i++) { - snprintf(propname, sizeof(propname), "%s%u", DNS_PROP_NAME_PREFIX, i); - if (__system_property_get(propname, propvalue) < 1) { - status = ARES_EOF; - break; - } - - status = config_nameserver(&servers, &nservers, propvalue); - if (status != ARES_SUCCESS) - break; - status = ARES_EOF; - } - } -# endif /* HAVE___SYSTEM_PROPERTY_GET */ -#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)) { + for (i = 1; i <= MAX_DNS_PROPERTIES; i++) { + snprintf(propname, sizeof(propname), "%s%u", DNS_PROP_NAME_PREFIX, i); + if (__system_property_get(propname, propvalue) < 1) { + status = ARES_EOF; + break; + } + + status = config_nameserver(&servers, &nservers, propvalue); + if (status != ARES_SUCCESS) + break; + status = ARES_EOF; + } + } +# endif /* HAVE___SYSTEM_PROPERTY_GET */ +#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); + + 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 { @@ -1678,16 +1678,16 @@ static int init_by_resolv_conf(ares_channel channel) FILE *fp; size_t linesize; int error; - int update_domains; + int update_domains; const char *resolvconf_path; /* Don't read resolv.conf and friends if we don't have to */ if (ARES_CONFIG_CHECK(channel)) return ARES_SUCCESS; - /* Only update search domains if they're not already specified */ - update_domains = (channel->ndomains == -1); - + /* Only update search domains if they're not already specified */ + update_domains = (channel->ndomains == -1); + /* Support path for resolvconf filename set by ares_init_options */ if(channel->resolvconf_path) { resolvconf_path = channel->resolvconf_path; @@ -1699,11 +1699,11 @@ static int init_by_resolv_conf(ares_channel channel) if (fp) { while ((status = ares__read_line(fp, &line, &linesize)) == ARES_SUCCESS) { - if ((p = try_config(line, "domain", ';')) && update_domains) + 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", NULL, "file"); - else if ((p = try_config(line, "search", ';')) && update_domains) + 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) @@ -1743,7 +1743,7 @@ static int init_by_resolv_conf(ares_channel channel) ARES_SUCCESS) { if ((p = try_config(line, "hosts:", '\0')) && !channel->lookups) - (void)config_lookup(channel, p, "dns", "resolve", "files"); + (void)config_lookup(channel, p, "dns", "resolve", "files"); } fclose(fp); } @@ -1759,9 +1759,9 @@ static int init_by_resolv_conf(ares_channel channel) DEBUGF(fprintf(stderr, "Error opening file: %s\n", "/etc/nsswitch.conf")); } - - /* ignore error, maybe we will get luck in next if clause */ - status = ARES_EOF; + + /* ignore error, maybe we will get luck in next if clause */ + status = ARES_EOF; } } @@ -1774,7 +1774,7 @@ static int init_by_resolv_conf(ares_channel channel) { if ((p = try_config(line, "order", '\0')) && !channel->lookups) /* ignore errors */ - (void)config_lookup(channel, p, "bind", NULL, "hosts"); + (void)config_lookup(channel, p, "bind", NULL, "hosts"); } fclose(fp); } @@ -1790,9 +1790,9 @@ static int init_by_resolv_conf(ares_channel channel) DEBUGF(fprintf(stderr, "Error opening file: %s\n", "/etc/host.conf")); } - - /* ignore error, maybe we will get luck in next if clause */ - status = ARES_EOF; + + /* ignore error, maybe we will get luck in next if clause */ + status = ARES_EOF; } } @@ -1805,7 +1805,7 @@ static int init_by_resolv_conf(ares_channel channel) { if ((p = try_config(line, "hosts=", '\0')) && !channel->lookups) /* ignore errors */ - (void)config_lookup(channel, p, "bind", NULL, "local"); + (void)config_lookup(channel, p, "bind", NULL, "local"); } fclose(fp); } @@ -1820,14 +1820,14 @@ static int init_by_resolv_conf(ares_channel channel) error, strerror(error))); DEBUGF(fprintf(stderr, "Error opening file: %s\n", "/etc/svc.conf")); } - - /* ignore error, default value will be chosen for `channel->lookups` */ - status = ARES_EOF; + + /* ignore error, default value will be chosen for `channel->lookups` */ + status = ARES_EOF; } } if(line) - ares_free(line); + ares_free(line); } #endif @@ -1836,9 +1836,9 @@ static int init_by_resolv_conf(ares_channel channel) if (status != ARES_EOF) { if (servers != NULL) - ares_free(servers); + ares_free(servers); if (sortlist != NULL) - ares_free(sortlist); + ares_free(sortlist); return status; } @@ -1887,15 +1887,15 @@ static int init_by_defaults(ares_channel channel) if (channel->nservers == -1) { /* If nobody specified servers, try a local named. */ - channel->servers = ares_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->servers[0].addr.udp_port = 0; + channel->servers[0].addr.tcp_port = 0; channel->nservers = 1; } @@ -1920,7 +1920,7 @@ static int init_by_defaults(ares_channel channel) int res; channel->ndomains = 0; /* default to none */ - hostname = ares_malloc(len); + hostname = ares_malloc(len); if(!hostname) { rc = ARES_ENOMEM; goto error; @@ -1933,7 +1933,7 @@ static int init_by_defaults(ares_channel channel) char *p; len *= 2; lenv *= 2; - p = ares_realloc(hostname, len); + p = ares_realloc(hostname, len); if(!p) { rc = ARES_ENOMEM; goto error; @@ -1942,23 +1942,23 @@ static int init_by_defaults(ares_channel channel) continue; } else if(res) { - /* Lets not treat a gethostname failure as critical, since we - * are ok if gethostname doesn't even exist */ - *hostname = '\0'; - break; + /* Lets not treat a gethostname failure as critical, since we + * are ok if gethostname doesn't even exist */ + *hostname = '\0'; + break; } - } while (res != 0); + } while (res != 0); dot = strchr(hostname, '.'); if (dot) { /* a dot was found */ - channel->domains = ares_malloc(sizeof(char *)); + channel->domains = ares_malloc(sizeof(char *)); if (!channel->domains) { rc = ARES_ENOMEM; goto error; } - channel->domains[0] = ares_strdup(dot + 1); + channel->domains[0] = ares_strdup(dot + 1); if (!channel->domains[0]) { rc = ARES_ENOMEM; goto error; @@ -1974,7 +1974,7 @@ static int init_by_defaults(ares_channel channel) } if (!channel->lookups) { - channel->lookups = ares_strdup("fb"); + channel->lookups = ares_strdup("fb"); if (!channel->lookups) rc = ARES_ENOMEM; } @@ -1982,19 +1982,19 @@ static int init_by_defaults(ares_channel channel) error: if(rc) { if(channel->servers) { - ares_free(channel->servers); + ares_free(channel->servers); channel->servers = NULL; } if(channel->domains && channel->domains[0]) - ares_free(channel->domains[0]); + ares_free(channel->domains[0]); if(channel->domains) { - ares_free(channel->domains); + ares_free(channel->domains); channel->domains = NULL; } if(channel->lookups) { - ares_free(channel->lookups); + ares_free(channel->lookups); channel->lookups = NULL; } @@ -2005,13 +2005,13 @@ static int init_by_defaults(ares_channel channel) } if(hostname) - ares_free(hostname); + ares_free(hostname); return rc; } #if !defined(WIN32) && !defined(WATT32) && \ - !defined(ANDROID) && !defined(__ANDROID__) && !defined(CARES_USE_LIBRESOLV) + !defined(ANDROID) && !defined(__ANDROID__) && !defined(CARES_USE_LIBRESOLV) static int config_domain(ares_channel channel, char *str) { char *q; @@ -2033,16 +2033,16 @@ 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 *altbindch, - const char *filech) + const char *bindch, const char *altbindch, + const char *filech) { char lookups[3], *l; const char *vqualifier p; int found; - if (altbindch == NULL) - altbindch = bindch; - + 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. @@ -2052,8 +2052,8 @@ static int config_lookup(ares_channel channel, const char *str, found = 0; while (*p) { - if ((*p == *bindch || *p == *altbindch || *p == *filech) && l < lookups + 2) { - if (*p == *bindch || *p == *altbindch) *l++ = 'b'; + if ((*p == *bindch || *p == *altbindch || *p == *filech) && l < lookups + 2) { + if (*p == *bindch || *p == *altbindch) *l++ = 'b'; else *l++ = 'f'; found = 1; } @@ -2065,10 +2065,10 @@ static int config_lookup(ares_channel channel, const char *str, if (!found) return ARES_ENOTINITIALIZED; *l = '\0'; - channel->lookups = ares_strdup(lookups); + channel->lookups = ares_strdup(lookups); return (channel->lookups) ? ARES_SUCCESS : ARES_ENOMEM; } -#endif /* !WIN32 & !WATT32 & !ANDROID & !__ANDROID__ & !CARES_USE_LIBRESOLV */ +#endif /* !WIN32 & !WATT32 & !ANDROID & !__ANDROID__ & !CARES_USE_LIBRESOLV */ #ifndef WATT32 /* Validate that the ip address matches the subnet (network base and network @@ -2184,15 +2184,15 @@ static int config_nameserver(struct server_state **servers, int *nservers, continue; /* Resize servers state array. */ - newserv = ares_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; + 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)); @@ -2207,7 +2207,7 @@ static int config_nameserver(struct server_state **servers, int *nservers, return ARES_SUCCESS; } -#endif /* !WATT32 */ +#endif /* !WATT32 */ static int config_sortlist(struct apattern **sortlist, int *nsort, const char *str) @@ -2247,11 +2247,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)) { - ares_free(*sortlist); - *sortlist = NULL; + 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, @@ -2260,11 +2260,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)) { - ares_free(*sortlist); - *sortlist = NULL; + 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) @@ -2280,11 +2280,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)) { - ares_free(*sortlist); - *sortlist = NULL; + if (!sortlist_alloc(sortlist, nsort, &pat)) { + ares_free(*sortlist); + *sortlist = NULL; return ARES_ENOMEM; - } + } } else { @@ -2304,12 +2304,12 @@ static int set_search(ares_channel channel, const char *str) size_t cnt; if(channel->ndomains != -1) { - /* LCOV_EXCL_START: all callers check ndomains == -1 */ + /* LCOV_EXCL_START: all callers check ndomains == -1 */ /* if we already have some domains present, free them first */ ares_strsplit_free(channel->domains, channel->ndomains); channel->domains = NULL; channel->ndomains = -1; - } /* LCOV_EXCL_STOP */ + } /* LCOV_EXCL_STOP */ channel->domains = ares_strsplit(str, ", ", 1, &cnt); channel->ndomains = (int)cnt; @@ -2370,7 +2370,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(CARES_USE_LIBRESOLV) + !defined(ANDROID) && !defined(__ANDROID__) && !defined(CARES_USE_LIBRESOLV) static char *try_config(char *s, const char *opt, char scc) { size_t len; @@ -2379,7 +2379,7 @@ static char *try_config(char *s, const char *opt, char scc) if (!s || !opt) /* no line or no option */ - return NULL; /* LCOV_EXCL_LINE */ + 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. */ @@ -2411,7 +2411,7 @@ static char *try_config(char *s, const char *opt, char scc) if ((len = strlen(opt)) == 0) /* empty option */ - return NULL; /* LCOV_EXCL_LINE */ + return NULL; /* LCOV_EXCL_LINE */ if (strncmp(p, opt, len) != 0) /* line and option do not match */ @@ -2422,7 +2422,7 @@ static char *try_config(char *s, const char *opt, char scc) if (!*p) /* no option value */ - return NULL; /* LCOV_EXCL_LINE */ + return NULL; /* LCOV_EXCL_LINE */ if ((opt[len-1] != ':') && (opt[len-1] != '=') && !ISSPACE(*p)) /* whitespace between option name and value is mandatory @@ -2440,9 +2440,9 @@ static char *try_config(char *s, const char *opt, char scc) /* return pointer to option value */ return p; } -#endif /* !WIN32 & !WATT32 & !ANDROID & !__ANDROID__ */ +#endif /* !WIN32 & !WATT32 & !ANDROID & !__ANDROID__ */ -static int ip_addr(const char *ipbuf, ares_ssize_t len, struct in_addr *addr) +static int ip_addr(const char *ipbuf, ares_ssize_t len, struct in_addr *addr) { /* Four octets and three periods yields at most 15 characters. */ @@ -2475,19 +2475,19 @@ static void natural_mask(struct apattern *pat) pat->mask.addr4.s_addr = htonl(IN_CLASSC_NET); } -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; -} - +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 described in @@ -2519,7 +2519,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); /* LCOV_EXCL_LINE */ + key[counter]=(unsigned char)(rand() % 256); /* LCOV_EXCL_LINE */ } } @@ -2531,10 +2531,10 @@ static int init_id_key(rc4_key* key,int key_data_len) short counter; unsigned char *key_data_ptr = 0; - key_data_ptr = ares_malloc(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); + memset(key_data_ptr, 0, key_data_len); state = &key->state[0]; for(counter = 0; counter < 256; counter++) @@ -2553,7 +2553,7 @@ static int init_id_key(rc4_key* key,int key_data_len) index1 = (unsigned char)((index1 + 1) % key_data_len); } - ares_free(key_data_ptr); + ares_free(key_data_ptr); return ARES_SUCCESS; } @@ -2587,41 +2587,41 @@ 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; -} - -void ares_set_socket_functions(ares_channel channel, - const struct ares_socket_functions * funcs, - void *data) -{ - channel->sock_funcs = funcs; - channel->sock_func_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_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; +} + +void ares_set_socket_functions(ares_channel channel, + const struct ares_socket_functions * funcs, + void *data) +{ + channel->sock_funcs = funcs; + channel->sock_func_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/contrib/libs/c-ares/ares_ipv6.h b/contrib/libs/c-ares/ares_ipv6.h index fdbc21fe8f..48b8ee61dd 100644 --- a/contrib/libs/c-ares/ares_ipv6.h +++ b/contrib/libs/c-ares/ares_ipv6.h @@ -54,16 +54,16 @@ struct addrinfo #endif #ifndef NS_IN6ADDRSZ -#ifndef HAVE_STRUCT_IN6_ADDR +#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 @@ -78,7 +78,7 @@ struct addrinfo #endif #endif -/* Defined in inet_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/contrib/libs/c-ares/ares_library_init.c b/contrib/libs/c-ares/ares_library_init.c index 3c7ad37200..8eaae2a83c 100644 --- a/contrib/libs/c-ares/ares_library_init.c +++ b/contrib/libs/c-ares/ares_library_init.c @@ -29,20 +29,20 @@ fpGetNetworkParams_t ares_fpGetNetworkParams = ZERO_NULL; fpSystemFunction036_t ares_fpSystemFunction036 = ZERO_NULL; fpGetAdaptersAddresses_t ares_fpGetAdaptersAddresses = ZERO_NULL; -fpGetBestRoute2_t ares_fpGetBestRoute2 = ZERO_NULL; -#endif - -#if defined(ANDROID) || defined(__ANDROID__) -#include "ares_android.h" +fpGetBestRoute2_t ares_fpGetBestRoute2 = ZERO_NULL; #endif +#if defined(ANDROID) || defined(__ANDROID__) +#include "ares_android.h" +#endif + /* library-private global vars with source visibility restricted to this file */ static atomic_t ares_init_lock; static unsigned int ares_initialized; static int ares_init_flags; -/* library-private global vars with visibility across the whole library */ +/* library-private global vars with visibility across the whole library */ #if defined(WIN32) /* We need indirections to handle Windows DLL rules. */ static void *default_malloc(size_t size) { return malloc(size); } @@ -56,7 +56,7 @@ static void default_free(void *p) { free(p); } void *(*ares_malloc)(size_t size) = default_malloc; void *(*ares_realloc)(void *ptr, size_t size) = default_realloc; void (*ares_free)(void *ptr) = default_free; - + #ifdef USE_WINSOCK static HMODULE hnd_iphlpapi; static HMODULE hnd_advapi32; @@ -68,7 +68,7 @@ static int ares_win32_init(void) #ifdef USE_WINSOCK hnd_iphlpapi = 0; - hnd_iphlpapi = LoadLibraryW(L"iphlpapi.dll"); + hnd_iphlpapi = LoadLibraryW(L"iphlpapi.dll"); if (!hnd_iphlpapi) return ARES_ELOADIPHLPAPI; @@ -89,15 +89,15 @@ static int ares_win32_init(void) support Windows 2000 anymore */ } - ares_fpGetBestRoute2 = (fpGetBestRoute2_t) - GetProcAddress(hnd_iphlpapi, "GetBestRoute2"); - if (!ares_fpGetBestRoute2) - { - /* This can happen on clients before Vista, I don't - think it should be an error, unless we don't want to - support Windows XP anymore */ - } - + ares_fpGetBestRoute2 = (fpGetBestRoute2_t) + GetProcAddress(hnd_iphlpapi, "GetBestRoute2"); + if (!ares_fpGetBestRoute2) + { + /* This can happen on clients before Vista, I don't + think it should be an error, unless we don't want to + support Windows XP anymore */ + } + /* * When advapi32.dll is unavailable or advapi32.dll has no SystemFunction036, * also known as RtlGenRandom, which is the case for Windows versions prior @@ -105,7 +105,7 @@ static int ares_win32_init(void) */ hnd_advapi32 = 0; - hnd_advapi32 = LoadLibraryW(L"advapi32.dll"); + hnd_advapi32 = LoadLibraryW(L"advapi32.dll"); if (hnd_advapi32) { ares_fpSystemFunction036 = (fpSystemFunction036_t) @@ -149,21 +149,21 @@ int ares_library_init(int flags) return res; } -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); -} - - +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) { acquire_lock(&ares_init_lock); @@ -176,14 +176,14 @@ void ares_library_cleanup(void) if (ares_init_flags & ARES_LIB_INIT_WIN32) ares_win32_cleanup(); -#if defined(ANDROID) || defined(__ANDROID__) - ares_library_cleanup_android(); -#endif - +#if defined(ANDROID) || defined(__ANDROID__) + ares_library_cleanup_android(); +#endif + ares_init_flags = ARES_LIB_INIT_NONE; - ares_malloc = malloc; - ares_realloc = realloc; - ares_free = free; + ares_malloc = malloc; + ares_realloc = realloc; + ares_free = free; } } diff --git a/contrib/libs/c-ares/ares_library_init.h b/contrib/libs/c-ares/ares_library_init.h index 2a2ba118b5..8c86708f54 100644 --- a/contrib/libs/c-ares/ares_library_init.h +++ b/contrib/libs/c-ares/ares_library_init.h @@ -28,14 +28,14 @@ typedef DWORD (WINAPI *fpGetNetworkParams_t) (FIXED_INFO*, DWORD*); typedef BOOLEAN (APIENTRY *fpSystemFunction036_t) (void*, ULONG); typedef ULONG (WINAPI *fpGetAdaptersAddresses_t) ( ULONG, ULONG, void*, IP_ADAPTER_ADDRESSES*, ULONG* ); -typedef NETIO_STATUS (WINAPI *fpGetBestRoute2_t) ( NET_LUID *, NET_IFINDEX, const SOCKADDR_INET *, const SOCKADDR_INET *, ULONG, PMIB_IPFORWARD_ROW2, SOCKADDR_INET * ); +typedef NETIO_STATUS (WINAPI *fpGetBestRoute2_t) ( NET_LUID *, NET_IFINDEX, const SOCKADDR_INET *, const SOCKADDR_INET *, ULONG, PMIB_IPFORWARD_ROW2, SOCKADDR_INET * ); /* Forward-declaration of variables defined in ares_library_init.c */ /* that are global and unique instances for whole c-ares library. */ extern fpGetNetworkParams_t ares_fpGetNetworkParams; extern fpSystemFunction036_t ares_fpSystemFunction036; extern fpGetAdaptersAddresses_t ares_fpGetAdaptersAddresses; -extern fpGetBestRoute2_t ares_fpGetBestRoute2; +extern fpGetBestRoute2_t ares_fpGetBestRoute2; #endif /* USE_WINSOCK */ diff --git a/contrib/libs/c-ares/ares_nowarn.c b/contrib/libs/c-ares/ares_nowarn.c index f63d9135ec..ca5a12cbba 100644 --- a/contrib/libs/c-ares/ares_nowarn.c +++ b/contrib/libs/c-ares/ares_nowarn.c @@ -1,5 +1,5 @@ -/* Copyright (C) 2010-2013 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,10 +21,10 @@ # include <assert.h> #endif -#ifdef HAVE_LIMITS_H -#include <limits.h> -#endif - +#ifdef HAVE_LIMITS_H +#include <limits.h> +#endif + #if defined(__INTEL_COMPILER) && defined(__unix__) #ifdef HAVE_NETINET_IN_H @@ -40,22 +40,22 @@ #include "ares_nowarn.h" -#ifndef HAVE_LIMITS_H -/* systems without <limits.h> we guess have 16 bit shorts, 32bit ints and - 32bit longs */ +#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 -# define CARES_MASK_SINT 0x7FFFFFFF -# define CARES_MASK_UINT 0xFFFFFFFF -# define CARES_MASK_SLONG 0x7FFFFFFFL -# define CARES_MASK_ULONG 0xFFFFFFFFUL +# define CARES_MASK_SINT 0x7FFFFFFF +# define CARES_MASK_UINT 0xFFFFFFFF +# define CARES_MASK_SLONG 0x7FFFFFFFL +# define CARES_MASK_ULONG 0xFFFFFFFFUL #else -# 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 +# 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 /* @@ -151,10 +151,10 @@ int aresx_sltosi(long slnum) } /* -** signed ares_ssize_t to signed int +** signed ares_ssize_t to signed int */ -int aresx_sztosi(ares_ssize_t sznum) +int aresx_sztosi(ares_ssize_t sznum) { #ifdef __INTEL_COMPILER # pragma warning(push) @@ -162,7 +162,7 @@ int aresx_sztosi(ares_ssize_t sznum) #endif DEBUGASSERT(sznum >= 0); - return (int)(sznum & (ares_ssize_t) CARES_MASK_SINT); + return (int)(sznum & (ares_ssize_t) CARES_MASK_SINT); #ifdef __INTEL_COMPILER # pragma warning(pop) @@ -170,10 +170,10 @@ int aresx_sztosi(ares_ssize_t sznum) } /* -** signed ares_ssize_t to unsigned int +** signed ares_ssize_t to unsigned int */ -unsigned int aresx_sztoui(ares_ssize_t sznum) +unsigned int aresx_sztoui(ares_ssize_t sznum) { #ifdef __INTEL_COMPILER # pragma warning(push) @@ -181,7 +181,7 @@ unsigned int aresx_sztoui(ares_ssize_t sznum) #endif DEBUGASSERT(sznum >= 0); - return (unsigned int)(sznum & (ares_ssize_t) CARES_MASK_UINT); + return (unsigned int)(sznum & (ares_ssize_t) CARES_MASK_UINT); #ifdef __INTEL_COMPILER # pragma warning(pop) diff --git a/contrib/libs/c-ares/ares_nowarn.h b/contrib/libs/c-ares/ares_nowarn.h index 505e622098..579e499876 100644 --- a/contrib/libs/c-ares/ares_nowarn.h +++ b/contrib/libs/c-ares/ares_nowarn.h @@ -25,9 +25,9 @@ short aresx_sitoss(int sinum); int aresx_sltosi(long slnum); -int aresx_sztosi(ares_ssize_t sznum); +int aresx_sztosi(ares_ssize_t sznum); -unsigned int aresx_sztoui(ares_ssize_t sznum); +unsigned int aresx_sztoui(ares_ssize_t sznum); unsigned short aresx_sitous(int sinum); diff --git a/contrib/libs/c-ares/ares_options.c b/contrib/libs/c-ares/ares_options.c index de49de4625..4907d3f76d 100644 --- a/contrib/libs/c-ares/ares_options.c +++ b/contrib/libs/c-ares/ares_options.c @@ -83,63 +83,63 @@ 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_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) { @@ -148,7 +148,7 @@ int ares_set_servers(ares_channel channel, int i; if (ares_library_initialized() != ARES_SUCCESS) - return ARES_ENOTINITIALIZED; /* LCOV_EXCL_LINE: n/a on non-WinSock */ + return ARES_ENOTINITIALIZED; /* LCOV_EXCL_LINE: n/a on non-WinSock */ if (!channel) return ARES_ENODATA; @@ -166,7 +166,7 @@ int ares_set_servers(ares_channel channel, if (num_srvrs > 0) { /* Allocate storage for servers state */ - channel->servers = ares_malloc(num_srvrs * sizeof(struct server_state)); + channel->servers = ares_malloc(num_srvrs * sizeof(struct server_state)); if (!channel->servers) { return ARES_ENOMEM; @@ -176,8 +176,8 @@ 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; + 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)); @@ -192,62 +192,62 @@ int ares_set_servers(ares_channel 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; - +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; + if (!ares__is_list_empty(&channel->all_queries)) return ARES_ENOTIMP; - 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)); - 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; -} - + 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)); + 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; +} + /* Incomming string format: host[:port][,host[:port]]... */ /* IPv6 addresses with ports require square brackets [fe80::1%lo0]:53 */ -static int set_servers_csv(ares_channel channel, - const char* _csv, int use_port) +static int set_servers_csv(ares_channel channel, + const char* _csv, int use_port) { size_t i; char* csv = NULL; @@ -255,11 +255,11 @@ static int set_servers_csv(ares_channel channel, char* start_host; int cc = 0; int rv = ARES_SUCCESS; - struct ares_addr_port_node *servers = NULL; - struct ares_addr_port_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; /* LCOV_EXCL_LINE: n/a on non-WinSock */ + return ARES_ENOTINITIALIZED; /* LCOV_EXCL_LINE: n/a on non-WinSock */ if (!channel) return ARES_ENODATA; @@ -268,10 +268,10 @@ static int set_servers_csv(ares_channel channel, if (i == 0) return ARES_SUCCESS; /* blank all servers */ - csv = ares_malloc(i + 2); - if (!csv) - return ARES_ENOMEM; - + 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] = ','; @@ -293,10 +293,10 @@ static int set_servers_csv(ares_channel channel, else if (*ptr == ',') { char* pp = ptr - 1; char* p = ptr; - int port = 0; + int port = 0; struct in_addr in4; struct ares_in6_addr in6; - struct ares_addr_port_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. */ @@ -325,7 +325,7 @@ static int set_servers_csv(ares_channel channel, if (*pp == ']') p++; /* move p before ':' */ /* p will point to the start of the port */ - port = (int)strtol(p, NULL, 10); + port = (int)strtol(p, NULL, 10); *pp = 0; /* null terminate host */ } } @@ -339,7 +339,7 @@ static int set_servers_csv(ares_channel channel, goto out; } /* was ipv6, add new server */ - s = ares_malloc(sizeof(*s)); + s = ares_malloc(sizeof(*s)); if (!s) { rv = ARES_ENOMEM; goto out; @@ -349,7 +349,7 @@ static int set_servers_csv(ares_channel channel, } else { /* was ipv4, add new server */ - s = ares_malloc(sizeof(*s)); + s = ares_malloc(sizeof(*s)); if (!s) { rv = ARES_ENOMEM; goto out; @@ -358,8 +358,8 @@ static int set_servers_csv(ares_channel channel, memcpy(&s->addr, &in4, sizeof(struct in_addr)); } if (s) { - s->udp_port = use_port ? port: 0; - s->tcp_port = s->udp_port; + s->udp_port = use_port ? port: 0; + s->tcp_port = s->udp_port; s->next = NULL; if (last) { last->next = s; @@ -378,29 +378,29 @@ static int set_servers_csv(ares_channel channel, } } - rv = ares_set_servers_ports(channel, servers); + rv = ares_set_servers_ports(channel, servers); out: if (csv) - ares_free(csv); + ares_free(csv); while (servers) { - struct ares_addr_port_node *s = servers; + struct ares_addr_port_node *s = servers; servers = servers->next; - ares_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); -} - + +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/contrib/libs/c-ares/ares_parse_mx_reply.c b/contrib/libs/c-ares/ares_parse_mx_reply.c index 8d1703020c..95f7664daa 100644 --- a/contrib/libs/c-ares/ares_parse_mx_reply.c +++ b/contrib/libs/c-ares/ares_parse_mx_reply.c @@ -46,7 +46,7 @@ ares_parse_mx_reply (const unsigned char *abuf, int alen, { unsigned int qdcount, ancount, i; const unsigned char *aptr, *vptr; - int status, rr_type, rr_class, rr_len, rr_ttl; + int status, rr_type, rr_class, rr_len, rr_ttl; long len; char *hostname = NULL, *rr_name = NULL; struct ares_mx_reply *mx_head = NULL; @@ -76,7 +76,7 @@ ares_parse_mx_reply (const unsigned char *abuf, int alen, if (aptr + len + QFIXEDSZ > abuf + alen) { - ares_free (hostname); + ares_free (hostname); return ARES_EBADRESP; } aptr += len + QFIXEDSZ; @@ -99,7 +99,7 @@ ares_parse_mx_reply (const unsigned char *abuf, int alen, rr_type = DNS_RR_TYPE (aptr); rr_class = DNS_RR_CLASS (aptr); rr_len = DNS_RR_LEN (aptr); - rr_ttl = DNS_RR_TTL (aptr); + rr_ttl = DNS_RR_TTL (aptr); aptr += RRFIXEDSZ; if (aptr + rr_len > abuf + alen) { @@ -136,7 +136,7 @@ ares_parse_mx_reply (const unsigned char *abuf, int alen, vptr = aptr; mx_curr->priority = DNS__16BIT(vptr); - mx_curr->ttl = rr_ttl; + mx_curr->ttl = rr_ttl; vptr += sizeof(unsigned short); status = ares_expand_name (vptr, abuf, alen, &mx_curr->host, &len); @@ -145,7 +145,7 @@ ares_parse_mx_reply (const unsigned char *abuf, int alen, } /* Don't lose memory in the next iteration */ - ares_free (rr_name); + ares_free (rr_name); rr_name = NULL; /* Move on to the next record */ @@ -153,9 +153,9 @@ ares_parse_mx_reply (const unsigned char *abuf, int alen, } if (hostname) - ares_free (hostname); + ares_free (hostname); if (rr_name) - ares_free (rr_name); + ares_free (rr_name); /* clean up on error */ if (status != ARES_SUCCESS) diff --git a/contrib/libs/c-ares/ares_parse_naptr_reply.c b/contrib/libs/c-ares/ares_parse_naptr_reply.c index 04abc3c7ee..38e6bcd59b 100644 --- a/contrib/libs/c-ares/ares_parse_naptr_reply.c +++ b/contrib/libs/c-ares/ares_parse_naptr_reply.c @@ -51,7 +51,7 @@ ares_parse_naptr_reply (const unsigned char *abuf, int alen, { unsigned int qdcount, ancount, i; const unsigned char *aptr, *vptr; - int status, rr_type, rr_class, rr_len, rr_ttl; + int status, rr_type, rr_class, rr_len, rr_ttl; long len; char *hostname = NULL, *rr_name = NULL; struct ares_naptr_reply *naptr_head = NULL; @@ -81,7 +81,7 @@ ares_parse_naptr_reply (const unsigned char *abuf, int alen, if (aptr + len + QFIXEDSZ > abuf + alen) { - ares_free (hostname); + ares_free (hostname); return ARES_EBADRESP; } aptr += len + QFIXEDSZ; @@ -104,7 +104,7 @@ ares_parse_naptr_reply (const unsigned char *abuf, int alen, rr_type = DNS_RR_TYPE (aptr); rr_class = DNS_RR_CLASS (aptr); rr_len = DNS_RR_LEN (aptr); - rr_ttl = DNS_RR_TTL (aptr); + rr_ttl = DNS_RR_TTL (aptr); aptr += RRFIXEDSZ; if (aptr + rr_len > abuf + alen) { @@ -117,13 +117,13 @@ ares_parse_naptr_reply (const unsigned char *abuf, int alen, { /* parse the NAPTR record itself */ - /* RR must contain at least 7 bytes = 2 x int16 + 3 x name */ - if (rr_len < 7) - { - status = ARES_EBADRESP; - break; - } - + /* RR must contain at least 7 bytes = 2 x int16 + 3 x name */ + if (rr_len < 7) + { + status = ARES_EBADRESP; + break; + } + /* Allocate storage for this NAPTR answer appending it to the list */ naptr_curr = ares_malloc_data(ARES_DATATYPE_NAPTR_REPLY); if (!naptr_curr) @@ -141,7 +141,7 @@ ares_parse_naptr_reply (const unsigned char *abuf, int alen, } naptr_last = naptr_curr; - naptr_curr->ttl = rr_ttl; + naptr_curr->ttl = rr_ttl; vptr = aptr; naptr_curr->order = DNS__16BIT(vptr); vptr += sizeof(unsigned short); @@ -169,7 +169,7 @@ ares_parse_naptr_reply (const unsigned char *abuf, int alen, } /* Don't lose memory in the next iteration */ - ares_free (rr_name); + ares_free (rr_name); rr_name = NULL; /* Move on to the next record */ @@ -177,9 +177,9 @@ ares_parse_naptr_reply (const unsigned char *abuf, int alen, } if (hostname) - ares_free (hostname); + ares_free (hostname); if (rr_name) - ares_free (rr_name); + ares_free (rr_name); /* clean up on error */ if (status != ARES_SUCCESS) diff --git a/contrib/libs/c-ares/ares_parse_ns_reply.c b/contrib/libs/c-ares/ares_parse_ns_reply.c index 7bb51429db..9898769da4 100644 --- a/contrib/libs/c-ares/ares_parse_ns_reply.c +++ b/contrib/libs/c-ares/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 ) { - ares_free( hostname ); + ares_free( hostname ); return ARES_EBADRESP; } aptr += len + QFIXEDSZ; /* Allocate nameservers array; ancount gives an upper bound */ - nameservers = ares_malloc( ( ancount + 1 ) * sizeof( char * ) ); + nameservers = ares_malloc( ( ancount + 1 ) * sizeof( char * ) ); if ( !nameservers ) { - ares_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; - ares_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) { - ares_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 ) { - ares_free(rr_name); + ares_free(rr_name); break; } - nameservers[nameservers_num] = ares_malloc(strlen(rr_data)+1); + nameservers[nameservers_num] = ares_malloc(strlen(rr_data)+1); if (nameservers[nameservers_num]==NULL) { - ares_free(rr_name); - ares_free(rr_data); + ares_free(rr_name); + ares_free(rr_data); status=ARES_ENOMEM; break; } strcpy(nameservers[nameservers_num],rr_data); - ares_free(rr_data); + ares_free(rr_data); nameservers_num++; } - ares_free( rr_name ); + ares_free( rr_name ); aptr += rr_len; if ( aptr > abuf + alen ) - { /* LCOV_EXCL_START: already checked above */ + { /* LCOV_EXCL_START: already checked above */ status = ARES_EBADRESP; break; - } /* LCOV_EXCL_STOP */ + } /* 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 = ares_malloc( sizeof( struct hostent ) ); + hostent = ares_malloc( sizeof( struct hostent ) ); if ( hostent ) { - hostent->h_addr_list = ares_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; } - ares_free( hostent ); + ares_free( hostent ); } status = ARES_ENOMEM; } for ( i = 0; i < nameservers_num; i++ ) - ares_free( nameservers[i] ); - ares_free( nameservers ); - ares_free( hostname ); + ares_free( nameservers[i] ); + ares_free( nameservers ); + ares_free( hostname ); return status; } diff --git a/contrib/libs/c-ares/ares_parse_ptr_reply.c b/contrib/libs/c-ares/ares_parse_ptr_reply.c index 0e2b064bb4..b5325f7032 100644 --- a/contrib/libs/c-ares/ares_parse_ptr_reply.c +++ b/contrib/libs/c-ares/ares_parse_ptr_reply.c @@ -35,21 +35,21 @@ # include <strings.h> #endif -#ifdef HAVE_LIMITS_H -# include <limits.h> -#endif - +#ifdef HAVE_LIMITS_H +# include <limits.h> +#endif + #include "ares.h" #include "ares_dns.h" #include "ares_nowarn.h" #include "ares_private.h" int ares_parse_ptr_reply(const unsigned char *abuf, int alen, const void *addr, - int addrlen, int family, struct hostent **host, - int *hostttl) + int addrlen, int family, struct hostent **host, + int *hostttl) { unsigned int qdcount, ancount; - int status, i, rr_type, rr_class, rr_len, rr_ttl; + int status, i, rr_type, rr_class, rr_len, rr_ttl; long len; const unsigned char *aptr; char *ptrname, *hostname, *rr_name, *rr_data; @@ -61,8 +61,8 @@ int ares_parse_ptr_reply(const unsigned char *abuf, int alen, const void *addr, /* Set *host to NULL for all failure cases. */ *host = NULL; - if (hostttl) - *hostttl = INT_MAX; + if (hostttl) + *hostttl = INT_MAX; /* Give up if abuf doesn't have room for a header. */ if (alen < HFIXEDSZ) @@ -81,17 +81,17 @@ int ares_parse_ptr_reply(const unsigned char *abuf, int alen, const void *addr, return status; if (aptr + len + QFIXEDSZ > abuf + alen) { - ares_free(ptrname); + ares_free(ptrname); return ARES_EBADRESP; } aptr += len + QFIXEDSZ; /* Examine each answer resource record (RR) in turn. */ hostname = NULL; - aliases = ares_malloc(alias_alloc * sizeof(char *)); + aliases = ares_malloc(alias_alloc * sizeof(char *)); if (!aliases) { - ares_free(ptrname); + ares_free(ptrname); return ARES_ENOMEM; } for (i = 0; i < (int)ancount; i++) @@ -103,18 +103,18 @@ int ares_parse_ptr_reply(const unsigned char *abuf, int alen, const void *addr, aptr += len; if (aptr + RRFIXEDSZ > abuf + alen) { - ares_free(rr_name); + ares_free(rr_name); status = ARES_EBADRESP; break; } rr_type = DNS_RR_TYPE(aptr); rr_class = DNS_RR_CLASS(aptr); rr_len = DNS_RR_LEN(aptr); - rr_ttl = DNS_RR_TTL(aptr); + rr_ttl = DNS_RR_TTL(aptr); aptr += RRFIXEDSZ; if (aptr + rr_len > abuf + alen) { - ares_free(rr_name); + ares_free(rr_name); status = ARES_EBADRESP; break; } @@ -127,17 +127,17 @@ int ares_parse_ptr_reply(const unsigned char *abuf, int alen, const void *addr, &len); if (status != ARES_SUCCESS) { - ares_free(rr_name); + ares_free(rr_name); break; } if (hostname) - ares_free(hostname); + ares_free(hostname); hostname = rr_data; rr_data_len = strlen(rr_data)+1; aliases[aliascnt] = ares_malloc(rr_data_len * sizeof(char)); if (!aliases[aliascnt]) { - ares_free(rr_name); + ares_free(rr_name); status = ARES_ENOMEM; break; } @@ -146,21 +146,21 @@ int ares_parse_ptr_reply(const unsigned char *abuf, int alen, const void *addr, if (aliascnt >= alias_alloc) { char **ptr; alias_alloc *= 2; - ptr = ares_realloc(aliases, alias_alloc * sizeof(char *)); + ptr = ares_realloc(aliases, alias_alloc * sizeof(char *)); if(!ptr) { - ares_free(rr_name); + ares_free(rr_name); status = ARES_ENOMEM; break; } aliases = ptr; } - if (hostttl) - { - if (*hostttl > rr_ttl) - { - *hostttl = rr_ttl; - } - } + if (hostttl) + { + if (*hostttl > rr_ttl) + { + *hostttl = rr_ttl; + } + } } if (rr_class == C_IN && rr_type == T_CNAME) @@ -170,20 +170,20 @@ int ares_parse_ptr_reply(const unsigned char *abuf, int alen, const void *addr, &len); if (status != ARES_SUCCESS) { - ares_free(rr_name); + ares_free(rr_name); break; } - ares_free(ptrname); + ares_free(ptrname); ptrname = rr_data; } - ares_free(rr_name); + ares_free(rr_name); aptr += rr_len; if (aptr > abuf + alen) - { /* LCOV_EXCL_START: already checked above */ + { /* LCOV_EXCL_START: already checked above */ status = ARES_EBADRESP; break; - } /* LCOV_EXCL_STOP */ + } /* LCOV_EXCL_STOP */ } if (status == ARES_SUCCESS && !hostname) @@ -191,16 +191,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 = ares_malloc(sizeof(struct hostent)); + hostent = ares_malloc(sizeof(struct hostent)); if (hostent) { - hostent->h_addr_list = ares_malloc(2 * sizeof(char *)); + hostent->h_addr_list = ares_malloc(2 * sizeof(char *)); if (hostent->h_addr_list) { - hostent->h_addr_list[0] = ares_malloc(addrlen); + hostent->h_addr_list[0] = ares_malloc(addrlen); if (hostent->h_addr_list[0]) { - hostent->h_aliases = ares_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. */ @@ -213,24 +213,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; - ares_free(aliases); - ares_free(ptrname); + ares_free(aliases); + ares_free(ptrname); return ARES_SUCCESS; } - ares_free(hostent->h_addr_list[0]); + ares_free(hostent->h_addr_list[0]); } - ares_free(hostent->h_addr_list); + ares_free(hostent->h_addr_list); } - ares_free(hostent); + ares_free(hostent); } status = ARES_ENOMEM; } for (i=0 ; i<aliascnt ; i++) if (aliases[i]) - ares_free(aliases[i]); - ares_free(aliases); + ares_free(aliases[i]); + ares_free(aliases); if (hostname) - ares_free(hostname); - ares_free(ptrname); + ares_free(hostname); + ares_free(ptrname); return status; } diff --git a/contrib/libs/c-ares/ares_parse_soa_reply.c b/contrib/libs/c-ares/ares_parse_soa_reply.c index 8b84a368db..8288a534a8 100644 --- a/contrib/libs/c-ares/ares_parse_soa_reply.c +++ b/contrib/libs/c-ares/ares_parse_soa_reply.c @@ -50,7 +50,7 @@ ares_parse_soa_reply(const unsigned char *abuf, int alen, struct ares_soa_reply *soa = NULL; int qdcount, ancount, qclass; int status, i, rr_type, rr_class, rr_len; - int ttl; + int ttl; if (alen < HFIXEDSZ) return ARES_EBADRESP; @@ -96,11 +96,11 @@ ares_parse_soa_reply(const unsigned char *abuf, int alen, aptr += len; if ( aptr + RRFIXEDSZ > abuf + alen ) - { + { ares_free(rr_name); status = ARES_EBADRESP; - goto failed_stat; - } + goto failed_stat; + } rr_type = DNS_RR_TYPE( aptr ); rr_class = DNS_RR_CLASS( aptr ); rr_len = DNS_RR_LEN( aptr ); @@ -180,6 +180,6 @@ failed_stat: if (soa) ares_free_data(soa); if (qname) - ares_free(qname); + ares_free(qname); return status; } diff --git a/contrib/libs/c-ares/ares_parse_srv_reply.c b/contrib/libs/c-ares/ares_parse_srv_reply.c index 72a2dd4e96..538d68fc84 100644 --- a/contrib/libs/c-ares/ares_parse_srv_reply.c +++ b/contrib/libs/c-ares/ares_parse_srv_reply.c @@ -51,7 +51,7 @@ ares_parse_srv_reply (const unsigned char *abuf, int alen, { unsigned int qdcount, ancount, i; const unsigned char *aptr, *vptr; - int status, rr_type, rr_class, rr_len, rr_ttl; + int status, rr_type, rr_class, rr_len, rr_ttl; long len; char *hostname = NULL, *rr_name = NULL; struct ares_srv_reply *srv_head = NULL; @@ -81,7 +81,7 @@ ares_parse_srv_reply (const unsigned char *abuf, int alen, if (aptr + len + QFIXEDSZ > abuf + alen) { - ares_free (hostname); + ares_free (hostname); return ARES_EBADRESP; } aptr += len + QFIXEDSZ; @@ -104,7 +104,7 @@ ares_parse_srv_reply (const unsigned char *abuf, int alen, rr_type = DNS_RR_TYPE (aptr); rr_class = DNS_RR_CLASS (aptr); rr_len = DNS_RR_LEN (aptr); - rr_ttl = DNS_RR_TTL(aptr); + rr_ttl = DNS_RR_TTL(aptr); aptr += RRFIXEDSZ; if (aptr + rr_len > abuf + alen) { @@ -146,7 +146,7 @@ ares_parse_srv_reply (const unsigned char *abuf, int alen, vptr += sizeof(unsigned short); srv_curr->port = DNS__16BIT(vptr); vptr += sizeof(unsigned short); - srv_curr->ttl = rr_ttl; + srv_curr->ttl = rr_ttl; status = ares_expand_name (vptr, abuf, alen, &srv_curr->host, &len); if (status != ARES_SUCCESS) @@ -154,7 +154,7 @@ ares_parse_srv_reply (const unsigned char *abuf, int alen, } /* Don't lose memory in the next iteration */ - ares_free (rr_name); + ares_free (rr_name); rr_name = NULL; /* Move on to the next record */ @@ -162,9 +162,9 @@ ares_parse_srv_reply (const unsigned char *abuf, int alen, } if (hostname) - ares_free (hostname); + ares_free (hostname); if (rr_name) - ares_free (rr_name); + ares_free (rr_name); /* clean up on error */ if (status != ARES_SUCCESS) diff --git a/contrib/libs/c-ares/ares_parse_txt_reply.c b/contrib/libs/c-ares/ares_parse_txt_reply.c index c685dfd052..76ebbe19aa 100644 --- a/contrib/libs/c-ares/ares_parse_txt_reply.c +++ b/contrib/libs/c-ares/ares_parse_txt_reply.c @@ -44,20 +44,20 @@ #include "ares_data.h" #include "ares_private.h" -static int -ares__parse_txt_reply (const unsigned char *abuf, int alen, - int ex, void **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; const unsigned char *aptr; const unsigned char *strptr; - int status, rr_type, rr_class, rr_len, rr_ttl; + int status, rr_type, rr_class, rr_len, rr_ttl; long len; char *hostname = NULL, *rr_name = NULL; - struct ares_txt_ext *txt_head = NULL; - struct ares_txt_ext *txt_last = NULL; - struct ares_txt_ext *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) { - ares_free (hostname); + ares_free (hostname); return ARES_EBADRESP; } aptr += len + QFIXEDSZ; @@ -105,7 +105,7 @@ ares__parse_txt_reply (const unsigned char *abuf, int alen, rr_type = DNS_RR_TYPE (aptr); rr_class = DNS_RR_CLASS (aptr); rr_len = DNS_RR_LEN (aptr); - rr_ttl = DNS_RR_TTL (aptr); + rr_ttl = DNS_RR_TTL (aptr); aptr += RRFIXEDSZ; if (aptr + rr_len > abuf + alen) { @@ -135,8 +135,8 @@ ares__parse_txt_reply (const unsigned char *abuf, int alen, } /* Allocate storage for this TXT answer appending it to the list */ - txt_curr = ares_malloc_data(ex ? ARES_DATATYPE_TXT_EXT : - 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,35 +152,35 @@ ares__parse_txt_reply (const unsigned char *abuf, int alen, } txt_last = txt_curr; - if (ex) - txt_curr->record_start = (strptr == aptr); + if (ex) + txt_curr->record_start = (strptr == aptr); txt_curr->length = substr_len; - txt_curr->txt = ares_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; + + ++strptr; memcpy ((char *) txt_curr->txt, strptr, substr_len); /* Make sure we NULL-terminate */ txt_curr->txt[substr_len] = 0; - txt_curr->ttl = rr_ttl; + txt_curr->ttl = rr_ttl; strptr += substr_len; } } - /* Propagate any failures */ - if (status != ARES_SUCCESS) - { - break; - } - + /* Propagate any failures */ + if (status != ARES_SUCCESS) + { + break; + } + /* Don't lose memory in the next iteration */ - ares_free (rr_name); + ares_free (rr_name); rr_name = NULL; /* Move on to the next record */ @@ -188,9 +188,9 @@ ares__parse_txt_reply (const unsigned char *abuf, int alen, } if (hostname) - ares_free (hostname); + ares_free (hostname); if (rr_name) - ares_free (rr_name); + ares_free (rr_name); /* clean up on error */ if (status != ARES_SUCCESS) @@ -205,18 +205,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); -} + +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/contrib/libs/c-ares/ares_platform.c b/contrib/libs/c-ares/ares_platform.c index 6c749dccb2..ae207f2ef1 100644 --- a/contrib/libs/c-ares/ares_platform.c +++ b/contrib/libs/c-ares/ares_platform.c @@ -36,10 +36,10 @@ win_platform ares__getplatform(void) memset(&OsvEx, 0, sizeof(OsvEx)); OsvEx.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); -#ifdef _MSC_VER -#pragma warning(push) -#pragma warning(disable:4996) /* warning C4996: 'GetVersionExW': was declared deprecated */ -#endif +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable:4996) /* warning C4996: 'GetVersionExW': was declared deprecated */ +#endif if (!GetVersionEx((void *)&OsvEx)) { memset(&OsvEx, 0, sizeof(OsvEx)); @@ -47,9 +47,9 @@ win_platform ares__getplatform(void) if (!GetVersionEx((void *)&OsvEx)) return WIN_UNKNOWN; } -#ifdef _MSC_VER -#pragma warning(pop) -#endif +#ifdef _MSC_VER +#pragma warning(pop) +#endif switch(OsvEx.dwPlatformId) { diff --git a/contrib/libs/c-ares/ares_private.h b/contrib/libs/c-ares/ares_private.h index 3312ed1932..aa50f576f0 100644 --- a/contrib/libs/c-ares/ares_private.h +++ b/contrib/libs/c-ares/ares_private.h @@ -43,13 +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 - +#ifdef CARES_EXPOSE_STATICS +/* Make some internal functions visible for testing */ +#define STATIC_TESTABLE +#else +#define STATIC_TESTABLE static +#endif + /* By using a double cast, we can get rid of the bogus warning of * warning: cast from 'const struct sockaddr *' to 'const struct sockaddr_in6 *' increases required alignment from 1 to 4 [-Wcast-align] */ @@ -66,7 +66,7 @@ #define DATABASEPATH "DatabasePath" #define WIN_PATH_HOSTS "\\hosts" #define SEARCHLIST_KEY "SearchList" -#define PRIMARYDNSSUFFIX_KEY "PrimaryDNSSuffix" +#define PRIMARYDNSSUFFIX_KEY "PrimaryDNSSuffix" #define INTERFACES_KEY "Interfaces" #define DOMAIN_KEY "Domain" #define DHCPDOMAIN_KEY "DhcpDomain" @@ -105,7 +105,7 @@ # define getenv(ptr) ares_getenv(ptr) #endif -#include "ares_strdup.h" +#include "ares_strdup.h" #include "ares_strsplit.h" #ifndef HAVE_STRCASECMP @@ -136,8 +136,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 */ + int udp_port; /* stored in network order */ + int tcp_port; /* stored in network order */ }; #define addrV4 addr.addr4 #define addrV6 addr.addr6 @@ -273,8 +273,8 @@ struct ares_channeldata { int tries; int ndots; int rotate; /* if true, all servers specified are used */ - int udp_port; /* stored in network order */ - int tcp_port; /* stored in network order */ + 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; @@ -327,12 +327,12 @@ 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; - - const struct ares_socket_functions * sock_funcs; - void *sock_func_cb_data; + + ares_sock_config_callback sock_config_cb; + void *sock_config_cb_data; + + const struct ares_socket_functions * sock_funcs; + void *sock_func_cb_data; /* Path for resolv.conf file, configurable via ares_options */ char *resolvconf_path; @@ -341,15 +341,15 @@ struct ares_channeldata { /* Does the domain end in ".onion" or ".onion."? Case-insensitive. */ int ares__is_onion_domain(const char *name); -/* 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); - +/* 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); - + void ares__send_query(ares_channel channel, struct query *query, struct timeval *now); void ares__close_sockets(ares_channel channel, struct server_state *server); @@ -408,7 +408,7 @@ int ares__connect_socket(ares_channel channel, ares_socket_t sockfd, const struct sockaddr *addr, ares_socklen_t addrlen); - + #define ARES_SWAP_BYTE(a,b) \ { unsigned char swapByte = *(a); *(a) = *(b); *(b) = swapByte; } diff --git a/contrib/libs/c-ares/ares_process.c b/contrib/libs/c-ares/ares_process.c index 25095d0f05..1b464c03fc 100644 --- a/contrib/libs/c-ares/ares_process.c +++ b/contrib/libs/c-ares/ares_process.c @@ -1,6 +1,6 @@ /* Copyright 1998 by the Massachusetts Institute of Technology. - * Copyright (C) 2004-2017 by Daniel Stenberg + * Copyright (C) 2004-2017 by Daniel Stenberg * * Permission to use, copy, modify, and distribute this * software and its documentation for any purpose and without @@ -29,9 +29,9 @@ #ifdef HAVE_NETDB_H # include <netdb.h> #endif -#ifdef HAVE_ARPA_INET_H -# include <arpa/inet.h> -#endif +#ifdef HAVE_ARPA_INET_H +# include <arpa/inet.h> +#endif #ifdef HAVE_ARPA_NAMESER_H # include <arpa/nameser.h> #else @@ -69,7 +69,7 @@ static void read_tcp_data(ares_channel channel, fd_set *read_fds, static void read_udp_packets(ares_channel channel, fd_set *read_fds, ares_socket_t read_fd, struct timeval *now); static void advance_tcp_send_queue(ares_channel channel, int whichserver, - ares_ssize_t num_bytes); + ares_ssize_t num_bytes); static void process_timeouts(ares_channel channel, struct timeval *now); static void process_broken_connections(ares_channel channel, struct timeval *now); @@ -106,7 +106,7 @@ int ares__timedout(struct timeval *now, } /* add the specific number of milliseconds to the time in the first argument */ -static void 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; @@ -179,26 +179,26 @@ static int try_again(int errnum) return 0; } -static ares_ssize_t socket_writev(ares_channel channel, ares_socket_t s, const struct iovec * vec, int len) -{ - if (channel->sock_funcs) - return channel->sock_funcs->asendv(s, vec, len, channel->sock_func_cb_data); - - return writev(s, vec, len); -} - -static ares_ssize_t socket_write(ares_channel channel, ares_socket_t s, const void * data, size_t len) -{ - if (channel->sock_funcs) - { - struct iovec vec; - vec.iov_base = (void*)data; - vec.iov_len = len; - return channel->sock_funcs->asendv(s, &vec, 1, channel->sock_func_cb_data); - } - return swrite(s, data, len); -} - +static ares_ssize_t socket_writev(ares_channel channel, ares_socket_t s, const struct iovec * vec, int len) +{ + if (channel->sock_funcs) + return channel->sock_funcs->asendv(s, vec, len, channel->sock_func_cb_data); + + return writev(s, vec, len); +} + +static ares_ssize_t socket_write(ares_channel channel, ares_socket_t s, const void * data, size_t len) +{ + if (channel->sock_funcs) + { + struct iovec vec; + vec.iov_base = (void*)data; + vec.iov_len = len; + return channel->sock_funcs->asendv(s, &vec, 1, channel->sock_func_cb_data); + } + return swrite(s, data, len); +} + /* If any TCP sockets select true for writing, write out queued data * we have for them. */ @@ -211,8 +211,8 @@ static void write_tcp_data(ares_channel channel, struct send_request *sendreq; struct iovec *vec; int i; - ares_ssize_t scount; - ares_ssize_t wcount; + ares_ssize_t scount; + ares_ssize_t wcount; size_t n; if(!write_fds && (write_fd == ARES_SOCKET_BAD)) @@ -251,7 +251,7 @@ static void write_tcp_data(ares_channel channel, n++; /* Allocate iovecs so we can send all our data at once. */ - vec = ares_malloc(n * sizeof(struct iovec)); + vec = ares_malloc(n * sizeof(struct iovec)); if (vec) { /* Fill in the iovecs and send. */ @@ -262,8 +262,8 @@ static void write_tcp_data(ares_channel channel, vec[n].iov_len = sendreq->len; n++; } - wcount = socket_writev(channel, server->tcp_socket, vec, (int)n); - ares_free(vec); + wcount = socket_writev(channel, server->tcp_socket, vec, (int)n); + ares_free(vec); if (wcount < 0) { if (!try_again(SOCKERRNO)) @@ -279,7 +279,7 @@ static void write_tcp_data(ares_channel channel, /* Can't allocate iovecs; just send the first request. */ sendreq = server->qhead; - scount = socket_write(channel, server->tcp_socket, sendreq->data, sendreq->len); + scount = socket_write(channel, server->tcp_socket, sendreq->data, sendreq->len); if (scount < 0) { if (!try_again(SOCKERRNO)) @@ -295,7 +295,7 @@ static void write_tcp_data(ares_channel channel, /* Consume the given number of bytes from the head of the TCP send queue. */ static void advance_tcp_send_queue(ares_channel channel, int whichserver, - ares_ssize_t num_bytes) + ares_ssize_t num_bytes) { struct send_request *sendreq; struct server_state *server = &channel->servers[whichserver]; @@ -305,8 +305,8 @@ static void advance_tcp_send_queue(ares_channel channel, int whichserver, num_bytes -= sendreq->len; server->qhead = sendreq->next; if (sendreq->data_storage) - ares_free(sendreq->data_storage); - ares_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; @@ -323,38 +323,38 @@ static void advance_tcp_send_queue(ares_channel channel, int whichserver, } } -static ares_ssize_t socket_recvfrom(ares_channel channel, - ares_socket_t s, - void * data, - size_t data_len, - int flags, - struct sockaddr *from, - ares_socklen_t *from_len) -{ - if (channel->sock_funcs) - return channel->sock_funcs->arecvfrom(s, data, data_len, - flags, from, from_len, - channel->sock_func_cb_data); - -#ifdef HAVE_RECVFROM - return recvfrom(s, data, data_len, flags, from, from_len); -#else - return sread(s, data, data_len); -#endif -} - -static ares_ssize_t socket_recv(ares_channel channel, - ares_socket_t s, - void * data, - size_t data_len) -{ - if (channel->sock_funcs) - return channel->sock_funcs->arecvfrom(s, data, data_len, 0, 0, 0, - channel->sock_func_cb_data); - - return sread(s, data, data_len); -} - +static ares_ssize_t socket_recvfrom(ares_channel channel, + ares_socket_t s, + void * data, + size_t data_len, + int flags, + struct sockaddr *from, + ares_socklen_t *from_len) +{ + if (channel->sock_funcs) + return channel->sock_funcs->arecvfrom(s, data, data_len, + flags, from, from_len, + channel->sock_func_cb_data); + +#ifdef HAVE_RECVFROM + return recvfrom(s, data, data_len, flags, from, from_len); +#else + return sread(s, data, data_len); +#endif +} + +static ares_ssize_t socket_recv(ares_channel channel, + ares_socket_t s, + void * data, + size_t data_len) +{ + if (channel->sock_funcs) + return channel->sock_funcs->arecvfrom(s, data, data_len, 0, 0, 0, + channel->sock_func_cb_data); + + return sread(s, data, data_len); +} + /* If any TCP socket selects true for reading, read some data, * allocate a buffer if we finish reading the length word, and process * a packet if we finish reading one. @@ -364,7 +364,7 @@ static void read_tcp_data(ares_channel channel, fd_set *read_fds, { struct server_state *server; int i; - ares_ssize_t count; + ares_ssize_t count; if(!read_fds && (read_fd == ARES_SOCKET_BAD)) /* no possible action */ @@ -399,9 +399,9 @@ static void read_tcp_data(ares_channel channel, fd_set *read_fds, /* We haven't yet read a length word, so read that (or * what's left to read of it). */ - count = socket_recv(channel, server->tcp_socket, - server->tcp_lenbuf + server->tcp_lenbuf_pos, - 2 - server->tcp_lenbuf_pos); + count = socket_recv(channel, server->tcp_socket, + server->tcp_lenbuf + server->tcp_lenbuf_pos, + 2 - server->tcp_lenbuf_pos); if (count <= 0) { if (!(count == -1 && try_again(SOCKERRNO))) @@ -417,21 +417,21 @@ 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 = ares_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 */ - } + return; /* bail out on malloc failure. TODO: make this + function return error codes */ + } server->tcp_buffer_pos = 0; } } else { /* Read data into the allocated buffer. */ - count = socket_recv(channel, server->tcp_socket, - server->tcp_buffer + server->tcp_buffer_pos, - server->tcp_length - server->tcp_buffer_pos); + count = socket_recv(channel, server->tcp_socket, + server->tcp_buffer + server->tcp_buffer_pos, + server->tcp_length - server->tcp_buffer_pos); if (count <= 0) { if (!(count == -1 && try_again(SOCKERRNO))) @@ -447,7 +447,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); - ares_free(server->tcp_buffer); + ares_free(server->tcp_buffer); server->tcp_buffer = NULL; server->tcp_lenbuf_pos = 0; server->tcp_buffer_pos = 0; @@ -462,7 +462,7 @@ static void read_udp_packets(ares_channel channel, fd_set *read_fds, { struct server_state *server; int i; - ares_ssize_t count; + ares_ssize_t count; unsigned char buf[MAXENDSSZ + 1]; #ifdef HAVE_RECVFROM ares_socklen_t fromlen; @@ -513,8 +513,8 @@ static void read_udp_packets(ares_channel channel, fd_set *read_fds, fromlen = sizeof(from.sa4); else fromlen = sizeof(from.sa6); - count = socket_recvfrom(channel, server->udp_socket, (void *)buf, - sizeof(buf), 0, &from.sa, &fromlen); + count = socket_recvfrom(channel, server->udp_socket, (void *)buf, + sizeof(buf), 0, &from.sa, &fromlen); } if (count == -1 && try_again(SOCKERRNO)) @@ -617,15 +617,15 @@ static void process_answer(ares_channel channel, unsigned char *abuf, packetsz = channel->ednspsz; if (rcode == NOTIMP || rcode == FORMERR || rcode == SERVFAIL) { - int qlen = (query->tcplen - 2) - 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 = ares_realloc(query->tcpbuf, query->tcplen); - query->qbuf = query->tcpbuf + 2; + query->tcpbuf = ares_realloc(query->tcpbuf, query->tcplen); + query->qbuf = query->tcpbuf + 2; ares__send_query(channel, query, now); return; } @@ -824,13 +824,13 @@ void ares__send_query(ares_channel channel, struct query *query, return; } } - sendreq = ares_malloc(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)); + 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 @@ -864,7 +864,7 @@ void ares__send_query(ares_channel channel, struct query *query, return; } } - if (socket_write(channel, server->udp_socket, query->qbuf, query->qlen) == -1) + if (socket_write(channel, server->udp_socket, query->qbuf, query->qlen) == -1) { /* FIXME: Handle EAGAIN here since it likely can happen. */ skip_server(channel, query, query->server); @@ -920,7 +920,7 @@ void ares__send_query(ares_channel channel, struct query *query, } query->timeout = *now; - timeadd(&query->timeout, timeplus); + timeadd(&query->timeout, timeplus); /* Keep track of queries bucketed by timeout, so we can process * timeout events quickly. */ @@ -944,7 +944,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) @@ -958,7 +958,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)); /* LCOV_EXCL_LINE */ + return fcntl(sockfd, F_SETFL, flags & (~O_NONBLOCK)); /* LCOV_EXCL_LINE */ #elif defined(HAVE_IOCTL_FIONBIO) @@ -1001,16 +1001,16 @@ static int configure_socket(ares_socket_t s, int family, ares_channel channel) struct sockaddr_in6 sa6; } local; - /* do not set options for user-managed sockets */ - if (channel->sock_funcs) - return 0; - - (void)setsocknonblock(s, TRUE); + /* do not set options for user-managed sockets */ + if (channel->sock_funcs) + return 0; + (void)setsocknonblock(s, TRUE); + #if defined(FD_CLOEXEC) && !defined(MSDOS) /* Configure the socket fd as close-on-exec. */ if (fcntl(s, F_SETFD, FD_CLOEXEC) == -1) - return -1; /* LCOV_EXCL_LINE */ + return -1; /* LCOV_EXCL_LINE */ #endif /* Set the socket's send and receive buffer sizes. */ @@ -1078,11 +1078,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; - 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); - } + 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; @@ -1091,16 +1091,16 @@ 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; - 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); - } + 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; /* LCOV_EXCL_LINE */ + return -1; /* LCOV_EXCL_LINE */ } /* Acquire a socket. */ @@ -1123,27 +1123,27 @@ static int open_tcp_socket(ares_channel channel, struct server_state *server) * so batching isn't very interesting. */ opt = 1; - if (channel->sock_funcs == 0 - && - setsockopt(s, IPPROTO_TCP, TCP_NODELAY, - (void *)&opt, sizeof(opt)) == -1) + if (channel->sock_funcs == 0 + && + setsockopt(s, IPPROTO_TCP, TCP_NODELAY, + (void *)&opt, sizeof(opt)) == -1) { ares__close_socket(channel, s); return -1; } #endif - if (channel->sock_config_cb) - { - int err = channel->sock_config_cb(s, SOCK_STREAM, - channel->sock_config_cb_data); - if (err < 0) - { + if (channel->sock_config_cb) + { + int err = channel->sock_config_cb(s, SOCK_STREAM, + channel->sock_config_cb_data); + if (err < 0) + { ares__close_socket(channel, s); - return err; - } - } - + return err; + } + } + /* Connect to the server. */ if (ares__connect_socket(channel, s, sa, salen) == -1) { @@ -1191,11 +1191,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; - 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); - } + 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; @@ -1204,16 +1204,16 @@ 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; - 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); - } + 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; /* LCOV_EXCL_LINE */ + return -1; /* LCOV_EXCL_LINE */ } /* Acquire a socket. */ @@ -1228,17 +1228,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) - { + if (channel->sock_config_cb) + { + int err = channel->sock_config_cb(s, SOCK_DGRAM, + channel->sock_config_cb_data); + if (err < 0) + { ares__close_socket(channel, s); - return err; - } - } - + return err; + } + } + /* Connect to the server. */ if (ares__connect_socket(channel, s, sa, salen) == -1) { @@ -1301,7 +1301,7 @@ static int same_questions(const unsigned char *qbuf, int qlen, q.p += q.namelen; if (q.p + QFIXEDSZ > qbuf + qlen) { - ares_free(q.name); + ares_free(q.name); return 0; } q.type = DNS_QUESTION_TYPE(q.p); @@ -1316,14 +1316,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) { - ares_free(q.name); + ares_free(q.name); return 0; } a.p += a.namelen; if (a.p + QFIXEDSZ > abuf + alen) { - ares_free(q.name); - ares_free(a.name); + ares_free(q.name); + ares_free(a.name); return 0; } a.type = DNS_QUESTION_TYPE(a.p); @@ -1334,13 +1334,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) { - ares_free(a.name); + ares_free(a.name); break; } - ares_free(a.name); + ares_free(a.name); } - ares_free(q.name); + ares_free(q.name); if (j == a.qdcount) return 0; } @@ -1369,7 +1369,7 @@ static int same_address(struct sockaddr *sa, struct ares_addr *aa) return 1; /* match */ break; default: - break; /* LCOV_EXCL_LINE */ + break; /* LCOV_EXCL_LINE */ } } return 0; /* different */ @@ -1406,7 +1406,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 = ares_malloc(sendreq->len); + sendreq->data_storage = ares_malloc(sendreq->len); if (sendreq->data_storage != NULL) { memcpy(sendreq->data_storage, sendreq->data, sendreq->len); @@ -1456,15 +1456,15 @@ void ares__free_query(struct query *query) query->callback = NULL; query->arg = NULL; /* Deallocate the memory associated with the query */ - ares_free(query->tcpbuf); - ares_free(query->server_info); - ares_free(query); + ares_free(query->tcpbuf); + ares_free(query->server_info); + ares_free(query); } - + ares_socket_t ares__open_socket(ares_channel channel, int af, int type, int protocol) -{ - if (channel->sock_funcs) +{ + if (channel->sock_funcs) return channel->sock_funcs->asocket(af, type, protocol, @@ -1490,7 +1490,7 @@ int ares__connect_socket(ares_channel channel, void ares__close_socket(ares_channel channel, ares_socket_t s) { if (channel->sock_funcs) - channel->sock_funcs->aclose(s, channel->sock_func_cb_data); - else - sclose(s); -} + channel->sock_funcs->aclose(s, channel->sock_func_cb_data); + else + sclose(s); +} diff --git a/contrib/libs/c-ares/ares_query.c b/contrib/libs/c-ares/ares_query.c index b38b8a6c22..8ced2ffd63 100644 --- a/contrib/libs/c-ares/ares_query.c +++ b/contrib/libs/c-ares/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) ares_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 = ares_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); } - ares_free(qquery); + ares_free(qquery); } diff --git a/contrib/libs/c-ares/ares_rules.h b/contrib/libs/c-ares/ares_rules.h index cac23cf2e3..417db70b14 100644 --- a/contrib/libs/c-ares/ares_rules.h +++ b/contrib/libs/c-ares/ares_rules.h @@ -89,7 +89,7 @@ typedef char __cares_rule_02__ - [CareschkszEQ(ares_socklen_t, sizeof(CARES_TYPEOF_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/contrib/libs/c-ares/ares_search.c b/contrib/libs/c-ares/ares_search.c index c4b0424f5b..e61e307919 100644 --- a/contrib/libs/c-ares/ares_search.c +++ b/contrib/libs/c-ares/ares_search.c @@ -71,24 +71,24 @@ void ares_search(ares_channel channel, const char *name, int dnsclass, if (s) { ares_query(channel, s, dnsclass, type, callback, arg); - ares_free(s); + ares_free(s); return; } /* Allocate a search_query structure to hold the state necessary for * doing multiple lookups. */ - squery = ares_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 = ares_strdup(name); + squery->name = ares_strdup(name); if (!squery->name) { - ares_free(squery); + ares_free(squery); callback(arg, ARES_ENOMEM, 0, NULL, 0); return; } @@ -128,13 +128,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); - ares_free(s); + ares_free(s); } else { /* failed, free the malloc()ed memory */ - ares_free(squery->name); - ares_free(squery); + ares_free(squery->name); + ares_free(squery); callback(arg, status, 0, NULL, 0); } } @@ -182,7 +182,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); - ares_free(s); + ares_free(s); } } else if (squery->status_as_is == -1) @@ -206,8 +206,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); - ares_free(squery->name); - ares_free(squery); + ares_free(squery->name); + ares_free(squery); } /* Concatenate two domains. */ @@ -216,7 +216,7 @@ int ares__cat_domain(const char *name, const char *domain, char **s) size_t nlen = strlen(name); size_t dlen = strlen(domain); - *s = ares_malloc(nlen + 1 + dlen + 1); + *s = ares_malloc(nlen + 1 + dlen + 1); if (!*s) return ARES_ENOMEM; memcpy(*s, name, nlen); @@ -244,9 +244,9 @@ int ares__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 ((len > 0) && (name[len - 1] == '.')) + if ((len > 0) && (name[len - 1] == '.')) { - *s = ares_strdup(name); + *s = ares_strdup(name); return (*s) ? ARES_SUCCESS : ARES_ENOMEM; } @@ -273,18 +273,18 @@ int ares__single_domain(ares_channel channel, const char *name, char **s) q = p + 1; while (*q && !ISSPACE(*q)) q++; - *s = ares_malloc(q - p + 1); + *s = ares_malloc(q - p + 1); if (*s) { memcpy(*s, p, q - p); (*s)[q - p] = 0; } - ares_free(line); + ares_free(line); fclose(fp); return (*s) ? ARES_SUCCESS : ARES_ENOMEM; } } - ares_free(line); + ares_free(line); fclose(fp); if (status != ARES_SUCCESS && status != ARES_EOF) return status; @@ -312,7 +312,7 @@ int ares__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 = ares_strdup(name); + *s = ares_strdup(name); return (*s) ? ARES_SUCCESS : ARES_ENOMEM; } diff --git a/contrib/libs/c-ares/ares_send.c b/contrib/libs/c-ares/ares_send.c index f4f1f95119..7cf26fdeb1 100644 --- a/contrib/libs/c-ares/ares_send.c +++ b/contrib/libs/c-ares/ares_send.c @@ -47,16 +47,16 @@ void ares_send(ares_channel channel, const unsigned char *qbuf, int qlen, } /* Allocate space for query and allocated fields. */ - query = ares_malloc(sizeof(struct query)); + query = ares_malloc(sizeof(struct query)); if (!query) { callback(arg, ARES_ENOMEM, 0, NULL, 0); return; } - query->tcpbuf = ares_malloc(qlen + 2); + query->tcpbuf = ares_malloc(qlen + 2); if (!query->tcpbuf) { - ares_free(query); + ares_free(query); callback(arg, ARES_ENOMEM, 0, NULL, 0); return; } @@ -66,12 +66,12 @@ void ares_send(ares_channel channel, const unsigned char *qbuf, int qlen, callback(arg, ARES_ESERVFAIL, 0, NULL, 0); return; } - query->server_info = ares_malloc(channel->nservers * - sizeof(query->server_info[0])); + query->server_info = ares_malloc(channel->nservers * + sizeof(query->server_info[0])); if (!query->server_info) { - ares_free(query->tcpbuf); - ares_free(query); + ares_free(query->tcpbuf); + ares_free(query); callback(arg, ARES_ENOMEM, 0, NULL, 0); return; } diff --git a/contrib/libs/c-ares/ares_strdup.c b/contrib/libs/c-ares/ares_strdup.c index 0c3dcffc30..73e12e3479 100644 --- a/contrib/libs/c-ares/ares_strdup.c +++ b/contrib/libs/c-ares/ares_strdup.c @@ -17,33 +17,33 @@ #include "ares_setup.h" #include "ares_strdup.h" -#include "ares.h" -#include "ares_private.h" +#include "ares.h" +#include "ares_private.h" char *ares_strdup(const char *s1) { -#ifdef HAVE_STRDUP - if (ares_malloc == malloc) - return strdup(s1); - else -#endif - { - 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 = ares_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; } } diff --git a/contrib/libs/c-ares/ares_timeout.c b/contrib/libs/c-ares/ares_timeout.c index 293e4af021..4a2ef2b312 100644 --- a/contrib/libs/c-ares/ares_timeout.c +++ b/contrib/libs/c-ares/ares_timeout.c @@ -23,13 +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; -} - +/* 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 @@ -60,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 = timeoffset(&now, &query->timeout); + offset = timeoffset(&now, &query->timeout); if (offset < 0) offset = 0; if (min_offset == -1 || offset < min_offset) diff --git a/contrib/libs/c-ares/ares_writev.c b/contrib/libs/c-ares/ares_writev.c index e812c09e1c..8557fb111b 100644 --- a/contrib/libs/c-ares/ares_writev.c +++ b/contrib/libs/c-ares/ares_writev.c @@ -25,12 +25,12 @@ #include "ares_private.h" #ifndef HAVE_WRITEV -ares_ssize_t ares_writev(ares_socket_t s, const struct iovec *iov, int iovcnt) +ares_ssize_t ares_writev(ares_socket_t s, const struct iovec *iov, int iovcnt) { char *buffer, *bp; int i; size_t bytes = 0; - ares_ssize_t result; + ares_ssize_t result; /* Validate iovcnt */ if (iovcnt <= 0) @@ -54,7 +54,7 @@ ares_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 = ares_malloc(bytes); + buffer = ares_malloc(bytes); if (!buffer) { SET_ERRNO(ENOMEM); @@ -71,7 +71,7 @@ ares_ssize_t ares_writev(ares_socket_t s, const struct iovec *iov, int iovcnt) /* Send buffer contents */ result = swrite(s, buffer, bytes); - ares_free(buffer); + ares_free(buffer); return (result); } diff --git a/contrib/libs/c-ares/ares_writev.h b/contrib/libs/c-ares/ares_writev.h index 65cea8708f..17fdba2b9f 100644 --- a/contrib/libs/c-ares/ares_writev.h +++ b/contrib/libs/c-ares/ares_writev.h @@ -29,7 +29,7 @@ struct iovec size_t iov_len; /* Length of data. */ }; -extern ares_ssize_t ares_writev(ares_socket_t s, const struct iovec *iov, int iovcnt); +extern ares_ssize_t ares_writev(ares_socket_t s, const struct iovec *iov, int iovcnt); #endif diff --git a/contrib/libs/c-ares/bitncmp.c b/contrib/libs/c-ares/bitncmp.c index bbf1cff4a6..93cca514f2 100644 --- a/contrib/libs/c-ares/bitncmp.c +++ b/contrib/libs/c-ares/bitncmp.c @@ -26,7 +26,7 @@ * bitncmp(l, r, n) * compare bit masks l and r, for n bits. * return: - * <0, >0, 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/contrib/libs/c-ares/config-win32.h b/contrib/libs/c-ares/config-win32.h index da7eba44d8..c796802a33 100644 --- a/contrib/libs/c-ares/config-win32.h +++ b/contrib/libs/c-ares/config-win32.h @@ -217,9 +217,9 @@ /* 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 +#ifdef __cplusplus +/* Compiling headers in C++ mode means bool is available */ +#define HAVE_BOOL_T #endif /* ---------------------------------------------------------------- */ @@ -252,18 +252,18 @@ #endif /* Set the Target to Vista. However, any symbols required above Win2000 - * should be loaded via LoadLibrary() */ + * should be loaded via LoadLibrary() */ #if defined(_MSC_VER) && (_MSC_VER >= 1500) -# define VS2008_MIN_TARGET 0x0600 +# define VS2008_MIN_TARGET 0x0600 #endif /* VS2008 default target settings and minimum build target check. */ #if defined(_MSC_VER) && (_MSC_VER >= 1500) # ifndef _WIN32_WINNT -# define _WIN32_WINNT VS2008_MIN_TARGET +# define _WIN32_WINNT VS2008_MIN_TARGET # endif # ifndef WINVER -# define WINVER VS2008_MIN_TARGET +# define WINVER VS2008_MIN_TARGET # endif # if (_WIN32_WINNT < VS2008_MIN_TARGET) || (WINVER < VS2008_MIN_TARGET) # error VS2008 does not support Windows build targets prior to Windows 2000 @@ -271,13 +271,13 @@ #endif /* When no build target is specified Pelles C 5.00 and later default build - target is Windows Vista. */ + target is Windows Vista. */ #if defined(__POCC__) && (__POCC__ >= 500) # ifndef _WIN32_WINNT -# define _WIN32_WINNT 0x0600 +# define _WIN32_WINNT 0x0600 # endif # ifndef WINVER -# define WINVER 0x0600 +# define WINVER 0x0600 # endif #endif diff --git a/contrib/libs/c-ares/inet_net_pton.c b/contrib/libs/c-ares/inet_net_pton.c index af1a534a05..c0695d16b0 100644 --- a/contrib/libs/c-ares/inet_net_pton.c +++ b/contrib/libs/c-ares/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; /* LCOV_EXCL_LINE: all valid paths above increment dst */ + 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 */ @@ -357,8 +357,8 @@ inet_net_pton_ipv6(const char *src, unsigned char *dst, size_t size) * Since some memmove()'s erroneously fail to handle * overlapping regions, we'll do the shift by hand. */ - const ares_ssize_t n = tp - colonp; - ares_ssize_t i; + const ares_ssize_t n = tp - colonp; + ares_ssize_t i; if (tp == endp) goto enoent; diff --git a/contrib/libs/c-ares/inet_ntop.c b/contrib/libs/c-ares/inet_ntop.c index 1935a871ce..c9638df768 100644 --- a/contrib/libs/c-ares/inet_ntop.c +++ b/contrib/libs/c-ares/inet_ntop.c @@ -54,7 +54,7 @@ static const char *inet_ntop6(const unsigned char *src, char *dst, size_t size); * On Windows we store the error in the thread errno, not * in the winsock error code. This is to avoid loosing the * actual last winsock error. So use macro ERRNO to fetch the - * errno this function sets when returning NULL, not SOCKERRNO. + * errno this function sets when returning NULL, not SOCKERRNO. * author: * Paul Vixie, 1996. */ diff --git a/contrib/libs/c-ares/setup_once.h b/contrib/libs/c-ares/setup_once.h index d4b0a954ed..0eaa81067b 100644 --- a/contrib/libs/c-ares/setup_once.h +++ b/contrib/libs/c-ares/setup_once.h @@ -131,7 +131,7 @@ struct timeval { #if defined(__minix) /* Minix doesn't support recv on TCP sockets */ -#define sread(x,y,z) (ares_ssize_t)read((RECV_TYPE_ARG1)(x), \ +#define sread(x,y,z) (ares_ssize_t)read((RECV_TYPE_ARG1)(x), \ (RECV_TYPE_ARG2)(y), \ (RECV_TYPE_ARG3)(z)) @@ -167,7 +167,7 @@ struct timeval { Error Missing_definition_of_return_and_arguments_types_of_recv /* */ #else -#define sread(x,y,z) (ares_ssize_t)recv((RECV_TYPE_ARG1)(x), \ +#define sread(x,y,z) (ares_ssize_t)recv((RECV_TYPE_ARG1)(x), \ (RECV_TYPE_ARG2)(y), \ (RECV_TYPE_ARG3)(z), \ (RECV_TYPE_ARG4)(0)) @@ -183,7 +183,7 @@ struct timeval { #if defined(__minix) /* Minix doesn't support send on TCP sockets */ -#define swrite(x,y,z) (ares_ssize_t)write((SEND_TYPE_ARG1)(x), \ +#define swrite(x,y,z) (ares_ssize_t)write((SEND_TYPE_ARG1)(x), \ (SEND_TYPE_ARG2)(y), \ (SEND_TYPE_ARG3)(z)) @@ -198,7 +198,7 @@ struct timeval { Error Missing_definition_of_return_and_arguments_types_of_send /* */ #else -#define swrite(x,y,z) (ares_ssize_t)send((SEND_TYPE_ARG1)(x), \ +#define swrite(x,y,z) (ares_ssize_t)send((SEND_TYPE_ARG1)(x), \ (SEND_TYPE_ARG2)(y), \ (SEND_TYPE_ARG3)(z), \ (SEND_TYPE_ARG4)(SEND_4TH_ARG)) @@ -228,7 +228,7 @@ struct timeval { Error Missing_definition_of_return_and_arguments_types_of_recvfrom /* */ #else -#define sreadfrom(s,b,bl,f,fl) (ares_ssize_t)recvfrom((RECVFROM_TYPE_ARG1) (s), \ +#define sreadfrom(s,b,bl,f,fl) (ares_ssize_t)recvfrom((RECVFROM_TYPE_ARG1) (s), \ (RECVFROM_TYPE_ARG2 *)(b), \ (RECVFROM_TYPE_ARG3) (bl), \ (RECVFROM_TYPE_ARG4) (0), \ diff --git a/contrib/libs/c-ares/ya.make b/contrib/libs/c-ares/ya.make index bd35762e44..8235413279 100644 --- a/contrib/libs/c-ares/ya.make +++ b/contrib/libs/c-ares/ya.make @@ -42,12 +42,12 @@ IF (NOT DLL_FOR) ) ENDIF() -IF (ARCH_ARM7) +IF (ARCH_ARM7) CFLAGS( GLOBAL -D__SIZEOF_LONG__=4 ) -ENDIF() - +ENDIF() + SRCS( ares__close_sockets.c ares__get_hostent.c @@ -56,7 +56,7 @@ SRCS( ares__readaddrinfo.c ares__sortaddrinfo.c ares__timeval.c - ares_android.c + ares_android.c ares_cancel.c ares_create_query.c ares_data.c |