]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
* grub-core/kern/ieee1275/openfw.c (grub_ieee1275_encode_devname):
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Wed, 20 Jun 2012 21:31:59 +0000 (23:31 +0200)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Wed, 20 Jun 2012 21:31:59 +0000 (23:31 +0200)
Escape commas.

ChangeLog
grub-core/kern/ieee1275/openfw.c

index 56627dcad9ae063a723fea0dfeab97fb1edc52c5..fc8b21c1e03c9e7f9495aa10b50b2d0ee95e0f53 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2012-06-20  Vladimir Serbinenko  <phcoder@gmail.com>
+
+       * grub-core/kern/ieee1275/openfw.c (grub_ieee1275_encode_devname):
+       Escape commas.
+
 2012-06-20  Vladimir Serbinenko  <phcoder@gmail.com>
 
        Restructure FAT driver to avoid hook in label reading as it hits a
index 0fedad8428a6e00fd076b5802ca541c6f7740d88..40abaa37306a50a9aceae4e1688a5e98a8ce084e 100644 (file)
@@ -436,21 +436,42 @@ char *
 grub_ieee1275_encode_devname (const char *path)
 {
   char *device = grub_ieee1275_get_devname (path);
-  char *partition = grub_ieee1275_parse_args (path, GRUB_PARSE_PARTITION);
+  char *partition;
   char *encoding;
+  char *optr;
+  const char *iptr;
 
+  encoding = grub_malloc (sizeof ("ieee1275/") + 2 * grub_strlen (device)
+                         + sizeof (",XXXXXXXXXXXX"));
+  if (!encoding)
+    {
+      grub_free (device);
+      return 0;
+    }
+
+  partition = grub_ieee1275_parse_args (path, GRUB_PARSE_PARTITION);
+
+  optr = grub_stpcpy (encoding, "ieee1275/");
+  for (iptr = device; *iptr; )
+    {
+      if (*iptr == ',')
+       *optr++ ='\\';
+      *optr++ = *iptr++;
+    }
   if (partition && partition[0])
     {
       unsigned int partno = grub_strtoul (partition, 0, 0);
 
+      *optr++ = ',';
+
       if (grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_0_BASED_PARTITIONS))
        /* GRUB partition 1 is OF partition 0.  */
        partno++;
 
-      encoding = grub_xasprintf ("ieee1275/%s,%d", device, partno);
+      grub_snprintf (optr, sizeof ("XXXXXXXXXXXX"), "%d", partno);
     }
   else
-    encoding = grub_xasprintf ("ieee1275/%s", device);
+    *optr = '\0';
 
   grub_free (partition);
   grub_free (device);