From: Todd C. Miller Date: Sat, 4 Sep 2010 12:33:45 +0000 (-0400) Subject: Do not return -1 on error from the display functions; the call expects X-Git-Tag: SUDO_1_7_5~175 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=470be8ba432408e1f50530dfbb88c7d4eaa603fc;p=sudo Do not return -1 on error from the display functions; the call expects a return value >= 0. --HG-- branch : 1.7 --- diff --git a/ldap.c b/ldap.c index a8dfe81c2..90ac8c248 100644 --- a/ldap.c +++ b/ldap.c @@ -1233,7 +1233,7 @@ sudo_ldap_display_defaults(nss, pw, lbuf) int rc, count = 0; if (ld == NULL) - return(-1); + goto done; for (base = ldap_conf.base; base != NULL; base = base->next) { result = NULL; @@ -1257,6 +1257,7 @@ sudo_ldap_display_defaults(nss, pw, lbuf) if (result) ldap_msgfree(result); } +done: return(count); } @@ -1446,7 +1447,7 @@ sudo_ldap_display_privs(nss, pw, lbuf) int rc, do_netgr, count = 0; if (ld == NULL) - return(-1); + goto done; /* * Okay - time to search for anything that matches this user @@ -1488,6 +1489,7 @@ sudo_ldap_display_privs(nss, pw, lbuf) } efree(filt); } +done: return(count); } diff --git a/parse.c b/parse.c index 245219e46..97aba79cc 100644 --- a/parse.c +++ b/parse.c @@ -429,7 +429,7 @@ sudo_file_display_privs(nss, pw, lbuf) int nfound = 0; if (nss->handle == NULL) - return(-1); + goto done; tq_foreach_fwd(&userspecs, us) { if (userlist_matches(pw, &us->users) != ALLOW) @@ -440,6 +440,7 @@ sudo_file_display_privs(nss, pw, lbuf) else nfound += sudo_file_display_priv_short(pw, us, lbuf); } +done: return(nfound); } @@ -457,7 +458,7 @@ sudo_file_display_defaults(nss, pw, lbuf) int nfound = 0; if (nss->handle == NULL) - return(-1); + goto done; if (lbuf->len == 0 || isspace((unsigned char)lbuf->buf[lbuf->len - 1])) prefix = " "; @@ -493,7 +494,7 @@ sudo_file_display_defaults(nss, pw, lbuf) prefix = ", "; nfound++; } - +done: return(nfound); } @@ -594,7 +595,7 @@ sudo_file_display_cmnd(nss, pw) int host_match, runas_match, cmnd_match; if (nss->handle == NULL) - return(rval); + goto done; match = NULL; tq_foreach_rev(&userspecs, us) { @@ -625,6 +626,7 @@ sudo_file_display_cmnd(nss, pw) user_args ? user_args : ""); rval = 0; } +done: return(rval); }