From: Todd C. Miller Date: Wed, 26 Oct 2016 16:46:03 +0000 (-0600) Subject: When checking syslog facility or priority, move the string X-Git-Tag: SUDO_1_8_19^2~95 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e3825cbedd351d23b4b2228143d1de2cc4370543;p=sudo When checking syslog facility or priority, move the string compare into the body of the loop and return if it matches. If we finish the loop it means we didn't find a match. This makes the code a little bit more readable. --- diff --git a/plugins/sudoers/defaults.c b/plugins/sudoers/defaults.c index d21b83f89..bab834388 100644 --- a/plugins/sudoers/defaults.c +++ b/plugins/sudoers/defaults.c @@ -866,13 +866,13 @@ store_syslogfac(const char *val, struct sudo_defs_types *def) def->sd_un.ival = false; debug_return_bool(true); } - for (fac = facilities; fac->name && strcmp(val, fac->name); fac++) - continue; - if (fac->name == NULL) - debug_return_bool(false); /* not found */ - - def->sd_un.ival = fac->num; - debug_return_bool(true); + for (fac = facilities; fac->name != NULL; fac++) { + if (strcmp(val, fac->name) != 0) { + def->sd_un.ival = fac->num; + debug_return_bool(true); + } + } + debug_return_bool(false); /* not found */ } static const char * @@ -895,13 +895,13 @@ store_syslogpri(const char *val, struct sudo_defs_types *def) if (val == NULL) debug_return_bool(false); - for (pri = priorities; pri->name && strcmp(val, pri->name); pri++) - continue; - if (pri->name == NULL) - debug_return_bool(false); /* not found */ - - def->sd_un.ival = pri->num; - debug_return_bool(true); + for (pri = priorities; pri->name != NULL; pri++) { + if (strcmp(val, pri->name) != 0) { + def->sd_un.ival = pri->num; + debug_return_bool(true); + } + } + debug_return_bool(false); /* not found */ } static const char *