* grub-core/partmap/sun.c (grub_sun_is_valid): make argument uint16_t *
to ensure alignment. (sun_partition_map_iterate): Make `block' a union to ensure alignment.
This commit is contained in:
parent
58acccd645
commit
a23f2cc4d6
2 changed files with 21 additions and 11 deletions
|
@ -1,3 +1,9 @@
|
|||
2011-12-13 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* grub-core/partmap/sun.c (grub_sun_is_valid): make argument uint16_t *
|
||||
to ensure alignment.
|
||||
(sun_partition_map_iterate): Make `block' a union to ensure alignment.
|
||||
|
||||
2011-12-13 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* grub-core/fs/ntfs.c (u16at): Make into inline function.
|
||||
|
|
|
@ -71,13 +71,13 @@ static struct grub_partition_map grub_sun_partition_map;
|
|||
|
||||
/* Verify checksum (true=ok). */
|
||||
static int
|
||||
grub_sun_is_valid (struct grub_sun_block *label)
|
||||
grub_sun_is_valid (grub_uint16_t *label)
|
||||
{
|
||||
grub_uint16_t *pos;
|
||||
grub_uint16_t sum = 0;
|
||||
|
||||
for (pos = (grub_uint16_t *) label;
|
||||
pos < (grub_uint16_t *) (label + 1);
|
||||
for (pos = label;
|
||||
pos < (label + sizeof (struct grub_sun_block) / 2);
|
||||
pos++)
|
||||
sum ^= *pos;
|
||||
|
||||
|
@ -90,7 +90,11 @@ sun_partition_map_iterate (grub_disk_t disk,
|
|||
const grub_partition_t partition))
|
||||
{
|
||||
struct grub_partition p;
|
||||
struct grub_sun_block block;
|
||||
union
|
||||
{
|
||||
struct grub_sun_block sun;
|
||||
grub_uint16_t raw[0];
|
||||
} block;
|
||||
int partnum;
|
||||
grub_err_t err;
|
||||
|
||||
|
@ -100,10 +104,10 @@ sun_partition_map_iterate (grub_disk_t disk,
|
|||
if (err)
|
||||
return err;
|
||||
|
||||
if (GRUB_PARTMAP_SUN_MAGIC != grub_be_to_cpu16 (block.magic))
|
||||
if (GRUB_PARTMAP_SUN_MAGIC != grub_be_to_cpu16 (block.sun.magic))
|
||||
return grub_error (GRUB_ERR_BAD_PART_TABLE, "not a sun partition table");
|
||||
|
||||
if (! grub_sun_is_valid (&block))
|
||||
if (! grub_sun_is_valid (block.raw))
|
||||
return grub_error (GRUB_ERR_BAD_PART_TABLE, "invalid checksum");
|
||||
|
||||
/* Maybe another error value would be better, because partition
|
||||
|
@ -112,14 +116,14 @@ sun_partition_map_iterate (grub_disk_t disk,
|
|||
{
|
||||
struct grub_sun_partition_descriptor *desc;
|
||||
|
||||
if (block.infos[partnum].id == 0
|
||||
|| block.infos[partnum].id == GRUB_PARTMAP_SUN_WHOLE_DISK_ID)
|
||||
if (block.sun.infos[partnum].id == 0
|
||||
|| block.sun.infos[partnum].id == GRUB_PARTMAP_SUN_WHOLE_DISK_ID)
|
||||
continue;
|
||||
|
||||
desc = &block.partitions[partnum];
|
||||
desc = &block.sun.partitions[partnum];
|
||||
p.start = ((grub_uint64_t) grub_be_to_cpu32 (desc->start_cylinder)
|
||||
* grub_be_to_cpu16 (block.ntrks)
|
||||
* grub_be_to_cpu16 (block.nsect));
|
||||
* grub_be_to_cpu16 (block.sun.ntrks)
|
||||
* grub_be_to_cpu16 (block.sun.nsect));
|
||||
p.len = grub_be_to_cpu32 (desc->num_sectors);
|
||||
p.number = p.index = partnum;
|
||||
if (p.len)
|
||||
|
|
Loading…
Reference in a new issue