* grub-core/fs/reiserfs.c (grub_reiserfs_iterate_dir): Put a trailing

zero after directory block since last entry may be not 0-terminated if
	it ends on block boundary. Use continue instead of if spanning whole
	loop.
This commit is contained in:
Vladimir 'phcoder' Serbinenko 2012-05-03 16:43:05 +02:00
parent a3a0eace51
commit 1516bfb43a
2 changed files with 173 additions and 165 deletions

View file

@ -1,3 +1,10 @@
2012-05-03 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/fs/reiserfs.c (grub_reiserfs_iterate_dir): Put a trailing
zero after directory block since last entry may be not 0-terminated if
it ends on block boundary. Use continue instead of if spanning whole
loop.
2012-05-03 Vladimir Serbinenko <phcoder@gmail.com> 2012-05-03 Vladimir Serbinenko <phcoder@gmail.com>
Support 4K sectors UDF inline files. Support 4K sectors UDF inline files.

View file

@ -749,7 +749,7 @@ grub_reiserfs_iterate_dir (grub_fshelp_node_t item,
goto fail; goto fail;
} }
block_size = grub_le_to_cpu16 (data->superblock.block_size); block_size = grub_le_to_cpu16 (data->superblock.block_size);
block_header = grub_malloc (block_size); block_header = grub_malloc (block_size + 1);
if (! block_header) if (! block_header)
goto fail; goto fail;
block_number = item->block_number; block_number = item->block_number;
@ -770,6 +770,8 @@ grub_reiserfs_iterate_dir (grub_fshelp_node_t item,
if (grub_errno) if (grub_errno)
goto fail; goto fail;
((char *) block_header)[block_size] = 0;
#if 0 #if 0
if (grub_le_to_cpu16 (block_header->level) != 1) if (grub_le_to_cpu16 (block_header->level) != 1)
{ {
@ -793,14 +795,14 @@ grub_reiserfs_iterate_dir (grub_fshelp_node_t item,
= &directory_headers[entry_number]; = &directory_headers[entry_number];
grub_uint16_t entry_state grub_uint16_t entry_state
= grub_le_to_cpu16 (directory_header->state); = grub_le_to_cpu16 (directory_header->state);
if (entry_state & GRUB_REISERFS_VISIBLE_MASK)
{
grub_fshelp_node_t entry_item; grub_fshelp_node_t entry_item;
struct grub_reiserfs_key entry_key; struct grub_reiserfs_key entry_key;
enum grub_reiserfs_item_type entry_type; enum grub_reiserfs_item_type entry_type;
char *entry_name; char *entry_name;
if (!(entry_state & GRUB_REISERFS_VISIBLE_MASK))
continue;
entry_name = (((char *) directory_headers) entry_name = (((char *) directory_headers)
+ grub_le_to_cpu16 (directory_header->location)); + grub_le_to_cpu16 (directory_header->location));
entry_key.directory_id = directory_header->directory_id; entry_key.directory_id = directory_header->directory_id;
@ -968,7 +970,6 @@ next:
before this one in disk order) stops before before this one in disk order) stops before
the current one. */ the current one. */
} }
}
if (next_offset == 0) if (next_offset == 0)
break; break;