From owner-svn-src-stable-9@FreeBSD.ORG Thu Aug 15 13:09:59 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 8552058E; Thu, 15 Aug 2013 13:09:59 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 725942EEE; Thu, 15 Aug 2013 13:09:59 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r7FD9x7d031491; Thu, 15 Aug 2013 13:09:59 GMT (envelope-from ae@svn.freebsd.org) Received: (from ae@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r7FD9x13031489; Thu, 15 Aug 2013 13:09:59 GMT (envelope-from ae@svn.freebsd.org) Message-Id: <201308151309.r7FD9x13031489@svn.freebsd.org> From: "Andrey V. Elsukov" Date: Thu, 15 Aug 2013 13:09:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r254366 - stable/9/sys/boot/common X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 15 Aug 2013 13:09:59 -0000 Author: ae Date: Thu Aug 15 13:09:58 2013 New Revision: 254366 URL: http://svnweb.freebsd.org/changeset/base/254366 Log: MFC r254092: Make the check for number of entries less strict. Some partitioning tools can create GPT with number of entries less than 128. Modified: stable/9/sys/boot/common/part.c Directory Properties: stable/9/sys/ (props changed) stable/9/sys/boot/ (props changed) Modified: stable/9/sys/boot/common/part.c ============================================================================== --- stable/9/sys/boot/common/part.c Thu Aug 15 12:55:57 2013 (r254365) +++ stable/9/sys/boot/common/part.c Thu Aug 15 13:09:58 2013 (r254366) @@ -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++) {