Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 25 Aug 2014 07:15:14 +0000 (UTC)
From:      "Andrey V. Elsukov" <ae@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r270521 - head/sys/boot/common
Message-ID:  <201408250715.s7P7FEoC016648@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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));



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201408250715.s7P7FEoC016648>