aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/c-ares/src/lib/ares_parse_a_reply.c
diff options
context:
space:
mode:
authorthegeorg <thegeorg@yandex-team.com>2024-07-30 09:57:24 +0300
committerthegeorg <thegeorg@yandex-team.com>2024-07-30 10:08:52 +0300
commit5b405616d0467647cb365e71237976a9f3810b42 (patch)
treec35e742877f95ba2b9357f178197c755f121cb1a /contrib/libs/c-ares/src/lib/ares_parse_a_reply.c
parent997c68115bc1c9dd2fce5a6a6f8eae92ad628df7 (diff)
downloadydb-5b405616d0467647cb365e71237976a9f3810b42.tar.gz
Update contrib/libs/c-ares to 1.28.1
db71d0a3bd9ec3cf1e1ccb5a9cfac8abfd43fdb7
Diffstat (limited to 'contrib/libs/c-ares/src/lib/ares_parse_a_reply.c')
-rw-r--r--contrib/libs/c-ares/src/lib/ares_parse_a_reply.c66
1 files changed, 39 insertions, 27 deletions
diff --git a/contrib/libs/c-ares/src/lib/ares_parse_a_reply.c b/contrib/libs/c-ares/src/lib/ares_parse_a_reply.c
index b50dea3884..da841f0da9 100644
--- a/contrib/libs/c-ares/src/lib/ares_parse_a_reply.c
+++ b/contrib/libs/c-ares/src/lib/ares_parse_a_reply.c
@@ -56,38 +56,45 @@ int ares_parse_a_reply(const unsigned char *abuf, int alen,
int *naddrttls)
{
struct ares_addrinfo ai;
- char *question_hostname = NULL;
- int status;
- int req_naddrttls = 0;
-
- if (naddrttls)
- {
- req_naddrttls = *naddrttls;
- *naddrttls = 0;
- }
+ char *question_hostname = NULL;
+ ares_status_t status;
+ size_t req_naddrttls = 0;
+ ares_dns_record_t *dnsrec = NULL;
+
+ if (alen < 0) {
+ return ARES_EBADRESP;
+ }
+
+ if (naddrttls) {
+ req_naddrttls = (size_t)*naddrttls;
+ *naddrttls = 0;
+ }
memset(&ai, 0, sizeof(ai));
- status = ares__parse_into_addrinfo(abuf, alen, 0, 0, &ai);
- if (status != ARES_SUCCESS && status != ARES_ENODATA)
- {
- goto fail;
- }
+ status = ares_dns_parse(abuf, (size_t)alen, 0, &dnsrec);
+ if (status != ARES_SUCCESS) {
+ goto fail;
+ }
+
+ status = ares__parse_into_addrinfo(dnsrec, 0, 0, &ai);
+ if (status != ARES_SUCCESS && status != ARES_ENODATA) {
+ goto fail;
+ }
- if (host != NULL)
- {
- status = ares__addrinfo2hostent(&ai, AF_INET, host);
- if (status != ARES_SUCCESS && status != ARES_ENODATA)
- {
- goto fail;
- }
+ if (host != NULL) {
+ status = ares__addrinfo2hostent(&ai, AF_INET, host);
+ if (status != ARES_SUCCESS && status != ARES_ENODATA) {
+ goto fail;
}
+ }
- if (addrttls != NULL && req_naddrttls)
- {
- ares__addrinfo2addrttl(&ai, AF_INET, req_naddrttls, addrttls,
- NULL, naddrttls);
- }
+ if (addrttls != NULL && req_naddrttls) {
+ size_t temp_naddrttls = 0;
+ ares__addrinfo2addrttl(&ai, AF_INET, req_naddrttls, addrttls, NULL,
+ &temp_naddrttls);
+ *naddrttls = (int)temp_naddrttls;
+ }
fail:
@@ -95,6 +102,11 @@ fail:
ares__freeaddrinfo_nodes(ai.nodes);
ares_free(ai.name);
ares_free(question_hostname);
+ ares_dns_record_destroy(dnsrec);
+
+ if (status == ARES_EBADNAME) {
+ status = ARES_EBADRESP;
+ }
- return status;
+ return (int)status;
}