Skip to content

Commit

Permalink
deps: provide TXT chunk info in c-ares
Browse files Browse the repository at this point in the history
Provide more information in `ares_txt_reply` to coalesce chunks from the
same record into one string.

fix nodejs#7367
  • Loading branch information
indutny authored and bnoordhuis committed May 12, 2015
1 parent 7e1c0e7 commit 0f850f7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 2 additions & 0 deletions deps/cares/include/ares.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 3 additions & 2 deletions deps/cares/src/ares_parse_txt_reply.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -152,13 +150,16 @@ 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)
{
status = ARES_ENOMEM;
break;
}

++strptr;
memcpy ((char *) txt_curr->txt, strptr, substr_len);

/* Make sure we NULL-terminate */
Expand Down

0 comments on commit 0f850f7

Please sign in to comment.