]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
src/login_nopam.c: login_access(): Use stpsep() to simplify
authorAlejandro Colomar <alx@kernel.org>
Thu, 4 Jul 2024 12:35:24 +0000 (14:35 +0200)
committerSerge Hallyn <serge@hallyn.com>
Tue, 9 Jul 2024 01:25:01 +0000 (20:25 -0500)
Signed-off-by: Alejandro Colomar <alx@kernel.org>
src/login_nopam.c

index 2b19d15153f9065bc6b7f72aa2f50584128d5859..5c0ecc0e8dbe50bab23c8e3483d5dce57dfd73be 100644 (file)
@@ -104,7 +104,7 @@ int login_access (const char *user, const char *from)
                while (   !match
                       && (fgets (line, sizeof (line), fp) == line)) {
                        lineno++;
-                       if (line[0] == '\0' || strchr(line, '\n') == NULL) {
+                       if (stpsep(line, "\n") == NULL) {
                                SYSLOG ((LOG_ERR,
                                         "%s: line %d: missing newline or line too long",
                                         TABLE, lineno));
@@ -113,7 +113,7 @@ int login_access (const char *user, const char *from)
                        if (line[0] == '#') {
                                continue;       /* comment line */
                        }
-                       stpcpy(strrspn(line, " \t\n"), "");
+                       stpcpy(strrspn(line, " \t"), "");
                        if (line[0] == '\0') {  /* skip blank lines */
                                continue;
                        }