Commit Graph

31 Commits

Author SHA1 Message Date
David Drysdale f1bcfa1122 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
2016-02-02 10:05:07 +00:00
David Drysdale 87ff25049c 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).
2016-02-02 10:05:07 +00:00
Daniel Stenberg cf7ad9758d ares_inet_pton/ntop: cleanup
Make sure that the symbols are always exported and present in c-ares.

Make the headers prefixed with 'ares'.

Removed the inet_ntop.h version as it no longer features any content.
2013-02-17 17:44:02 +01:00
Yang Tse 0c677f578e setup_once.h: refactor inclusion of <unistd.h> and <sys/socket.h>
Inclusion of these two header files now done in setup_once.h
2012-12-14 18:36:59 +01:00
Yang Tse 14eb79f660 warnings: fix some 'conversion may lose significant bits' compiler warnings 2011-08-20 23:05:14 +02:00
Daniel Stenberg 63627fa5ab remove all $Id$ lines 2010-03-27 19:42:02 +01:00
Yang Tse 8fe746fcf2 Added IPv6 name servers support 2010-03-05 20:01:47 +00:00
Yang Tse a82a8fbf82 Renamed c-ares setup.h to ares_setup.h 2009-11-02 11:55:53 +00:00
Yang Tse e199ec677f Fix compiler warning: local variable may be used without having been initialized 2009-10-19 15:56:26 +00:00
Yang Tse f3346ca16b Fix compiler warning 2009-10-08 18:38:29 +00:00
Yang Tse e112f191a3 Fix compiler warning 2009-10-08 17:06:08 +00:00
Yang Tse 716d5817dc Fix compiler warning: addition result could be truncated before cast to bigger sized type 2009-10-08 00:02:32 +00:00
Yang Tse c2d3e82931 Overhauled ares__get_hostent()
- Fixing out of bounds memory overwrite triggered with malformed /etc/hosts file.
- Improving parsing of /etc/hosts file.
- Validating requested address family.
- Ensuring that failures always return a NULL pointer.
- Adjusting header inclusions.
2009-10-07 18:47:04 +00:00
Yang Tse 737707bf4b fix compiler warning: implicit conversion shortens 64-bit value into a 32-bit value 2009-04-14 12:53:53 +00:00
Daniel Stenberg 1ce8e6583e - ares_gethostbyname() now accepts 'AF_UNSPEC' as a family for resolving
either AF_INET6 or AF_INET. It works by accepting any of the looksups in the
  hosts file, and it resolves the AAAA field with a fallback to A.
2009-01-31 20:17:41 +00:00
Yang Tse f2582d6949 include header file only when available 2008-09-15 17:14:29 +00:00
Yang Tse 2cb5cbba34 move inclusion of ares_private.h last 2008-09-11 03:46:47 +00:00
Daniel Stenberg 4e27354b82 Ashish Sharma provided a patch for supporting multiple entries in the
/etc/hosts file. Patch edited for coding style and functionality by me
(Daniel).
2007-06-02 19:42:25 +00:00
Gisle Vanem a627160041 Removed inclusion of <sys/types.h> in .c-files
since it's already included through "setup.h".
2007-02-26 04:33:19 +00:00
Yang Tse dd3b42e1ac Replace is*() macros with our own IS*() ones.
Get rid of non ANSI/ISO isascii().
2006-10-18 03:42:06 +00:00
Gisle Vanem 0a83c1e416 2nd try adding CVS id. 2006-07-22 15:37:10 +00:00
Gisle Vanem f6e7395ca0 Added CVS id. 2006-07-22 15:21:13 +00:00
Dominick Meglio e55c48b8cf Added include for inet_net_pton.h to ares__get_hostent.c 2005-04-08 16:22:51 +00:00
Dominick Meglio 29d71bd499 Made ares_gethostbyaddr support IPv6 by specifying AF_INET6 as the family 2005-04-08 15:41:31 +00:00
Daniel Stenberg 3e748f4b50 removed tabs and trailing whitespace from source 2004-10-06 07:50:18 +00:00
Gisle Vanem 6deb40acac Changes for Watt-32 on Windows. I've assumed Configure
sets the required HAVE_xx defines for non-DOS/Win targets.
2004-08-20 13:45:26 +00:00
Daniel Stenberg d5f3636a52 - Fixed a few variable return types for some system calls. Made configure
check for ssize_t to make it possible to use that when receiving the send()
  error code. This is necessary to prevent compiler warnings on some systems.

- Made configure create config.h, and all source files now include setup.h that
  might include the proper config.h (or a handicrafted alternative).

- Switched to 'ares_socket_t' type for sockets in ares, since Windows don't
  use 'int' for that.

- automake-ified and libool-ified c-ares. Now it builds libcares as a shared
  lib on most platforms if wanted. (This bloated the size of the release
  archive with another 200K!)

- Makefile.am now uses Makefile.inc for the c sources, h headers and man
  pages, to make it easier for other makefiles to use the exact same set of
  files.

- Adjusted 'maketgz' to use the new automake magic when building distribution
  archives.
2004-07-22 22:18:45 +00:00
Daniel Stenberg 8cb7fd4e22 better checks to avoid free(NULL) 2004-05-27 07:09:21 +00:00
Daniel Stenberg d870be584d James Bursa's fix to prevent free(NULL) to occur 2004-05-27 06:42:48 +00:00
Daniel Stenberg 3d0a7c00df remove rcsid stuff from c files, it serves no useful purpose 2004-02-02 15:59:35 +00:00
Daniel Stenberg 5e847a14bd ares 1.1.1 with collected applied patches 2003-10-07 21:54:04 +00:00