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.
This commit is contained in:
Todd C. Miller
2016-10-26 13:49:05 -06:00
parent 5a7936209e
commit a401107564

View File

@@ -3375,6 +3375,7 @@ sudo_ldap_result_add_entry(struct ldap_result *lres, LDAPMessage *entry)
/* Determine whether the entry has the sudoOrder attribute. */ /* Determine whether the entry has the sudoOrder attribute. */
last = sudo_ldap_result_last_search(lres); last = sudo_ldap_result_last_search(lres);
if (last != NULL) {
bv = ldap_get_values_len(last->ldap, entry, "sudoOrder"); bv = ldap_get_values_len(last->ldap, entry, "sudoOrder");
if (bv != NULL) { if (bv != NULL) {
if (ldap_count_values_len(bv) > 0) { if (ldap_count_values_len(bv) > 0) {
@@ -3382,13 +3383,15 @@ sudo_ldap_result_add_entry(struct ldap_result *lres, LDAPMessage *entry)
DPRINTF2("order attribute raw: %s", (*bv)->bv_val); DPRINTF2("order attribute raw: %s", (*bv)->bv_val);
order = strtod((*bv)->bv_val, &ep); order = strtod((*bv)->bv_val, &ep);
if (ep == (*bv)->bv_val || *ep != '\0') { if (ep == (*bv)->bv_val || *ep != '\0') {
sudo_warnx(U_("invalid sudoOrder attribute: %s"), (*bv)->bv_val); sudo_warnx(U_("invalid sudoOrder attribute: %s"),
(*bv)->bv_val);
order = 0.0; order = 0.0;
} }
DPRINTF2("order attribute: %f", order); DPRINTF2("order attribute: %f", order);
} }
ldap_value_free_len(bv); ldap_value_free_len(bv);
} }
}
/* /*
* Enlarge the array of entry wrappers as needed, preallocating blocks * Enlarge the array of entry wrappers as needed, preallocating blocks