]> granicus.if.org Git - sudo/commitdiff
Check for sudo_ldap_result_last_search() returning NULL. This can't
authorTodd C. Miller <Todd.Miller@courtesan.com>
Wed, 26 Oct 2016 19:49:05 +0000 (13:49 -0600)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Wed, 26 Oct 2016 19:49:05 +0000 (13:49 -0600)
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.

plugins/sudoers/ldap.c

index 20c5605dff3a35f0e5ea25ffe73d0c74fbc183a0..c85efe2d00b1242c866222e4918df5771cd93938 100644 (file)
@@ -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);
     }
 
     /*