2009-06-11 Giuseppe Caizzone <acaizzo@gmail.com>

UDF fix

	* fs/udf.c (grub_udf_read_block): handle the fact that ad->length 
	is in bytes and not in blocks
This commit is contained in:
phcoder 2009-06-11 19:32:13 +00:00
parent 8ada9bc12e
commit 948f48e731
2 changed files with 16 additions and 6 deletions

View file

@ -1,3 +1,10 @@
2009-06-11 Giuseppe Caizzone <acaizzo@gmail.com>
UDF fix
* fs/udf.c (grub_udf_read_block): handle the fact that ad->length
is in bytes and not in blocks
2009-06-11 Pavel Roskin <proski@gnu.org> 2009-06-11 Pavel Roskin <proski@gnu.org>
* kern/i386/halt.c (grub_halt): Make `i' unsigned to fix a * kern/i386/halt.c (grub_halt): Make `i' unsigned to fix a

View file

@ -407,6 +407,7 @@ grub_udf_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock)
{ {
char *ptr; char *ptr;
int len; int len;
grub_disk_addr_t filebytes;
if (U16 (node->fe.tag.tag_ident) == GRUB_UDF_TAG_IDENT_FE) if (U16 (node->fe.tag.tag_ident) == GRUB_UDF_TAG_IDENT_FE)
{ {
@ -425,16 +426,17 @@ grub_udf_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock)
struct grub_udf_short_ad *ad = (struct grub_udf_short_ad *) ptr; struct grub_udf_short_ad *ad = (struct grub_udf_short_ad *) ptr;
len /= sizeof (struct grub_udf_short_ad); len /= sizeof (struct grub_udf_short_ad);
filebytes = fileblock * GRUB_UDF_BLKSZ;
while (len > 0) while (len > 0)
{ {
if (fileblock < U32 (ad->length)) if (filebytes < U32 (ad->length))
return ((U32 (ad->position) & GRUB_UDF_EXT_MASK) ? 0 : return ((U32 (ad->position) & GRUB_UDF_EXT_MASK) ? 0 :
(grub_udf_get_block (node->data, (grub_udf_get_block (node->data,
node->part_ref, node->part_ref,
ad->position) ad->position)
+ fileblock)); + (filebytes / GRUB_UDF_BLKSZ)));
fileblock -= U32 (ad->length); filebytes -= U32 (ad->length);
ad++; ad++;
len--; len--;
} }
@ -444,16 +446,17 @@ grub_udf_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock)
struct grub_udf_long_ad *ad = (struct grub_udf_long_ad *) ptr; struct grub_udf_long_ad *ad = (struct grub_udf_long_ad *) ptr;
len /= sizeof (struct grub_udf_long_ad); len /= sizeof (struct grub_udf_long_ad);
filebytes = fileblock * GRUB_UDF_BLKSZ;
while (len > 0) while (len > 0)
{ {
if (fileblock < U32 (ad->length)) if (filebytes < U32 (ad->length))
return ((U32 (ad->block.block_num) & GRUB_UDF_EXT_MASK) ? 0 : return ((U32 (ad->block.block_num) & GRUB_UDF_EXT_MASK) ? 0 :
(grub_udf_get_block (node->data, (grub_udf_get_block (node->data,
ad->block.part_ref, ad->block.part_ref,
ad->block.block_num) ad->block.block_num)
+ fileblock)); + (filebytes / GRUB_UDF_BLKSZ)));
fileblock -= U32 (ad->length); filebytes -= U32 (ad->length);
ad++; ad++;
len--; len--;
} }