]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
Properly handle deleted files on UDF.
authorGiuseppe Caizzone <acaizzo@gmail.com>
Sun, 14 Nov 2010 15:51:45 +0000 (16:51 +0100)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Sun, 14 Nov 2010 15:51:45 +0000 (16:51 +0100)
* grub-core/fs/udf.c (grub_udf_iterate_dir): Skip directory entries
whose "characteristics" field has the bit GRUB_UDF_FID_CHAR_DELETED
set.

ChangeLog
grub-core/fs/udf.c

index 5cffcfdbda9c76042691740ef2b0be46aa89bab4..d944dc0f83e8f8f49f2fbc40360020d0b7d1efc8 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2010-11-14  Giuseppe Caizzone <acaizzo@gmail.com>
+
+       Properly handle deleted files on UDF.
+
+       * grub-core/fs/udf.c (grub_udf_iterate_dir): Skip directory entries
+       whose "characteristics" field has the bit GRUB_UDF_FID_CHAR_DELETED
+       set.
+
 2010-11-14  Giuseppe Caizzone <acaizzo@gmail.com>
 
        Support reading files larger than 2 GiB.
index 1600a4cd54c7dc5ea87c32592388b633576a643a..9e729a3495fb46ed88ba973abb8d1b89d8d33f82 100644 (file)
@@ -729,57 +729,60 @@ grub_udf_iterate_dir (grub_fshelp_node_t dir,
          return 0;
        }
 
-      child = grub_malloc (sizeof (struct grub_fshelp_node));
-      if (!child)
-       return 0;
-
-      if (grub_udf_read_icb (dir->data, &dirent.icb, child))
-       return 0;
-
       offset += sizeof (dirent) + U16 (dirent.imp_use_length);
-      if (dirent.characteristics & GRUB_UDF_FID_CHAR_PARENT)
+      if (!(dirent.characteristics & GRUB_UDF_FID_CHAR_DELETED))
        {
-         /* This is the parent directory.  */
-         if (hook ("..", GRUB_FSHELP_DIR, child))
-           return 1;
-       }
-      else
-       {
-         enum grub_fshelp_filetype type;
-         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 = 0;
-
-         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,
-                                  (char *) raw))
-             != dirent.file_ident_length)
+         child = grub_malloc (sizeof (struct grub_fshelp_node));
+         if (!child)
            return 0;
 
-         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)
+          if (grub_udf_read_icb (dir->data, &dirent.icb, child))
+           return 0;
+
+          if (dirent.characteristics & GRUB_UDF_FID_CHAR_PARENT)
            {
-             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];
+             /* This is the parent directory.  */
+             if (hook ("..", GRUB_FSHELP_DIR, child))
+               return 1;
            }
-         if (raw[0] == 8 || raw[0] == 16)
+          else
            {
-             *grub_utf16_to_utf8 (filename, utf16, utf16len) = '\0';
-         
-             if (hook ((char *) filename, type, child))
-               return 1;
+             enum grub_fshelp_filetype type;
+             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 = 0;
+
+             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,
+                                      (char *) raw))
+                 != dirent.file_ident_length)
+               return 0;
+
+             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;
+               }
            }
        }