Date: Thu, 15 Aug 2013 14:33:09 +0000 (UTC) From: "Andrey V. Elsukov" <ae@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-releng@freebsd.org Subject: svn commit: r254367 - releng/9.2/sys/boot/common Message-ID: <201308151433.r7FEX9A9064122@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: ae Date: Thu Aug 15 14:33:09 2013 New Revision: 254367 URL: http://svnweb.freebsd.org/changeset/base/254367 Log: Merge r254366: Make the check for number of entries less strict. Some partitioning tools can create GPT with number of entries less than 128. Approved by: re (marius) Modified: releng/9.2/sys/boot/common/part.c Directory Properties: releng/9.2/sys/ (props changed) releng/9.2/sys/boot/ (props changed) Modified: releng/9.2/sys/boot/common/part.c ============================================================================== --- releng/9.2/sys/boot/common/part.c Thu Aug 15 13:09:58 2013 (r254366) +++ releng/9.2/sys/boot/common/part.c Thu Aug 15 14:33:09 2013 (r254367) @@ -181,7 +181,7 @@ gpt_checkhdr(struct gpt_hdr *hdr, uint64 } hdr->hdr_entries = le32toh(hdr->hdr_entries); hdr->hdr_entsz = le32toh(hdr->hdr_entsz); - if (hdr->hdr_entries < 128 || + if (hdr->hdr_entries == 0 || hdr->hdr_entsz < sizeof(struct gpt_ent) || sectorsize % hdr->hdr_entsz != 0) { DEBUG("invalid entry size or number of entries"); @@ -203,11 +203,14 @@ gpt_checktbl(const struct gpt_hdr *hdr, int i, cnt; cnt = size / hdr->hdr_entsz; - /* Check CRC only when buffer size is enough for table. */ - if (hdr->hdr_entries <= cnt && - crc32(tbl, size) != hdr->hdr_crc_table) { - DEBUG("GPT table's CRC doesn't match"); - return (-1); + if (hdr->hdr_entries <= cnt) { + cnt = hdr->hdr_entries; + /* Check CRC only when buffer size is enough for table. */ + if (hdr->hdr_crc_table != + crc32(tbl, hdr->hdr_entries * hdr->hdr_entsz)) { + DEBUG("GPT table's CRC doesn't match"); + return (-1); + } } ent = (struct gpt_ent *)tbl; for (i = 0; i < cnt; i++, ent++) {
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201308151433.r7FEX9A9064122>