* grub-core/fs/romfs.c (grub_romfs_mount): Fix a bug with labels going

over the sector.
This commit is contained in:
Vladimir 'phcoder' Serbinenko 2012-01-31 22:25:07 +01:00
parent b3fe42adb7
commit 7397c69bb8
2 changed files with 22 additions and 14 deletions

View file

@ -1,3 +1,8 @@
2012-01-31 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/fs/romfs.c (grub_romfs_mount): Fix a bug with labels going
over the sector.
2012-01-31 Vladimir Serbinenko <phcoder@gmail.com> 2012-01-31 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/fs/zfs/zfs.c (get_filesystem_dnode): Support space in * grub-core/fs/zfs/zfs.c (get_filesystem_dnode): Support space in

View file

@ -115,23 +115,26 @@ grub_romfs_mount (grub_device_t dev)
&& ptr - sb.d < (grub_ssize_t) grub_be_to_cpu32 (sb.sb.total_size); ptr++) && ptr - sb.d < (grub_ssize_t) grub_be_to_cpu32 (sb.sb.total_size); ptr++)
if (!*ptr) if (!*ptr)
break; break;
if ((void *) ptr == &sb + 1) while ((void *) ptr == &sb + 1)
for (sec++; ; sec++) {
{ sec++;
err = grub_disk_read (dev->disk, sec, 0, sizeof (sb), &sb); err = grub_disk_read (dev->disk, sec, 0, sizeof (sb), &sb);
if (err == GRUB_ERR_OUT_OF_RANGE) if (err == GRUB_ERR_OUT_OF_RANGE)
err = grub_errno = GRUB_ERR_BAD_FS; err = grub_errno = GRUB_ERR_BAD_FS;
if (err) if (err)
return NULL; return NULL;
for (ptr = sb.d; (void *) ptr < (void *) (&sb + 1) for (ptr = sb.d; (void *) ptr < (void *) (&sb + 1)
&& ptr - sb.d < (grub_ssize_t) grub_be_to_cpu32 (sb.sb.total_size); ptr++) && (ptr - sb.d + (sec << GRUB_DISK_SECTOR_BITS)
if (!*ptr) < grub_be_to_cpu32 (sb.sb.total_size));
break; ptr++)
} if (!*ptr)
break;
}
data = grub_malloc (sizeof (*data)); data = grub_malloc (sizeof (*data));
if (!data) if (!data)
return NULL; return NULL;
data->first_file = ALIGN_UP (ptr - sb.d, GRUB_ROMFS_ALIGN) + sec * 512; data->first_file = ALIGN_UP (ptr + 1 - sb.d, GRUB_ROMFS_ALIGN)
+ (sec << GRUB_DISK_SECTOR_BITS);
data->disk = dev->disk; data->disk = dev->disk;
return data; return data;
} }