deps: provide TXT chunk info in c-ares
authorFedor Indutny <fedor@indutny.com>
Thu, 27 Mar 2014 20:09:20 +0000 (00:09 +0400)
committerBen Noordhuis <info@bnoordhuis.nl>
Tue, 12 May 2015 08:47:51 +0000 (10:47 +0200)
Provide more information in `ares_txt_reply` to coalesce chunks from the
same record into one string.

fix #7367

deps/cares/include/ares.h
deps/cares/src/ares_parse_txt_reply.c

index 7233c5a..f9abe85 100644 (file)
@@ -473,6 +473,8 @@ struct ares_txt_reply {
   struct ares_txt_reply  *next;
   unsigned char          *txt;
   size_t                  length;  /* length excludes null termination */
+  unsigned char           record_start;  /* 1 - if start of new record
+                                          * 0 - if a chunk in the same record */
 };
 
 struct ares_naptr_reply {
index 981db4c..dabf73c 100644 (file)
@@ -133,8 +133,6 @@ ares_parse_txt_reply (const unsigned char *abuf, int alen,
                   break;
                 }
 
-              ++strptr;
-
               /* Allocate storage for this TXT answer appending it to the list */
               txt_curr = ares_malloc_data(ARES_DATATYPE_TXT_REPLY);
               if (!txt_curr)
@@ -152,6 +150,7 @@ ares_parse_txt_reply (const unsigned char *abuf, int alen,
                 }
               txt_last = txt_curr;
 
+              txt_curr->record_start = strptr == aptr;
               txt_curr->length = substr_len;
               txt_curr->txt = malloc (substr_len + 1/* Including null byte */);
               if (txt_curr->txt == NULL)
@@ -159,6 +158,8 @@ ares_parse_txt_reply (const unsigned char *abuf, int alen,
                   status = ARES_ENOMEM;
                   break;
                 }
+
+              ++strptr;
               memcpy ((char *) txt_curr->txt, strptr, substr_len);
 
               /* Make sure we NULL-terminate */