* 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>
|
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.
|
to ensure alignment.
|
||||||
(sun_partition_map_iterate): Make `block' a union 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). */
|
/* Verify checksum (true=ok). */
|
||||||
static int
|
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 *pos;
|
||||||
grub_uint16_t sum = 0;
|
grub_uint16_t sum = 0;
|
||||||
|
|
||||||
for (pos = (grub_uint16_t *) label;
|
for (pos = label;
|
||||||
pos < (grub_uint16_t *) (label + 1);
|
pos < (label + sizeof (struct grub_sun_pc_block) / 2);
|
||||||
pos++)
|
pos++)
|
||||||
sum ^= *pos;
|
sum ^= *pos;
|
||||||
|
|
||||||
|
@ -72,7 +72,11 @@ sun_pc_partition_map_iterate (grub_disk_t disk,
|
||||||
const grub_partition_t partition))
|
const grub_partition_t partition))
|
||||||
{
|
{
|
||||||
grub_partition_t p;
|
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;
|
int partnum;
|
||||||
grub_err_t err;
|
grub_err_t err;
|
||||||
|
|
||||||
|
@ -88,14 +92,14 @@ sun_pc_partition_map_iterate (grub_disk_t disk,
|
||||||
return err;
|
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);
|
grub_free (p);
|
||||||
return grub_error (GRUB_ERR_BAD_PART_TABLE,
|
return grub_error (GRUB_ERR_BAD_PART_TABLE,
|
||||||
"not a sun_pc partition table");
|
"not a sun_pc partition table");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! grub_sun_is_valid (&block))
|
if (! grub_sun_is_valid (block.raw))
|
||||||
{
|
{
|
||||||
grub_free (p);
|
grub_free (p);
|
||||||
return grub_error (GRUB_ERR_BAD_PART_TABLE, "invalid checksum");
|
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;
|
struct grub_sun_pc_partition_descriptor *desc;
|
||||||
|
|
||||||
if (block.partitions[partnum].id == 0
|
if (block.sun.partitions[partnum].id == 0
|
||||||
|| block.partitions[partnum].id == GRUB_PARTMAP_SUN_PC_WHOLE_DISK_ID)
|
|| block.sun.partitions[partnum].id
|
||||||
|
== GRUB_PARTMAP_SUN_PC_WHOLE_DISK_ID)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
desc = &block.partitions[partnum];
|
desc = &block.sun.partitions[partnum];
|
||||||
p->start = grub_le_to_cpu32 (desc->start_sector);
|
p->start = grub_le_to_cpu32 (desc->start_sector);
|
||||||
p->len = grub_le_to_cpu32 (desc->num_sectors);
|
p->len = grub_le_to_cpu32 (desc->num_sectors);
|
||||||
p->number = partnum;
|
p->number = partnum;
|
||||||
|
|
Loading…
Reference in a new issue