* util/getroot.c (grub_find_device): Respect format security.

(get_mdadm_uuid): Remove unused variable.
	(grub_util_pull_device): Dont call gettext on already translated
	grub_errmsg.
	(find_system_device): Remove unused variable.
	(grub_util_get_grub_dev): Likewise.
	(grub_make_system_path_relative_to_its_root): Respect format security.
This commit is contained in:
Vladimir 'phcoder' Serbinenko 2012-02-10 13:17:12 +01:00
parent 1b024b4ea0
commit 45b0c8b797
2 changed files with 19 additions and 10 deletions

View file

@ -1,3 +1,13 @@
2012-02-10 Vladimir Serbinenko <phcoder@gmail.com>
* util/getroot.c (grub_find_device): Respect format security.
(get_mdadm_uuid): Remove unused variable.
(grub_util_pull_device): Dont call gettext on already translated
grub_errmsg.
(find_system_device): Remove unused variable.
(grub_util_get_grub_dev): Likewise.
(grub_make_system_path_relative_to_its_root): Respect format security.
2012-02-10 Vladimir Serbinenko <phcoder@gmail.com> 2012-02-10 Vladimir Serbinenko <phcoder@gmail.com>
* util/grub-fstest.c (execute_command): Make first argument * util/grub-fstest.c (execute_command): Make first argument

View file

@ -612,7 +612,8 @@ grub_find_device (const char *dir, dev_t dev)
if (res) if (res)
{ {
if (chdir (saved_cwd) < 0) if (chdir (saved_cwd) < 0)
grub_util_error (_("cannot restore the original directory")); grub_util_error ("%s",
_("cannot restore the original directory"));
free (saved_cwd); free (saved_cwd);
closedir (dp); closedir (dp);
@ -662,7 +663,7 @@ grub_find_device (const char *dir, dev_t dev)
continue; continue;
if (chdir (saved_cwd) < 0) if (chdir (saved_cwd) < 0)
grub_util_error (_("cannot restore the original directory")); grub_util_error ("%s", _("cannot restore the original directory"));
free (saved_cwd); free (saved_cwd);
closedir (dp); closedir (dp);
@ -671,7 +672,7 @@ grub_find_device (const char *dir, dev_t dev)
} }
if (chdir (saved_cwd) < 0) if (chdir (saved_cwd) < 0)
grub_util_error (_("cannot restore the original directory")); grub_util_error ("%s", _("cannot restore the original directory"));
free (saved_cwd); free (saved_cwd);
closedir (dp); closedir (dp);
@ -1143,7 +1144,6 @@ get_mdadm_uuid (const char *os_dev)
if (strncmp (buf, "MD_UUID=", sizeof ("MD_UUID=") - 1) == 0) if (strncmp (buf, "MD_UUID=", sizeof ("MD_UUID=") - 1) == 0)
{ {
char *name_start, *ptri, *ptro; char *name_start, *ptri, *ptro;
size_t name_len;
free (name); free (name);
name_start = buf + sizeof ("MD_UUID=") - 1; name_start = buf + sizeof ("MD_UUID=") - 1;
@ -1235,7 +1235,7 @@ grub_util_pull_device (const char *os_dev)
err = grub_cryptodisk_cheat_mount (grdev, os_dev); err = grub_cryptodisk_cheat_mount (grdev, os_dev);
if (err) if (err)
grub_util_error (_("can't mount crypto volume `%s': %s"), grub_util_error (_("can't mount crypto volume `%s': %s"),
lastsubdev, _(grub_errmsg)); lastsubdev, grub_errmsg);
} }
grub_free (grdev); grub_free (grdev);
@ -1280,7 +1280,7 @@ grub_util_pull_device (const char *os_dev)
err = grub_cryptodisk_cheat_mount (grdev, os_dev); err = grub_cryptodisk_cheat_mount (grdev, os_dev);
if (err) if (err)
grub_util_error (_("can't mount crypto volume `%s': %s"), grub_util_error (_("can't mount crypto volume `%s': %s"),
lastsubdev, _(grub_errmsg)); lastsubdev, grub_errmsg);
} }
grub_free (grdev); grub_free (grdev);
} }
@ -1800,7 +1800,6 @@ devmapper_out:
static const char * static const char *
find_system_device (const char *os_dev, struct stat *st, int convert, int add) find_system_device (const char *os_dev, struct stat *st, int convert, int add)
{ {
unsigned int i;
char *os_disk; char *os_disk;
const char *drive; const char *drive;
@ -2138,7 +2137,7 @@ grub_util_get_grub_dev (const char *os_dev)
case GRUB_DEV_ABSTRACTION_LVM: case GRUB_DEV_ABSTRACTION_LVM:
{ {
unsigned short i, len; unsigned short len;
grub_size_t offset = sizeof (LVM_DEV_MAPPER_STRING) - 1; grub_size_t offset = sizeof (LVM_DEV_MAPPER_STRING) - 1;
len = strlen (os_dev) - offset + 1; len = strlen (os_dev) - offset + 1;
@ -2300,7 +2299,6 @@ grub_util_get_grub_dev (const char *os_dev)
{ {
char *mdadm_name = get_mdadm_uuid (os_dev); char *mdadm_name = get_mdadm_uuid (os_dev);
struct stat st;
if (mdadm_name) if (mdadm_name)
{ {
@ -2507,7 +2505,8 @@ grub_make_system_path_relative_to_its_root (const char *path)
p = strrchr (buf, '/'); p = strrchr (buf, '/');
if (p == NULL) if (p == NULL)
/* This should never happen. */ /* This should never happen. */
grub_util_error (_("FIXME: no / in buf. (make_system_path_relative_to_its_root)")); grub_util_error ("%s",
_("FIXME: no / in buf. (make_system_path_relative_to_its_root)"));
if (p != buf) if (p != buf)
*p = 0; *p = 0;
else else