diff options
author | Yu Jiung <jiung.yu@samsung.com> | 2016-11-10 16:24:08 +0900 |
---|---|---|
committer | Yu Jiung <jiung.yu@samsung.com> | 2016-11-10 16:25:02 +0900 |
commit | 8166b0204b6945a4fdb89bbae0b0b7168a7cf6e8 (patch) | |
tree | 81f0750d91aa467df3ee81cf30d22a65db2e6685 /ares_parse_txt_reply.c | |
parent | ccccebb78520ec3a26a18370936516b12ae5d53a (diff) | |
parent | 45e88a8337839e5fd88519bc55467053d521c9f6 (diff) | |
download | c-ares-submit/tizen_4.0_base/20170828.000000.tar.gz c-ares-submit/tizen_4.0_base/20170828.000000.tar.bz2 c-ares-submit/tizen_4.0_base/20170828.000000.zip |
Merge branch 'tizen' into tizen_basetizen_4.0.m2_releasetizen_4.0.IoT.p1_releasesubmit/tizen_base/20170705.023439submit/tizen_base/20170703.013654submit/tizen_4.0_base/20170828.000001submit/tizen_4.0_base/20170828.000000submit/tizen_4.0_base/20170811.071500accepted/tizen/base/20170707.183634accepted/tizen/4.0/base/20170828.221324accepted/tizen/4.0/base/20170811.093019
Conflicts:
packaging/c-ares.spec
Change-Id: I1ec10e394aed3ef19ee21fefbe3aba7d7a615c74
Diffstat (limited to 'ares_parse_txt_reply.c')
-rw-r--r-- | ares_parse_txt_reply.c | 52 |
1 files changed, 38 insertions, 14 deletions
diff --git a/ares_parse_txt_reply.c b/ares_parse_txt_reply.c index 981db4c..4856b4c 100644 --- a/ares_parse_txt_reply.c +++ b/ares_parse_txt_reply.c @@ -44,9 +44,9 @@ #include "ares_data.h" #include "ares_private.h" -int -ares_parse_txt_reply (const unsigned char *abuf, int alen, - struct ares_txt_reply **txt_out) +static int +ares__parse_txt_reply (const unsigned char *abuf, int alen, + int ex, void **txt_out) { size_t substr_len; unsigned int qdcount, ancount, i; @@ -55,9 +55,9 @@ ares_parse_txt_reply (const unsigned char *abuf, int alen, int status, rr_type, rr_class, rr_len; long len; char *hostname = NULL, *rr_name = NULL; - struct ares_txt_reply *txt_head = NULL; - struct ares_txt_reply *txt_last = NULL; - struct ares_txt_reply *txt_curr; + struct ares_txt_ext *txt_head = NULL; + struct ares_txt_ext *txt_last = NULL; + struct ares_txt_ext *txt_curr; /* Set *txt_out to NULL for all failure cases. */ *txt_out = NULL; @@ -82,7 +82,7 @@ ares_parse_txt_reply (const unsigned char *abuf, int alen, if (aptr + len + QFIXEDSZ > abuf + alen) { - free (hostname); + ares_free (hostname); return ARES_EBADRESP; } aptr += len + QFIXEDSZ; @@ -133,10 +133,9 @@ 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); + txt_curr = ares_malloc_data(ex ? ARES_DATATYPE_TXT_EXT : + ARES_DATATYPE_TXT_REPLY); if (!txt_curr) { status = ARES_ENOMEM; @@ -152,13 +151,17 @@ ares_parse_txt_reply (const unsigned char *abuf, int alen, } txt_last = txt_curr; + if (ex) + txt_curr->record_start = (strptr == aptr); txt_curr->length = substr_len; - txt_curr->txt = malloc (substr_len + 1/* Including null byte */); + txt_curr->txt = ares_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 */ @@ -168,8 +171,14 @@ ares_parse_txt_reply (const unsigned char *abuf, int alen, } } + /* Propagate any failures */ + if (status != ARES_SUCCESS) + { + break; + } + /* Don't lose memory in the next iteration */ - free (rr_name); + ares_free (rr_name); rr_name = NULL; /* Move on to the next record */ @@ -177,9 +186,9 @@ ares_parse_txt_reply (const unsigned char *abuf, int alen, } if (hostname) - free (hostname); + ares_free (hostname); if (rr_name) - free (rr_name); + ares_free (rr_name); /* clean up on error */ if (status != ARES_SUCCESS) @@ -194,3 +203,18 @@ ares_parse_txt_reply (const unsigned char *abuf, int alen, return ARES_SUCCESS; } + +int +ares_parse_txt_reply (const unsigned char *abuf, int alen, + struct ares_txt_reply **txt_out) +{ + return ares__parse_txt_reply(abuf, alen, 0, (void **) txt_out); +} + + +int +ares_parse_txt_reply_ext (const unsigned char *abuf, int alen, + struct ares_txt_ext **txt_out) +{ + return ares__parse_txt_reply(abuf, alen, 1, (void **) txt_out); +} |