From: Alejandro Colomar Date: Sat, 8 Feb 2025 23:18:58 +0000 (+0100) Subject: lib/, src/: Use strcaseeq() instead of its pattern X-Git-Tag: 4.17.3~10 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5e362305e67a6fd2425dac86fdb9acdae943a067;p=thirdparty%2Fshadow.git lib/, src/: Use strcaseeq() instead of its pattern Signed-off-by: Alejandro Colomar --- diff --git a/lib/getdef.c b/lib/getdef.c index d234fe18b..f5cf391f8 100644 --- a/lib/getdef.c +++ b/lib/getdef.c @@ -32,6 +32,7 @@ #include "string/sprintf/xasprintf.h" #include "string/strchr/stpspn.h" #include "string/strchr/strrspn.h" +#include "string/strcmp/strcaseeq.h" #include "string/strcmp/streq.h" #include "string/strtok/stpsep.h" @@ -226,7 +227,7 @@ bool getdef_bool (const char *item) return false; } - return (strcasecmp (d->value, "yes") == 0); + return strcaseeq(d->value, "yes"); } diff --git a/src/login_nopam.c b/src/login_nopam.c index 896ab9410..dfd6f1353 100644 --- a/src/login_nopam.c +++ b/src/login_nopam.c @@ -60,6 +60,7 @@ #include "prototypes.h" #include "sizeof.h" #include "string/strchr/strrspn.h" +#include "string/strcmp/strcaseeq.h" #include "string/strcmp/streq.h" #include "string/strtok/stpsep.h" @@ -158,7 +159,7 @@ list_match(char *list, const char *item, bool (*match_fn)(char *, const char*)) * affected by any exceptions. */ while (NULL != (tok = strsep(&list, ", \t"))) { - if (strcasecmp (tok, "EXCEPT") == 0) { /* EXCEPT: invert */ + if (strcaseeq(tok, "EXCEPT")) { /* EXCEPT: invert */ if (!matched) { /* stop processing: not part of list */ break; } @@ -232,7 +233,7 @@ static bool user_match (char *tok, const char *string) } else if ((group = getgrnam (tok)) != NULL) { /* try group membership */ int i; for (i = 0; NULL != group->gr_mem[i]; i++) { - if (strcasecmp (string, group->gr_mem[i]) == 0) { + if (strcaseeq(string, group->gr_mem[i])) { return true; } } @@ -309,10 +310,10 @@ static bool from_match (char *tok, const char *string) str_len = strlen (string); tok_len = strlen (tok); if ( (str_len > tok_len) - && (strcasecmp (tok, string + str_len - tok_len) == 0)) { + && strcaseeq(tok, string + str_len - tok_len)) { return true; } - } else if (strcasecmp (tok, "LOCAL") == 0) { /* local: no dots */ + } else if (strcaseeq(tok, "LOCAL")) { /* LOCAL: no dots */ if (strchr (string, '.') == NULL) { return true; } @@ -331,9 +332,9 @@ static bool string_match (const char *tok, const char *string) * If the token has the magic value "ALL" the match always succeeds. * Otherwise, return true if the token fully matches the string. */ - if (strcasecmp (tok, "ALL") == 0) { /* all: always matches */ + if (strcaseeq(tok, "ALL")) { /* ALL: always matches */ return true; - } else if (strcasecmp (tok, string) == 0) { /* try exact match */ + } else if (strcaseeq(tok, string)) { /* try exact match */ return true; } return false;