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: <https://github.com/shadow-maint/shadow/pull/737>
Easter-egg: 8492dee663 ("subids: support nsswitch")
Signed-off-by: Alejandro Colomar <alx@kernel.org>
This commit is contained in:
committed by
Serge Hallyn
parent
2f9ca4b49d
commit
07b885318f
@@ -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;
|
||||
|
||||
+3
-7
@@ -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';
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -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)) {
|
||||
|
||||
Reference in New Issue
Block a user