* grub-core/partmap/sunpc.c (grub_sun_is_valid): Make argument
uint16_t * to ensure alignment. (sun_pc_partition_map_iterate): Make `block' a union to ensure alignment.
This commit is contained in:
parent
a23f2cc4d6
commit
93018f6400
2 changed files with 22 additions and 10 deletions
|
@ -1,6 +1,13 @@
|
|||
2011-12-13 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* grub-core/partmap/sun.c (grub_sun_is_valid): make argument uint16_t *
|
||||
* grub-core/partmap/sunpc.c (grub_sun_is_valid): Make argument
|
||||
uint16_t * to ensure alignment.
|
||||
(sun_pc_partition_map_iterate): Make `block' a union to ensure
|
||||
alignment.
|
||||
|
||||
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.
|
||||
|
||||
|
|
|
@ -53,13 +53,13 @@ static struct grub_partition_map grub_sun_pc_partition_map;
|
|||
|
||||
/* Verify checksum (true=ok). */
|
||||
static int
|
||||
grub_sun_is_valid (struct grub_sun_pc_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_pc_block) / 2);
|
||||
pos++)
|
||||
sum ^= *pos;
|
||||
|
||||
|
@ -72,7 +72,11 @@ sun_pc_partition_map_iterate (grub_disk_t disk,
|
|||
const grub_partition_t partition))
|
||||
{
|
||||
grub_partition_t p;
|
||||
struct grub_sun_pc_block block;
|
||||
union
|
||||
{
|
||||
struct grub_sun_pc_block sun;
|
||||
grub_uint16_t raw[0];
|
||||
} block;
|
||||
int partnum;
|
||||
grub_err_t err;
|
||||
|
||||
|
@ -88,14 +92,14 @@ sun_pc_partition_map_iterate (grub_disk_t disk,
|
|||
return err;
|
||||
}
|
||||
|
||||
if (GRUB_PARTMAP_SUN_PC_MAGIC != grub_le_to_cpu16 (block.magic))
|
||||
if (GRUB_PARTMAP_SUN_PC_MAGIC != grub_le_to_cpu16 (block.sun.magic))
|
||||
{
|
||||
grub_free (p);
|
||||
return grub_error (GRUB_ERR_BAD_PART_TABLE,
|
||||
"not a sun_pc partition table");
|
||||
}
|
||||
|
||||
if (! grub_sun_is_valid (&block))
|
||||
if (! grub_sun_is_valid (block.raw))
|
||||
{
|
||||
grub_free (p);
|
||||
return grub_error (GRUB_ERR_BAD_PART_TABLE, "invalid checksum");
|
||||
|
@ -107,11 +111,12 @@ sun_pc_partition_map_iterate (grub_disk_t disk,
|
|||
{
|
||||
struct grub_sun_pc_partition_descriptor *desc;
|
||||
|
||||
if (block.partitions[partnum].id == 0
|
||||
|| block.partitions[partnum].id == GRUB_PARTMAP_SUN_PC_WHOLE_DISK_ID)
|
||||
if (block.sun.partitions[partnum].id == 0
|
||||
|| block.sun.partitions[partnum].id
|
||||
== GRUB_PARTMAP_SUN_PC_WHOLE_DISK_ID)
|
||||
continue;
|
||||
|
||||
desc = &block.partitions[partnum];
|
||||
desc = &block.sun.partitions[partnum];
|
||||
p->start = grub_le_to_cpu32 (desc->start_sector);
|
||||
p->len = grub_le_to_cpu32 (desc->num_sectors);
|
||||
p->number = partnum;
|
||||
|
|
Loading…
Reference in a new issue