]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
src/login_nopam.c: login_access(): Simplify, calling strchr(3)
authorAlejandro Colomar <alx@kernel.org>
Sat, 18 May 2024 20:03:08 +0000 (22:03 +0200)
committerSerge Hallyn <serge@hallyn.com>
Wed, 3 Jul 2024 15:03:12 +0000 (10:03 -0500)
Signed-off-by: Alejandro Colomar <alx@kernel.org>
src/login_nopam.c

index e6f77d1ccd1668b58e09e1a158928ae86f6aabb6..1a2b17367f89f5b38f45e2f28fe1dc9dada7f110 100644 (file)
@@ -100,10 +100,8 @@ int login_access (const char *user, const char *from)
                int lineno = 0; /* for diagnostics */
                while (   !match
                       && (fgets (line, sizeof (line), fp) == line)) {
-                       ptrdiff_t  end;
                        lineno++;
-                       end = strlen (line) - 1;
-                       if (line[0] == '\0' || line[end] != '\n') {
+                       if (line[0] == '\0' || strchr(line, '\n') == NULL) {
                                SYSLOG ((LOG_ERR,
                                         "%s: line %d: missing newline or line too long",
                                         TABLE, lineno));