Author: ae
Date: Mon Aug 25 07:15:14 2014
New Revision: 270521
URL: http://svnweb.freebsd.org/changeset/base/270521

Log:
  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

Modified:
  head/sys/boot/common/part.c

Modified: head/sys/boot/common/part.c
==============================================================================
--- head/sys/boot/common/part.c Mon Aug 25 06:14:57 2014        (r270520)
+++ head/sys/boot/common/part.c Mon Aug 25 07:15:14 2014        (r270521)
@@ -212,8 +212,8 @@ gpt_checktbl(const struct gpt_hdr *hdr, 
                        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, voi
                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));
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to