reiserfs: Fix handling of first entry in the directory.

Fixes garbage being added to "." filename.
This commit is contained in:
Vladimir Serbinenko 2015-07-24 01:13:27 +02:00
parent 81ca24a59c
commit 02a249005f

View file

@ -783,12 +783,30 @@ grub_reiserfs_iterate_dir (grub_fshelp_node_t item,
struct grub_reiserfs_key entry_key;
enum grub_fshelp_filetype entry_type;
char *entry_name;
char *entry_name_end = 0;
char c;
if (!(entry_state & GRUB_REISERFS_VISIBLE_MASK))
continue;
entry_name = (((char *) directory_headers)
+ grub_le_to_cpu16 (directory_header->location));
if (entry_number == 0)
{
entry_name_end = (char *) block_header
+ grub_le_to_cpu16 (item_headers[block_position].item_location)
+ grub_le_to_cpu16 (item_headers[block_position].item_size);
}
else
{
entry_name_end = (((char *) directory_headers)
+ grub_le_to_cpu16 (directory_headers[entry_number - 1].location));
}
if (entry_name_end < entry_name || entry_name_end > (char *) block_header + block_size)
{
entry_name_end = (char *) block_header + block_size;
}
entry_key.directory_id = directory_header->directory_id;
entry_key.object_id = directory_header->object_id;
entry_key.u.v2.offset_type = 0;
@ -935,7 +953,7 @@ grub_reiserfs_iterate_dir (grub_fshelp_node_t item,
else
{
/* Pseudo file ".." never has stat block. */
if (grub_strcmp (entry_name, ".."))
if (entry_name_end == entry_name + 2 && grub_memcmp (entry_name, "..", 2) != 0)
grub_dprintf ("reiserfs",
"Warning : %s has no stat block !\n",
entry_name);
@ -943,18 +961,21 @@ grub_reiserfs_iterate_dir (grub_fshelp_node_t item,
goto next;
}
}
c = *entry_name_end;
*entry_name_end = 0;
if (hook (entry_name, entry_type, entry_item, hook_data))
{
*entry_name_end = c;
grub_dprintf ("reiserfs", "Found : %s, type=%d\n",
entry_name, entry_type);
ret = 1;
goto found;
}
*entry_name_end = c;
next:
*entry_name = 0; /* Make sure next entry name (which is just
before this one in disk order) stops before
the current one. */
;
}
if (next_offset == 0)