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.
This commit is contained in:
Giuseppe Caizzone 2010-11-14 16:51:45 +01:00 committed by Vladimir 'phcoder' Serbinenko
parent 406858a8a9
commit cb0229c587
2 changed files with 55 additions and 44 deletions

View file

@ -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> 2010-11-14 Giuseppe Caizzone <acaizzo@gmail.com>
Support reading files larger than 2 GiB. Support reading files larger than 2 GiB.

View file

@ -729,57 +729,60 @@ grub_udf_iterate_dir (grub_fshelp_node_t dir,
return 0; 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); 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. */ child = grub_malloc (sizeof (struct grub_fshelp_node));
if (hook ("..", GRUB_FSHELP_DIR, child)) if (!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)
return 0; return 0;
if (raw[0] == 8) if (grub_udf_read_icb (dir->data, &dirent.icb, child))
return 0;
if (dirent.characteristics & GRUB_UDF_FID_CHAR_PARENT)
{ {
unsigned i; /* This is the parent directory. */
utf16len = dirent.file_ident_length - 1; if (hook ("..", GRUB_FSHELP_DIR, child))
for (i = 0; i < utf16len; i++) return 1;
utf16[i] = raw[i + 1];
} }
if (raw[0] == 16) else
{ {
unsigned i; enum grub_fshelp_filetype type;
utf16len = (dirent.file_ident_length - 1) / 2; grub_uint8_t raw[dirent.file_ident_length];
for (i = 0; i < utf16len; i++) grub_uint16_t utf16[dirent.file_ident_length - 1];
utf16[i] = (raw[2 * i + 1] << 8) | raw[2*i + 2]; grub_uint8_t filename[dirent.file_ident_length * 2];
} grub_size_t utf16len = 0;
if (raw[0] == 8 || raw[0] == 16)
{ type = ((dirent.characteristics & GRUB_UDF_FID_CHAR_DIRECTORY) ?
*grub_utf16_to_utf8 (filename, utf16, utf16len) = '\0'; (GRUB_FSHELP_DIR) : (GRUB_FSHELP_REG));
if (hook ((char *) filename, type, child)) if ((grub_udf_read_file (dir, 0, offset,
return 1; 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;
}
} }
} }