From 102fae4a1ca7c6f05e05548a7bba72a5d23df21c Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Fri, 10 Feb 2012 14:12:43 +0100 Subject: [PATCH] * util/grub-mount.c (fuse_init): Avoid improper use of strings. * util/grub-fstest.c (fstest): Likewise. --- ChangeLog | 5 +++++ util/grub-fstest.c | 9 ++++++--- util/grub-mount.c | 6 ++++-- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 852bf6aa7..79ac222fe 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2012-02-10 Vladimir Serbinenko + + * util/grub-mount.c (fuse_init): Avoid improper use of strings. + * util/grub-fstest.c (fstest): Likewise. + 2012-02-10 Vladimir Serbinenko * grub-core/disk/geli.c (grub_md_sha256_real): Respect format security. diff --git a/util/grub-fstest.c b/util/grub-fstest.c index 1544fc5ce..37f4fb7ee 100644 --- a/util/grub-fstest.c +++ b/util/grub-fstest.c @@ -342,12 +342,13 @@ fstest (int n) } { - char *argv[2] = { "-a", NULL}; if (mount_crypt) { + char *argv[2] = { xstrdup ("-a"), NULL}; if (execute_command ("cryptomount", 1, argv)) grub_util_error (_("`cryptomount' command fails: %s"), grub_errmsg); + free (argv[0]); } } @@ -396,7 +397,7 @@ fstest (int n) grub_device_t dev; grub_fs_t fs; char *uuid = 0; - char *argv[3] = { "-l", NULL, NULL}; + char *argv[3] = { xstrdup ("-l"), NULL, NULL}; dev = grub_device_open (n ? args[0] : 0); if (!dev) grub_util_error ("%s", grub_errmsg); @@ -411,6 +412,7 @@ fstest (int n) grub_util_error ("%s", _("couldn't retrieve UUID")); argv[1] = uuid; execute_command ("xnu_uuid", 2, argv); + grub_free (argv[0]); grub_free (uuid); grub_device_close (dev); } @@ -424,12 +426,13 @@ fstest (int n) if (!loop_name) grub_util_error ("%s", grub_errmsg); - argv[0] = "-d"; + argv[0] = xstrdup ("-d"); argv[1] = loop_name; execute_command ("loopback", 2, argv); grub_free (loop_name); + grub_free (argv[0]); } } diff --git a/util/grub-mount.c b/util/grub-mount.c index a38348aa5..41b89925b 100644 --- a/util/grub-mount.c +++ b/util/grub-mount.c @@ -356,9 +356,10 @@ fuse_init (void) if (mount_crypt) { - char *argv[2] = { "-a", NULL}; + char *argv[2] = { xstrdup ("-a"), NULL}; if (execute_command ("cryptomount", 1, argv)) grub_util_error (_("cryptomount command fails: %s"), grub_errmsg); + free (argv[0]); } grub_lvm_fini (); @@ -392,11 +393,12 @@ fuse_init (void) if (!loop_name) grub_util_error ("%s", grub_errmsg); - argv[0] = "-d"; + argv[0] = xstrdup ("-d"); argv[1] = loop_name; execute_command ("loopback", 2, argv); + grub_free (argv[0]); grub_free (loop_name); }