From: Todd C. Miller Date: Wed, 26 Oct 2016 19:49:05 +0000 (-0600) Subject: Check for sudo_ldap_result_last_search() returning NULL. This can't X-Git-Tag: SUDO_1_8_19^2~89 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a40110756483b66ec69cd0e204d54afb62a65777;p=sudo Check for sudo_ldap_result_last_search() returning NULL. This can't happen in practice because we always call sudo_ldap_result_add_search() first which guarantees there is a result to be found. Quiets a PVS-Studio warning. --- diff --git a/plugins/sudoers/ldap.c b/plugins/sudoers/ldap.c index 20c5605df..c85efe2d0 100644 --- a/plugins/sudoers/ldap.c +++ b/plugins/sudoers/ldap.c @@ -3375,19 +3375,22 @@ sudo_ldap_result_add_entry(struct ldap_result *lres, LDAPMessage *entry) /* Determine whether the entry has the sudoOrder attribute. */ last = sudo_ldap_result_last_search(lres); - bv = ldap_get_values_len(last->ldap, entry, "sudoOrder"); - if (bv != NULL) { - if (ldap_count_values_len(bv) > 0) { - /* Get the value of this attribute, 0 if not present. */ - DPRINTF2("order attribute raw: %s", (*bv)->bv_val); - order = strtod((*bv)->bv_val, &ep); - if (ep == (*bv)->bv_val || *ep != '\0') { - sudo_warnx(U_("invalid sudoOrder attribute: %s"), (*bv)->bv_val); - order = 0.0; + if (last != NULL) { + bv = ldap_get_values_len(last->ldap, entry, "sudoOrder"); + if (bv != NULL) { + if (ldap_count_values_len(bv) > 0) { + /* Get the value of this attribute, 0 if not present. */ + DPRINTF2("order attribute raw: %s", (*bv)->bv_val); + order = strtod((*bv)->bv_val, &ep); + if (ep == (*bv)->bv_val || *ep != '\0') { + sudo_warnx(U_("invalid sudoOrder attribute: %s"), + (*bv)->bv_val); + order = 0.0; + } + DPRINTF2("order attribute: %f", order); } - DPRINTF2("order attribute: %f", order); + ldap_value_free_len(bv); } - ldap_value_free_len(bv); } /*