From: Todd C. Miller Date: Sat, 4 Sep 2010 12:42:08 +0000 (-0400) Subject: Do not return -1 on error from the display functions; the caller X-Git-Tag: SUDO_1_8_0~264 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=27f6558df94dff2698d49de20fc8e4976f9d0547;p=sudo Do not return -1 on error from the display functions; the caller expects a return value >= 0. --- diff --git a/plugins/sudoers/ldap.c b/plugins/sudoers/ldap.c index aa64396a8..92ce7638e 100644 --- a/plugins/sudoers/ldap.c +++ b/plugins/sudoers/ldap.c @@ -1149,7 +1149,7 @@ sudo_ldap_display_defaults(struct sudo_nss *nss, struct passwd *pw, int rc, count = 0; if (ld == NULL) - return(-1); + goto done; for (base = ldap_conf.base; base != NULL; base = base->next) { result = NULL; @@ -1173,6 +1173,7 @@ sudo_ldap_display_defaults(struct sudo_nss *nss, struct passwd *pw, if (result) ldap_msgfree(result); } +done: return(count); } @@ -1352,7 +1353,7 @@ sudo_ldap_display_privs(struct sudo_nss *nss, struct passwd *pw, int rc, do_netgr, count = 0; if (ld == NULL) - return(-1); + goto done; /* * Okay - time to search for anything that matches this user @@ -1394,6 +1395,7 @@ sudo_ldap_display_privs(struct sudo_nss *nss, struct passwd *pw, } efree(filt); } +done: return(count); } diff --git a/plugins/sudoers/parse.c b/plugins/sudoers/parse.c index 74251510e..57e9e8211 100644 --- a/plugins/sudoers/parse.c +++ b/plugins/sudoers/parse.c @@ -414,7 +414,7 @@ sudo_file_display_privs(struct sudo_nss *nss, struct passwd *pw, int nfound = 0; if (nss->handle == NULL) - return(-1); + goto done; tq_foreach_fwd(&userspecs, us) { if (userlist_matches(pw, &us->users) != ALLOW) @@ -425,6 +425,7 @@ sudo_file_display_privs(struct sudo_nss *nss, struct passwd *pw, else nfound += sudo_file_display_priv_short(pw, us, lbuf); } +done: return(nfound); } @@ -440,7 +441,7 @@ sudo_file_display_defaults(struct sudo_nss *nss, struct passwd *pw, int nfound = 0; if (nss->handle == NULL) - return(-1); + goto done; if (lbuf->len == 0 || isspace((unsigned char)lbuf->buf[lbuf->len - 1])) prefix = " "; @@ -476,7 +477,7 @@ sudo_file_display_defaults(struct sudo_nss *nss, struct passwd *pw, prefix = ", "; nfound++; } - +done: return(nfound); } @@ -571,7 +572,7 @@ sudo_file_display_cmnd(struct sudo_nss *nss, struct passwd *pw) int host_match, runas_match, cmnd_match; if (nss->handle == NULL) - return(rval); + goto done; match = NULL; tq_foreach_rev(&userspecs, us) { @@ -602,6 +603,7 @@ sudo_file_display_cmnd(struct sudo_nss *nss, struct passwd *pw) safe_cmnd, user_args ? " " : "", user_args ? user_args : ""); rval = 0; } +done: return(rval); }