]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
* fs/udf.c (grub_udf_iterate_dir): Decode the Unicode filenames.
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Mon, 19 Apr 2010 00:41:48 +0000 (02:41 +0200)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Mon, 19 Apr 2010 00:41:48 +0000 (02:41 +0200)
ChangeLog
fs/udf.c

index c9c398603ee73da2b7de568adf63b306a4ca10a6..ee2cf4079da650e003ae4843950d3a910de01f93 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2010-04-19  Vladimir Serbinenko  <phcoder@gmail.com>
+
+       * fs/udf.c (grub_udf_iterate_dir): Decode the Unicode filenames.
+
 2010-04-18  Vladimir Serbinenko  <phcoder@gmail.com>
 
        * boot/sparc64/ieee1275/boot.S: Various size-reducing changes.
index cecb6eb78e1a531b74671f3a7f6a55776ed2d024..725468f5431d32832087420ec79e3dc6deb1721e 100644 (file)
--- a/fs/udf.c
+++ b/fs/udf.c
@@ -25,6 +25,7 @@
 #include <grub/dl.h>
 #include <grub/types.h>
 #include <grub/fshelp.h>
+#include <grub/charset.h>
 
 #define GRUB_UDF_MAX_PDS               2
 #define GRUB_UDF_MAX_PMS               6
@@ -745,19 +746,41 @@ grub_udf_iterate_dir (grub_fshelp_node_t dir,
       else
        {
          enum grub_fshelp_filetype type;
-         char filename[dirent.file_ident_length + 1];
+         grub_uint8_t raw[dirent.file_ident_length];
+         grub_uint16_t utf16[dirent.file_ident_length - 1];
+         grub_uint8_t filename[dirent.file_ident_length * 2];
+         grub_size_t utf16len;
 
          type = ((dirent.characteristics & GRUB_UDF_FID_CHAR_DIRECTORY) ?
                  (GRUB_FSHELP_DIR) : (GRUB_FSHELP_REG));
 
          if ((grub_udf_read_file (dir, 0, offset,
-                                  dirent.file_ident_length, filename))
+                                  dirent.file_ident_length,
+                                  (char *) raw))
              != dirent.file_ident_length)
            return 0;
 
-         filename[dirent.file_ident_length] = 0;
-         if (hook (&filename[1], type, child))
-           return 1;
+         if (raw[0] == 8)
+           {
+             unsigned i;
+             utf16len = dirent.file_ident_length - 1;
+             for (i = 0; i < utf16len; i++)
+               utf16[i] = raw[i + 1];
+           }
+         if (raw[0] == 16)
+           {
+             unsigned i;
+             utf16len = (dirent.file_ident_length - 1) / 2;
+             for (i = 0; i < utf16len; i++)
+               utf16[i] = (raw[2 * i + 1] << 8) | raw[2*i + 2];
+           }
+         if (raw[0] == 8 || raw[0] == 16)
+           {
+             *grub_utf16_to_utf8 (filename, utf16, utf16len) = '\0';
+         
+             if (hook ((char *) filename, type, child))
+               return 1;
+           }
        }
 
       /* Align to dword boundary.  */