]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
* util/grub-editenv.c (argp_parser): Make static.
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Fri, 10 Feb 2012 12:26:19 +0000 (13:26 +0100)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Fri, 10 Feb 2012 12:26:19 +0000 (13:26 +0100)
(create_envblk_file): Use xmalloc.
(open_envblk_file): Likewise.
Resepect format security.
(set_variables): Respect format security.

ChangeLog
util/grub-editenv.c

index e444e15d2a32f3698e10bd9acdd3a26709936126..e94090b34fa38c5356b35590a31a71ee516f233c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+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.
index 2a710a8fb21b1e9a5c77c6ebc08673f43eace0d1..cb212f0b9f4dc1921568a0ffb50cc35e5d81e8de 100644 (file)
@@ -63,7 +63,7 @@ void (*argp_program_version_hook) (FILE *, struct argp_state *) = print_version;
 /* 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)
     {
@@ -113,9 +113,7 @@ create_envblk_file (const char *name)
   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");
@@ -169,9 +167,7 @@ open_envblk_file (const char *name)
     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,
@@ -181,7 +177,7 @@ open_envblk_file (const char *name)
 
   envblk = grub_envblk_open (buf, size);
   if (! envblk)
-    grub_util_error (_("invalid environment block"));
+    grub_util_error ("%s", _("invalid environment block"));
 
   return envblk;
 }
@@ -239,7 +235,7 @@ set_variables (const char *name, int argc, char *argv[])
       *(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++;