Commit Graph

17 Commits

Author SHA1 Message Date
Fedor Indutny 53c2186e18 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.
2016-02-04 10:00:59 +00:00
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 6aabc42e5f 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.
2016-01-24 09:05:40 +00:00
Patrick Valsecchi b5135bbc66 ares_parse_txt_reply: return a ares_txt_reply node for each sub-string
Previously, the function would wrongly return all substrings merged into
one.
2013-04-22 23:32:02 +02:00
Patrick Valsecchi 148c8e0353 protocol parsing: check input data stricter
... so that bad length fields aren't blindly accepted

Bug: http://c-ares.haxx.se/mail/c-ares-archive-2013-04/0016.shtml
2013-04-15 22:28:01 +02: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 a1035276c1 Header inclusion clean-up
Remove header inclusions already done in setup_once.h
2012-12-14 18:25:56 +01:00
Daniel Stenberg 63627fa5ab remove all $Id$ lines 2010-03-27 19:42:02 +01:00
Yang Tse 57e48c4cf1 - Larry Lansing fixed ares_parse_srv_reply to properly parse replies
which might contain non-SRV answers, skipping over potential non-SRV
  ones such as CNAMEs.
2009-11-26 01:21:21 +00:00
Yang Tse 09aadd57e6 Fix comment 2009-11-20 09:54:15 +00:00
Yang Tse 5d62fe703f Jakub Hrozek modified ares_parse_srv_reply() and ares_parse_txt_reply() API
to return a linked lists of results. These were also modified to internally
use the ares_data memory struct and as such its result must be free'ed with
ares_free_data().
2009-11-20 09:06:33 +00:00
Yang Tse a82a8fbf82 Renamed c-ares setup.h to ares_setup.h 2009-11-02 11:55:53 +00:00
Yang Tse 54a7da89c8 Header inclusion depending on HAVE_* symbol.
Fix two typos.
2009-10-30 18:20:17 +00:00
Yang Tse e576d895e7 Comparison of the Initial revision of this file with ares_parse_a_reply.c
shows that this one is actually a modified copy of ares_parse_a_reply.c.

In order to comply with ares_parse_a_reply.c's M.I.T. license, the old
1998 M.I.T. copyright notice is now also preserved in this file the same
as it is done in other ares_parse_*.c files.
2009-10-30 18:07:17 +00:00
Yang Tse 4533a082bd Fix comment 2009-10-30 16:27:30 +00:00
Yang Tse cef06973a2 In no particular order, changed/fixed all of the following in
ares_parse_txt_reply() current version:

- Fixed a couple of potential double free's.

- Fixed memory leaks upon out of memory condition.

- Fixed pointer arithmetic.

- Setting ntxtreply to zero upon entry for all failure cases.

- Changed data type to size_t for variables substr_len, str_len and
  the length member of ares_txt_reply struct.

- Avoided a couple of memcpy() calls.

- Changed i data type to unsigned int to prevent compiler warnings.

- Adjusted a comment.

- Use ARES_SUCCESS literal for successfull completion.

- Added CVS Id tag.
2009-10-30 16:21:56 +00:00
Daniel Stenberg 9cbd5ed034 Jakub Hrozek added ares_parse_txt_reply() for TXT parsing 2009-10-29 08:59:40 +00:00