]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
test_mount_optstr: use xstrdup()
authorKarel Zak <kzak@redhat.com>
Thu, 23 Sep 2021 11:11:16 +0000 (13:11 +0200)
committerKarel Zak <kzak@redhat.com>
Thu, 23 Sep 2021 11:11:16 +0000 (13:11 +0200)
Fixes: https://github.com/karelzak/util-linux/issues/1434
Signed-off-by: Karel Zak <kzak@redhat.com>
libmount/src/optstr.c

index e78109af5ce4f228a62617e6e4df16141fd69811..5adfd4dae61353ed6d1486a9e73449aec19bb7fb 100644 (file)
@@ -1170,6 +1170,7 @@ int mnt_match_options(const char *optstr, const char *pattern)
 }
 
 #ifdef TEST_PROGRAM
+#include "xalloc.h"
 
 static int test_append(struct libmnt_test *ts, int argc, char *argv[])
 {
@@ -1179,7 +1180,7 @@ static int test_append(struct libmnt_test *ts, int argc, char *argv[])
 
        if (argc < 3)
                return -EINVAL;
-       optstr = strdup(argv[1]);
+       optstr = xstrdup(argv[1]);
        name = argv[2];
 
        if (argc == 4)
@@ -1200,7 +1201,7 @@ static int test_prepend(struct libmnt_test *ts, int argc, char *argv[])
 
        if (argc < 3)
                return -EINVAL;
-       optstr = strdup(argv[1]);
+       optstr = xstrdup(argv[1]);
        name = argv[2];
 
        if (argc == 4)
@@ -1221,7 +1222,7 @@ static int test_split(struct libmnt_test *ts, int argc, char *argv[])
        if (argc < 2)
                return -EINVAL;
 
-       optstr = strdup(argv[1]);
+       optstr = xstrdup(argv[1]);
 
        rc = mnt_split_optstr(optstr, &user, &vfs, &fs, 0, 0);
        if (!rc) {
@@ -1246,7 +1247,7 @@ static int test_flags(struct libmnt_test *ts, int argc, char *argv[])
        if (argc < 2)
                return -EINVAL;
 
-       optstr = strdup(argv[1]);
+       optstr = xstrdup(argv[1]);
 
        rc = mnt_optstr_get_flags(optstr, &fl, mnt_get_builtin_optmap(MNT_LINUX_MAP));
        if (rc)
@@ -1281,7 +1282,7 @@ static int test_apply(struct libmnt_test *ts, int argc, char *argv[])
                return -EINVAL;
        }
 
-       optstr = strdup(argv[2]);
+       optstr = xstrdup(argv[2]);
        flags = strtoul(argv[3], NULL, 16);
 
        printf("flags:  0x%08lx\n", flags);
@@ -1301,7 +1302,7 @@ static int test_set(struct libmnt_test *ts, int argc, char *argv[])
 
        if (argc < 3)
                return -EINVAL;
-       optstr = strdup(argv[1]);
+       optstr = xstrdup(argv[1]);
        name = argv[2];
 
        if (argc == 4)
@@ -1351,7 +1352,7 @@ static int test_remove(struct libmnt_test *ts, int argc, char *argv[])
 
        if (argc < 3)
                return -EINVAL;
-       optstr = strdup(argv[1]);
+       optstr = xstrdup(argv[1]);
        name = argv[2];
 
        rc = mnt_optstr_remove_option(&optstr, name);
@@ -1369,7 +1370,7 @@ static int test_dedup(struct libmnt_test *ts, int argc, char *argv[])
 
        if (argc < 3)
                return -EINVAL;
-       optstr = strdup(argv[1]);
+       optstr = xstrdup(argv[1]);
        name = argv[2];
 
        rc = mnt_optstr_deduplicate_option(&optstr, name);
@@ -1389,7 +1390,7 @@ static int test_fix(struct libmnt_test *ts, int argc, char *argv[])
        if (argc < 2)
                return -EINVAL;
 
-       next = optstr = strdup(argv[1]);
+       next = optstr = xstrdup(argv[1]);
 
        printf("optstr: %s\n", optstr);