4444#include "ares_data.h"
4545#include "ares_private.h"
4646
47- int
48- ares_parse_txt_reply (const unsigned char * abuf , int alen ,
49- struct ares_txt_reply * * txt_out )
47+ static int
48+ ares__parse_txt_reply (const unsigned char * abuf , int alen ,
49+ int ex , void * * txt_out )
5050{
5151 size_t substr_len ;
5252 unsigned int qdcount , ancount , i ;
@@ -55,9 +55,9 @@ ares_parse_txt_reply (const unsigned char *abuf, int alen,
5555 int status , rr_type , rr_class , rr_len ;
5656 long len ;
5757 char * hostname = NULL , * rr_name = NULL ;
58- struct ares_txt_reply * txt_head = NULL ;
59- struct ares_txt_reply * txt_last = NULL ;
60- struct ares_txt_reply * txt_curr ;
58+ struct ares_txt_ext * txt_head = NULL ;
59+ struct ares_txt_ext * txt_last = NULL ;
60+ struct ares_txt_ext * txt_curr ;
6161
6262 /* Set *txt_out to NULL for all failure cases. */
6363 * txt_out = NULL ;
@@ -133,10 +133,9 @@ ares_parse_txt_reply (const unsigned char *abuf, int alen,
133133 break ;
134134 }
135135
136- ++ strptr ;
137-
138136 /* Allocate storage for this TXT answer appending it to the list */
139- txt_curr = ares_malloc_data (ARES_DATATYPE_TXT_REPLY );
137+ txt_curr = ares_malloc_data (ex ? ARES_DATATYPE_TXT_EXT :
138+ ARES_DATATYPE_TXT_REPLY );
140139 if (!txt_curr )
141140 {
142141 status = ARES_ENOMEM ;
@@ -152,13 +151,17 @@ ares_parse_txt_reply (const unsigned char *abuf, int alen,
152151 }
153152 txt_last = txt_curr ;
154153
154+ if (ex )
155+ txt_curr -> record_start = (strptr == aptr );
155156 txt_curr -> length = substr_len ;
156157 txt_curr -> txt = ares_malloc (substr_len + 1 /* Including null byte */ );
157158 if (txt_curr -> txt == NULL )
158159 {
159160 status = ARES_ENOMEM ;
160161 break ;
161162 }
163+
164+ ++ strptr ;
162165 memcpy ((char * ) txt_curr -> txt , strptr , substr_len );
163166
164167 /* Make sure we NULL-terminate */
@@ -200,3 +203,18 @@ ares_parse_txt_reply (const unsigned char *abuf, int alen,
200203
201204 return ARES_SUCCESS ;
202205}
206+
207+ int
208+ ares_parse_txt_reply (const unsigned char * abuf , int alen ,
209+ struct ares_txt_reply * * txt_out )
210+ {
211+ return ares__parse_txt_reply (abuf , alen , 0 , (void * * ) txt_out );
212+ }
213+
214+
215+ int
216+ ares_parse_txt_reply_ext (const unsigned char * abuf , int alen ,
217+ struct ares_txt_ext * * txt_out )
218+ {
219+ return ares__parse_txt_reply (abuf , alen , 1 , (void * * ) txt_out );
220+ }
0 commit comments