URL: https://github.com/SSSD/sssd/pull/5452 Author: alexey-tikhonov Title: #5452: RESOLV: handle fail of ares_parse_*_reply() properly Action: synchronized
To pull the PR as Git branch: git remote add ghsssd https://github.com/SSSD/sssd git fetch ghsssd pull/5452/head:pr5452 git checkout pr5452
From 64ed80d9e02819cd211b648f37578d1bf70591e6 Mon Sep 17 00:00:00 2001 From: Alexey Tikhonov <[email protected]> Date: Fri, 8 Jan 2021 20:05:03 +0100 Subject: [PATCH] RESOLV: handle fail of ares_parse_*_reply() properly With modern versions of c-ares ares_parse_*_reply() functions don't touch `hostent **host` in case of fail. This means it's unreliable to check for (hostent != NULL) without previous initialization. To be on a safe side it's better to check for return code as well. Resolves: https://github.com/SSSD/sssd/issues/5451 --- src/resolv/async_resolv.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/resolv/async_resolv.c b/src/resolv/async_resolv.c index 294a4b8827..209fa64178 100644 --- a/src/resolv/async_resolv.c +++ b/src/resolv/async_resolv.c @@ -937,7 +937,7 @@ static int resolv_gethostbyname_dns_parse(struct gethostbyname_dns_state *state, int status, unsigned char *abuf, int alen) { - struct hostent *hostent; + struct hostent *hostent = NULL; int naddrttls; errno_t ret; void *addr = NULL; @@ -977,7 +977,7 @@ resolv_gethostbyname_dns_parse(struct gethostbyname_dns_state *state, goto fail; } - if (hostent != NULL) { + if ((hostent != NULL) && (status == ARES_SUCCESS)) { state->rhostent = resolv_copy_hostent_ares(state, hostent, state->family, addr, naddrttls); @@ -994,6 +994,10 @@ resolv_gethostbyname_dns_parse(struct gethostbyname_dns_state *state, talloc_zfree(state->rhostent); return ENOENT; } + } else if (status != ARES_SUCCESS) { + DEBUG(SSSDBG_OP_FAILURE, "Failed to parse reply: %d\n", status); + } else { + DEBUG(SSSDBG_CRIT_FAILURE, "NULL parse result!\n"); } talloc_free(addr);
_______________________________________________ sssd-devel mailing list -- [email protected] To unsubscribe send an email to [email protected] Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/ List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines List Archives: https://lists.fedorahosted.org/archives/list/[email protected]
