]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
Second verse, it gets worse; it gets no better than this
authorAlejandro Colomar <alx@kernel.org>
Fri, 26 May 2023 09:34:10 +0000 (11:34 +0200)
committerSerge Hallyn <serge@hallyn.com>
Wed, 31 May 2023 14:29:49 +0000 (09:29 -0500)
Just in case it's not obious:

strlen("") < 8
isalpha('\0') == false
isdigit('\0') == false
isspace('\0') == false

Link: <https://github.com/shadow-maint/shadow/pull/737>
Easter-egg: 8492dee6632e ("subids: support nsswitch")
Signed-off-by: Alejandro Colomar <alx@kernel.org>
lib/nss.c
lib/port.c
libmisc/setupenv.c

index b902e5d775546607ff86c94f9b7ac5724f024d36..503f97e64639e779eab083949dcb7a4b337b7af3 100644 (file)
--- 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;
index 3068ae9d8c826fc19e5d1cf0ee3cca5b69bbb71b..8a45b67e448a9d3cc5dfe52a1474fb3dc8c0cb07 100644 (file)
@@ -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';
                }
 
index b30dae34ab4d364eed9b75ad889051e9faf18619..b082fe0e6d32e6389bea7146c8b6a0011ca7b5f5 100644 (file)
@@ -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)) {