]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libblkid: avoid strcasecmp() for ASCII-only strings
authorKarel Zak <kzak@redhat.com>
Tue, 1 Apr 2025 15:45:01 +0000 (17:45 +0200)
committerKarel Zak <kzak@redhat.com>
Wed, 2 Apr 2025 09:06:17 +0000 (11:06 +0200)
Use cctype.h for locale-independent string comparison and to avoid
tricky string conversions like in tr_TR locales.

Signed-off-by: Karel Zak <kzak@redhat.com>
libblkid/src/config.c
libblkid/src/partitions/partitions.c

index dcc18f2dd3f980c7b5ab9f378613314c44903dcf..934d28d65afcfc6286efdc09605fe8d6237cb990 100644 (file)
@@ -29,6 +29,7 @@
 
 #include "blkidP.h"
 #include "env.h"
+#include "cctype.h"
 
 static int parse_evaluate(struct blkid_config *conf, char *s)
 {
@@ -94,7 +95,7 @@ static int parse_next(FILE *fd, struct blkid_config *conf)
 
        if (!strncmp(s, "SEND_UEVENT=", 12)) {
                s += 12;
-               if (*s && !strcasecmp(s, "yes"))
+               if (*s && !c_strcasecmp(s, "yes"))
                        conf->uevent = TRUE;
                else if (*s)
                        conf->uevent = FALSE;
index 07a5d1ad6f08be5823fc0ea5d7bdebdad08ad15a..9df813c92143203c8989011abbd04c4d77dab9ab 100644 (file)
@@ -23,6 +23,7 @@
 #include "partitions.h"
 #include "sysfs.h"
 #include "strutils.h"
+#include "cctype.h"
 
 /**
  * SECTION: partitions
@@ -1044,7 +1045,7 @@ blkid_partition blkid_partlist_devno_to_partition(blkid_partlist ls, dev_t devno
                        tmp = uuid;
                        prefix = uuid ? strsep(&tmp, "-") : NULL;
 
-                       if (prefix && strncasecmp(prefix, "part", 4) == 0) {
+                       if (prefix && c_strncasecmp(prefix, "part", 4) == 0) {
                                char *end = NULL;
 
                                errno = 0;