* 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>
|
2011-12-13 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
* grub-core/fs/ntfs.c (u16at): Make into inline function.
|
* 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). */
|
/* Verify checksum (true=ok). */
|
||||||
static int
|
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 *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_block) / 2);
|
||||||
pos++)
|
pos++)
|
||||||
sum ^= *pos;
|
sum ^= *pos;
|
||||||
|
|
||||||
|
@ -90,7 +90,11 @@ sun_partition_map_iterate (grub_disk_t disk,
|
||||||
const grub_partition_t partition))
|
const grub_partition_t partition))
|
||||||
{
|
{
|
||||||
struct grub_partition p;
|
struct grub_partition p;
|
||||||
struct grub_sun_block block;
|
union
|
||||||
|
{
|
||||||
|
struct grub_sun_block sun;
|
||||||
|
grub_uint16_t raw[0];
|
||||||
|
} block;
|
||||||
int partnum;
|
int partnum;
|
||||||
grub_err_t err;
|
grub_err_t err;
|
||||||
|
|
||||||
|
@ -100,10 +104,10 @@ sun_partition_map_iterate (grub_disk_t disk,
|
||||||
if (err)
|
if (err)
|
||||||
return 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");
|
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");
|
return grub_error (GRUB_ERR_BAD_PART_TABLE, "invalid checksum");
|
||||||
|
|
||||||
/* Maybe another error value would be better, because partition
|
/* 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;
|
struct grub_sun_partition_descriptor *desc;
|
||||||
|
|
||||||
if (block.infos[partnum].id == 0
|
if (block.sun.infos[partnum].id == 0
|
||||||
|| block.infos[partnum].id == GRUB_PARTMAP_SUN_WHOLE_DISK_ID)
|
|| block.sun.infos[partnum].id == GRUB_PARTMAP_SUN_WHOLE_DISK_ID)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
desc = &block.partitions[partnum];
|
desc = &block.sun.partitions[partnum];
|
||||||
p.start = ((grub_uint64_t) grub_be_to_cpu32 (desc->start_cylinder)
|
p.start = ((grub_uint64_t) grub_be_to_cpu32 (desc->start_cylinder)
|
||||||
* grub_be_to_cpu16 (block.ntrks)
|
* grub_be_to_cpu16 (block.sun.ntrks)
|
||||||
* grub_be_to_cpu16 (block.nsect));
|
* grub_be_to_cpu16 (block.sun.nsect));
|
||||||
p.len = grub_be_to_cpu32 (desc->num_sectors);
|
p.len = grub_be_to_cpu32 (desc->num_sectors);
|
||||||
p.number = p.index = partnum;
|
p.number = p.index = partnum;
|
||||||
if (p.len)
|
if (p.len)
|
||||||
|
|
Loading…
Reference in a new issue