From: Alejandro Colomar Date: Fri, 26 May 2023 09:34:10 +0000 (+0200) Subject: Second verse, it gets worse; it gets no better than this X-Git-Tag: 4.14.0-rc1~56 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=07b885318f237f7129229cfb61496886a89ae505;p=thirdparty%2Fshadow.git Second verse, it gets worse; it gets no better than this Just in case it's not obious: strlen("") < 8 isalpha('\0') == false isdigit('\0') == false isspace('\0') == false Link: Easter-egg: 8492dee6632e ("subids: support nsswitch") Signed-off-by: Alejandro Colomar --- diff --git a/lib/nss.c b/lib/nss.c index b902e5d77..503f97e64 100644 --- a/lib/nss.c +++ b/lib/nss.c @@ -70,14 +70,14 @@ void nss_init(const char *nsswitch_path) { return; } while ((getline(&line, &len, nssfp)) != -1) { - if (line[0] == '\0' || line[0] == '#') + if (line[0] == '#') continue; if (strlen(line) < 8) continue; if (strncasecmp(line, "subid:", 6) != 0) continue; p = &line[6]; - while ((*p) && isspace(*p)) + while (isspace(*p)) p++; if (*p != '\0') break; diff --git a/lib/port.c b/lib/port.c index 3068ae9d8..8a45b67e4 100644 --- a/lib/port.c +++ b/lib/port.c @@ -243,9 +243,7 @@ static struct port *getportent (void) * week or the other two values. */ - for (i = 0; - ('\0' != cp[i]) && ('\0' != cp[i + 1]) && isalpha (cp[i]); - i += 2) { + for (i = 0; isalpha(cp[i]) && ('\0' != cp[i + 1]); i += 2) { switch ((cp[i] << 8) | (cp[i + 1])) { case ('S' << 8) | 'u': port.pt_times[j].t_days |= 01; @@ -294,7 +292,7 @@ static struct port *getportent (void) * representing the times of day. */ - for (dtime = 0; ('\0' != cp[i]) && isdigit (cp[i]); i++) { + for (dtime = 0; isdigit (cp[i]); i++) { dtime = dtime * 10 + cp[i] - '0'; } @@ -304,9 +302,7 @@ static struct port *getportent (void) port.pt_times[j].t_start = dtime; cp = cp + i + 1; - for (dtime = 0, i = 0; - ('\0' != cp[i]) && isdigit (cp[i]); - i++) { + for (dtime = 0, i = 0; isdigit (cp[i]); i++) { dtime = dtime * 10 + cp[i] - '0'; } diff --git a/libmisc/setupenv.c b/libmisc/setupenv.c index b30dae34a..b082fe0e6 100644 --- a/libmisc/setupenv.c +++ b/libmisc/setupenv.c @@ -63,7 +63,7 @@ static void read_env_file (const char *filename) cp = buf; /* ignore whitespace and comments */ - while (('\0' != *cp) && isspace (*cp)) { + while (isspace (*cp)) { cp++; } if (('\0' == *cp) || ('#' == *cp)) {