diff options
author | Andrey V. Elsukov <ae@FreeBSD.org> | 2013-08-15 14:33:09 +0000 |
---|---|---|
committer | Andrey V. Elsukov <ae@FreeBSD.org> | 2013-08-15 14:33:09 +0000 |
commit | fb4e36f79bb09b9e8c91e819271b05ac32f03c7a (patch) | |
tree | 38d0623054dda888d15cec66075cb11b0ffb5f3a | |
parent | 63e0f0f0c230505454bb02922661c407e1b437aa (diff) | |
download | src-fb4e36f79bb09b9e8c91e819271b05ac32f03c7a.tar.gz src-fb4e36f79bb09b9e8c91e819271b05ac32f03c7a.zip |
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)
Notes
Notes:
svn path=/releng/9.2/; revision=254367
-rw-r--r-- | sys/boot/common/part.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/sys/boot/common/part.c b/sys/boot/common/part.c index 2b3a16fbd851..d37eee52ca77 100644 --- a/sys/boot/common/part.c +++ b/sys/boot/common/part.c @@ -181,7 +181,7 @@ gpt_checkhdr(struct gpt_hdr *hdr, uint64_t lba_self, uint64_t lba_last, } 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, u_char *tbl, size_t size, 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++) { |