]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libmount: 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>
Thu, 3 Apr 2025 08:16:11 +0000 (10:16 +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>
(cherry picked from commit ea694f8b91b82474c018dac2250b03cb00685b26)

libmount/src/tab.c

index 8508715eab2768b6fca0b0e507f9e6bbdbb03334..a5070f8240c2041b22e68380664bae6baadbcc4e 100644 (file)
@@ -2054,6 +2054,7 @@ int mnt_table_is_fs_mounted(struct libmnt_table *tb, struct libmnt_fs *fstab_fs)
 
 #ifdef TEST_PROGRAM
 #include "pathnames.h"
+#include "cctype.h"
 
 static int parser_errcb(struct libmnt_table *tb __attribute__((unused)),
                        const char *filename, int line)
@@ -2229,9 +2230,9 @@ static int test_find(struct libmnt_test *ts __attribute__((unused)),
        mnt_table_set_cache(tb, mpc);
        mnt_unref_cache(mpc);
 
-       if (strcasecmp(find, "source") == 0)
+       if (c_strcasecmp(find, "source") == 0)
                fs = mnt_table_find_source(tb, what, dr);
-       else if (strcasecmp(find, "target") == 0)
+       else if (c_strcasecmp(find, "target") == 0)
                fs = mnt_table_find_target(tb, what, dr);
 
        if (!fs)