summaryrefslogtreecommitdiffstats
path: root/sys/boot/common
diff options
context:
space:
mode:
authorae <ae@FreeBSD.org>2014-08-25 07:15:14 +0000
committerae <ae@FreeBSD.org>2014-08-25 07:15:14 +0000
commita8ed877a78d1c1e6eb7255fd3ab2e393aa408f54 (patch)
treed4a649b1f1ddb55ccd51b5181395ef1caec6d56f /sys/boot/common
parent3359ac4cc80c5bfa33ddd735dd5142a0f85803e7 (diff)
downloadFreeBSD-src-a8ed877a78d1c1e6eb7255fd3ab2e393aa408f54.zip
FreeBSD-src-a8ed877a78d1c1e6eb7255fd3ab2e393aa408f54.tar.gz
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
Diffstat (limited to 'sys/boot/common')
-rw-r--r--sys/boot/common/part.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/sys/boot/common/part.c b/sys/boot/common/part.c
index d0ee938..086809f 100644
--- a/sys/boot/common/part.c
+++ b/sys/boot/common/part.c
@@ -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));
OpenPOWER on IntegriCloud