]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
* grub-core/loader/efi/chainloader.c (copy_file_path): Handle non-ASCII
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Wed, 6 Jun 2012 00:34:32 +0000 (02:34 +0200)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Wed, 6 Jun 2012 00:34:32 +0000 (02:34 +0200)
filenames.
(make_file_path): Likewise.

ChangeLog
grub-core/loader/efi/chainloader.c

index 01c5dee961413c0dd1f67d133f4466dcf324254e..cd8aaf74c0933eb63b62832c4555048adcbc74c9 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2012-06-06  Vladimir Serbinenko  <phcoder@gmail.com>
+
+       * grub-core/loader/efi/chainloader.c (copy_file_path): Handle non-ASCII
+       filenames.
+       (make_file_path): Likewise.
+
 2012-06-06  Vladimir Serbinenko  <phcoder@gmail.com>
 
        * grub-core/disk/ieee1275/ofdisk.c (scan): Support vscsi on IBM
index 83d3f93e61d3b6ff0701ded71979fefb719fee16..3f3e6e3817f120d9ea96438cc8571308b5b5d8e1 100644 (file)
@@ -111,14 +111,16 @@ copy_file_path (grub_efi_file_path_device_path_t *fp,
 
   fp->header.type = GRUB_EFI_MEDIA_DEVICE_PATH_TYPE;
   fp->header.subtype = GRUB_EFI_FILE_PATH_DEVICE_PATH_SUBTYPE;
-  size = len * sizeof (grub_efi_char16_t) + sizeof (*fp);
+
+  size = grub_utf8_to_utf16 (fp->path_name, len * GRUB_MAX_UTF16_PER_UTF8,
+                            (const grub_uint8_t *) str, len, 0);
+  for (p = fp->path_name; p < fp->path_name + size; p++)
+    if (*p == '/')
+      *p = '\\';
+
+  size = size * sizeof (grub_efi_char16_t) + sizeof (*fp);
   fp->header.length[0] = (grub_efi_uint8_t) (size & 0xff);
   fp->header.length[1] = (grub_efi_uint8_t) (size >> 8);
-  for (p = fp->path_name; len > 0; len--, p++, str++)
-    {
-      /* FIXME: this assumes that the path is in ASCII.  */
-      *p = (grub_efi_char16_t) (*str == '/' ? '\\' : *str);
-    }
 }
 
 static grub_efi_device_path_t *
@@ -154,6 +156,7 @@ make_file_path (grub_efi_device_path_t *dp, const char *filename)
 
   file_path = grub_malloc (size
                           + ((grub_strlen (dir_start) + 1)
+                             * GRUB_MAX_UTF16_PER_UTF8
                              * sizeof (grub_efi_char16_t))
                           + sizeof (grub_efi_file_path_device_path_t) * 2);
   if (! file_path)