+2012-02-10 Vladimir Serbinenko <phcoder@gmail.com>
+
+ * util/grub-editenv.c (argp_parser): Make static.
+ (create_envblk_file): Use xmalloc.
+ (open_envblk_file): Likewise.
+ Resepect format security.
+ (set_variables): Respect format security.
+
2012-02-10 Vladimir Serbinenko <phcoder@gmail.com>
* util/getroot.c (grub_find_device): Respect format security.
/* Set the bug report address */
const char *argp_program_bug_address = "<"PACKAGE_BUGREPORT">";
-error_t argp_parser (int key, char *arg, struct argp_state *state)
+static error_t argp_parser (int key, char *arg, struct argp_state *state)
{
switch (key)
{
char *buf;
char *namenew;
- buf = malloc (DEFAULT_ENVBLK_SIZE);
- if (! buf)
- grub_util_error (_("out of memory"));
+ buf = xmalloc (DEFAULT_ENVBLK_SIZE);
namenew = xasprintf ("%s.new", name);
fp = fopen (namenew, "wb");
grub_util_error (_("cannot seek `%s': %s"), name,
strerror (errno));
- buf = malloc (size);
- if (! buf)
- grub_util_error (_("out of memory"));
+ buf = xmalloc (size);
if (fread (buf, 1, size, fp) != size)
grub_util_error (_("cannot read `%s': %s"), name,
envblk = grub_envblk_open (buf, size);
if (! envblk)
- grub_util_error (_("invalid environment block"));
+ grub_util_error ("%s", _("invalid environment block"));
return envblk;
}
*(p++) = 0;
if (! grub_envblk_set (envblk, argv[0], p))
- grub_util_error (_("environment block too small"));
+ grub_util_error ("%s", _("environment block too small"));
argc--;
argv++;