Since the size of GPT entry may differ from the sizeof(struct gpt_ent),

use the size from GPT header to iterate entries.

Suggested by:	marcel@
MFC after:	1 week
This commit is contained in:
Andrey V. Elsukov 2014-08-25 07:15:14 +00:00
parent 50318baaa9
commit 94be23b653

View file

@ -212,8 +212,8 @@ gpt_checktbl(const struct gpt_hdr *hdr, u_char *tbl, size_t size,
return (-1);
}
}
ent = (struct gpt_ent *)tbl;
for (i = 0; i < cnt; i++, ent++) {
for (i = 0; i < cnt; i++) {
ent = (struct gpt_ent *)(tbl + i * hdr->hdr_entsz);
uuid_letoh(&ent->ent_type);
if (uuid_equal(&ent->ent_type, &gpt_uuid_unused, NULL))
continue;
@ -303,10 +303,10 @@ ptable_gptread(struct ptable *table, void *dev, diskread_t dread)
table->type = PTABLE_NONE;
goto out;
}
ent = (struct gpt_ent *)tbl;
size = MIN(hdr.hdr_entries * hdr.hdr_entsz,
MAXTBLSZ * table->sectorsize);
for (i = 0; i < size / hdr.hdr_entsz; i++, ent++) {
for (i = 0; i < size / hdr.hdr_entsz; i++) {
ent = (struct gpt_ent *)(tbl + i * hdr.hdr_entsz);
if (uuid_equal(&ent->ent_type, &gpt_uuid_unused, NULL))
continue;
entry = malloc(sizeof(*entry));