diff options
author | Stephen Gallagher <sgallagh@redhat.com> | 2012-11-27 15:51:05 -0500 |
---|---|---|
committer | Jakub Hrozek <jhrozek@redhat.com> | 2012-12-02 21:59:02 +0100 |
commit | a729f079ec4258923b286d0da1758974ae48cf97 (patch) | |
tree | 286d9b7239b511f0e097aa0da7df231f6c42fc12 | |
parent | 0f1736ce0830fc508c38d10c8df4327f82e02570 (diff) | |
download | sssd-a729f079ec4258923b286d0da1758974ae48cf97.tar.gz sssd-a729f079ec4258923b286d0da1758974ae48cf97.tar.xz sssd-a729f079ec4258923b286d0da1758974ae48cf97.zip |
IPA: Handle bad results from c-ares lookup
In some situations, the c-ares lookup can return NULL instead of
a list of addresses. In this situation, we need to avoid
dereferencing NULL.
This patch adds a log message and sets the count to zero so it is
handled appropriately below.
-rw-r--r-- | src/providers/ipa/ipa_dyndns.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/providers/ipa/ipa_dyndns.c b/src/providers/ipa/ipa_dyndns.c index 66515e840..22a16a11a 100644 --- a/src/providers/ipa/ipa_dyndns.c +++ b/src/providers/ipa/ipa_dyndns.c @@ -733,7 +733,17 @@ ipa_dyndns_update_get_addrs_done(struct tevent_req *subreq) /* EOK */ - for (count=0; rhostent->addr_list[count]; count++); + if (rhostent->addr_list) { + for (count=0; rhostent->addr_list[count]; count++); + } else { + /* The address list is NULL. This is probably a bug in + * c-ares, but we need to handle it gracefully. + */ + DEBUG(SSSDBG_MINOR_FAILURE, + ("Lookup of [%s] returned no addresses. Skipping.\n", + rhostent->name)); + count = 0; + } state->addrlist = talloc_realloc(state, state->addrlist, char *, state->count + count + 1); |