test_mount_optstr: use xstrdup()
Fixes: https://github.com/karelzak/util-linux/issues/1434 Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
parent
8b3d8aad5d
commit
0c19e4ca61
|
@ -1170,6 +1170,7 @@ int mnt_match_options(const char *optstr, const char *pattern)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef TEST_PROGRAM
|
#ifdef TEST_PROGRAM
|
||||||
|
#include "xalloc.h"
|
||||||
|
|
||||||
static int test_append(struct libmnt_test *ts, int argc, char *argv[])
|
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)
|
if (argc < 3)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
optstr = strdup(argv[1]);
|
optstr = xstrdup(argv[1]);
|
||||||
name = argv[2];
|
name = argv[2];
|
||||||
|
|
||||||
if (argc == 4)
|
if (argc == 4)
|
||||||
|
@ -1200,7 +1201,7 @@ static int test_prepend(struct libmnt_test *ts, int argc, char *argv[])
|
||||||
|
|
||||||
if (argc < 3)
|
if (argc < 3)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
optstr = strdup(argv[1]);
|
optstr = xstrdup(argv[1]);
|
||||||
name = argv[2];
|
name = argv[2];
|
||||||
|
|
||||||
if (argc == 4)
|
if (argc == 4)
|
||||||
|
@ -1221,7 +1222,7 @@ static int test_split(struct libmnt_test *ts, int argc, char *argv[])
|
||||||
if (argc < 2)
|
if (argc < 2)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
optstr = strdup(argv[1]);
|
optstr = xstrdup(argv[1]);
|
||||||
|
|
||||||
rc = mnt_split_optstr(optstr, &user, &vfs, &fs, 0, 0);
|
rc = mnt_split_optstr(optstr, &user, &vfs, &fs, 0, 0);
|
||||||
if (!rc) {
|
if (!rc) {
|
||||||
|
@ -1246,7 +1247,7 @@ static int test_flags(struct libmnt_test *ts, int argc, char *argv[])
|
||||||
if (argc < 2)
|
if (argc < 2)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
optstr = strdup(argv[1]);
|
optstr = xstrdup(argv[1]);
|
||||||
|
|
||||||
rc = mnt_optstr_get_flags(optstr, &fl, mnt_get_builtin_optmap(MNT_LINUX_MAP));
|
rc = mnt_optstr_get_flags(optstr, &fl, mnt_get_builtin_optmap(MNT_LINUX_MAP));
|
||||||
if (rc)
|
if (rc)
|
||||||
|
@ -1281,7 +1282,7 @@ static int test_apply(struct libmnt_test *ts, int argc, char *argv[])
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
optstr = strdup(argv[2]);
|
optstr = xstrdup(argv[2]);
|
||||||
flags = strtoul(argv[3], NULL, 16);
|
flags = strtoul(argv[3], NULL, 16);
|
||||||
|
|
||||||
printf("flags: 0x%08lx\n", flags);
|
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)
|
if (argc < 3)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
optstr = strdup(argv[1]);
|
optstr = xstrdup(argv[1]);
|
||||||
name = argv[2];
|
name = argv[2];
|
||||||
|
|
||||||
if (argc == 4)
|
if (argc == 4)
|
||||||
|
@ -1351,7 +1352,7 @@ static int test_remove(struct libmnt_test *ts, int argc, char *argv[])
|
||||||
|
|
||||||
if (argc < 3)
|
if (argc < 3)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
optstr = strdup(argv[1]);
|
optstr = xstrdup(argv[1]);
|
||||||
name = argv[2];
|
name = argv[2];
|
||||||
|
|
||||||
rc = mnt_optstr_remove_option(&optstr, name);
|
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)
|
if (argc < 3)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
optstr = strdup(argv[1]);
|
optstr = xstrdup(argv[1]);
|
||||||
name = argv[2];
|
name = argv[2];
|
||||||
|
|
||||||
rc = mnt_optstr_deduplicate_option(&optstr, name);
|
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)
|
if (argc < 2)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
next = optstr = strdup(argv[1]);
|
next = optstr = xstrdup(argv[1]);
|
||||||
|
|
||||||
printf("optstr: %s\n", optstr);
|
printf("optstr: %s\n", optstr);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue