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,19 +3375,22 @@ 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);
bv = ldap_get_values_len(last->ldap, entry, "sudoOrder"); if (last != NULL) {
if (bv != NULL) { bv = ldap_get_values_len(last->ldap, entry, "sudoOrder");
if (ldap_count_values_len(bv) > 0) { if (bv != NULL) {
/* Get the value of this attribute, 0 if not present. */ if (ldap_count_values_len(bv) > 0) {
DPRINTF2("order attribute raw: %s", (*bv)->bv_val); /* Get the value of this attribute, 0 if not present. */
order = strtod((*bv)->bv_val, &ep); DPRINTF2("order attribute raw: %s", (*bv)->bv_val);
if (ep == (*bv)->bv_val || *ep != '\0') { order = strtod((*bv)->bv_val, &ep);
sudo_warnx(U_("invalid sudoOrder attribute: %s"), (*bv)->bv_val); if (ep == (*bv)->bv_val || *ep != '\0') {
order = 0.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);
} }
/* /*