From: Alejandro Colomar Date: Wed, 3 Jul 2024 21:49:04 +0000 (+0200) Subject: src/suauth.c: check_su_auth(): Use pointers to simplify X-Git-Tag: 4.17.0-rc1~58 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4a1573940817008ab070925f28ab45aee4976a77;p=thirdparty%2Fshadow.git src/suauth.c: check_su_auth(): Use pointers to simplify Signed-off-by: Alejandro Colomar --- diff --git a/src/suauth.c b/src/suauth.c index 895f1278b..cbb33dc8d 100644 --- a/src/suauth.c +++ b/src/suauth.c @@ -18,6 +18,7 @@ #include "defines.h" #include "prototypes.h" +#include "string/strchr/stpspn.h" #include "string/strchr/strrspn.h" #include "string/strtok/stpsep.h" @@ -47,7 +48,6 @@ int check_su_auth (const char *actual_id, const char *wanted_id, bool su_to_root) { - int posn; const char field[] = ":"; FILE *authfile_fd; char temp[1024]; @@ -73,6 +73,8 @@ int check_su_auth (const char *actual_id, } while (fgets (temp, sizeof (temp), authfile_fd) != NULL) { + char *p; + lines++; if (stpsep(temp, "\n") == NULL) { @@ -84,12 +86,11 @@ int check_su_auth (const char *actual_id, stpcpy(strrspn(temp, " \t"), ""); - posn = strspn(temp, " \t"); - - if (temp[posn] == '#' || temp[posn] == '\0') { + p = stpspn(temp, " \t"); + if (*p == '#' || *p == '\0') continue; - } - if (!(to_users = strtok (temp + posn, field)) + + if (!(to_users = strtok(p, field)) || !(from_users = strtok (NULL, field)) || !(action = strtok (NULL, field)) || strtok (NULL, field)) {