From 5d1d4e288f57d741958b87704b1368a84c2da03f Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Fri, 10 Feb 2012 13:03:21 +0100 Subject: [PATCH] * util/grub-mount.c (root): Make const char *. (execute_command): Make first argument a const char *. (fuse_init): Respect format security. (argp_parser): Make static. Remove unused variable. (main): Make default_root a const char *. Respect format security. --- ChangeLog | 9 +++++++++ util/grub-mount.c | 21 ++++++++++----------- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1631d5ac6..8a17916f8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2012-02-10 Vladimir Serbinenko + + * util/grub-mount.c (root): Make const char *. + (execute_command): Make first argument a const char *. + (fuse_init): Respect format security. + (argp_parser): Make static. Remove unused variable. + (main): Make default_root a const char *. + Respect format security. + 2012-02-10 Vladimir Serbinenko * util/grub-probe.c (probe): Don't call gettext on already translated diff --git a/util/grub-mount.c b/util/grub-mount.c index ddb4ce7ff..a38348aa5 100644 --- a/util/grub-mount.c +++ b/util/grub-mount.c @@ -44,7 +44,7 @@ #include "progname.h" #include "argp.h" -static char *root = NULL; +static const char *root = NULL; grub_device_t dev = NULL; grub_fs_t fs = NULL; static char **images = NULL; @@ -55,7 +55,7 @@ static int num_disks = 0; static int mount_crypt = 0; static grub_err_t -execute_command (char *name, int n, char **args) +execute_command (const char *name, int n, char **args) { grub_command_t cmd; @@ -338,17 +338,17 @@ fuse_init (void) char *loop_name; loop_name = grub_xasprintf ("loop%d", i); if (!loop_name) - grub_util_error (grub_errmsg); + grub_util_error ("%s", grub_errmsg); host_file = grub_xasprintf ("(host)%s", images[i]); if (!host_file) - grub_util_error (grub_errmsg); + grub_util_error ("%s", grub_errmsg); argv[0] = loop_name; argv[1] = host_file; if (execute_command ("loopback", 2, argv)) - grub_util_error (_("loopback command fails")); + grub_util_error ("%s", _("loopback command fails")); grub_free (loop_name); grub_free (host_file); @@ -390,7 +390,7 @@ fuse_init (void) loop_name = grub_xasprintf ("loop%d", i); if (!loop_name) - grub_util_error (grub_errmsg); + grub_util_error ("%s", grub_errmsg); argv[0] = "-d"; argv[1] = loop_name; @@ -422,11 +422,9 @@ print_version (FILE *stream, struct argp_state *state) } void (*argp_program_version_hook) (FILE *, struct argp_state *) = print_version; -error_t +static error_t argp_parser (int key, char *arg, struct argp_state *state) { - char *p; - switch (key) { case 'r': @@ -512,7 +510,8 @@ struct argp argp = { int main (int argc, char *argv[]) { - char *default_root, *alloc_root; + const char *default_root; + char *alloc_root; set_program_name (argv[0]); @@ -528,7 +527,7 @@ main (int argc, char *argv[]) argp_parse (&argp, argc, argv, 0, 0, 0); if (num_disks < 2) - grub_util_error (_("need an image and mountpoint")); + grub_util_error ("%s", _("need an image and mountpoint")); fuse_args = xrealloc (fuse_args, (fuse_argc + 2) * sizeof (fuse_args[0])); fuse_args[fuse_argc] = images[num_disks - 1]; fuse_argc++;