diff options
author | Karel Zak | 2015-03-23 12:03:30 +0100 |
---|---|---|
committer | Karel Zak | 2015-03-23 12:03:30 +0100 |
commit | 9c6f3de60f9858e404a825824026bff4c42203fc (patch) | |
tree | 7a2277555070c695066272845133d02b387b6a21 /libfdisk/src/gpt.c | |
parent | dmesg: use GMT in tests, add DMESG_TEST_BOOTIME (diff) | |
download | kernel-qcow2-util-linux-9c6f3de60f9858e404a825824026bff4c42203fc.tar.gz kernel-qcow2-util-linux-9c6f3de60f9858e404a825824026bff4c42203fc.tar.xz kernel-qcow2-util-linux-9c6f3de60f9858e404a825824026bff4c42203fc.zip |
libfdisk: (gpt) check header size before verify CRC
Addresses: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=780834
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libfdisk/src/gpt.c')
-rw-r--r-- | libfdisk/src/gpt.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/libfdisk/src/gpt.c b/libfdisk/src/gpt.c index 61b0a32e1..9ceb01a6e 100644 --- a/libfdisk/src/gpt.c +++ b/libfdisk/src/gpt.c @@ -954,6 +954,11 @@ static struct gpt_header *gpt_read_header(struct fdisk_context *cxt, if (!gpt_check_signature(header)) goto invalid; + /* make sure header size is between 92 and sector size bytes */ + hsz = le32_to_cpu(header->size); + if (hsz < GPT_HEADER_MINSZ || hsz > cxt->sector_size) + goto invalid; + if (!gpt_check_header_crc(header, NULL)) goto invalid; @@ -972,10 +977,6 @@ static struct gpt_header *gpt_read_header(struct fdisk_context *cxt, if (le64_to_cpu(header->my_lba) != lba) goto invalid; - /* make sure header size is between 92 and sector size bytes */ - hsz = le32_to_cpu(header->size); - if (hsz < GPT_HEADER_MINSZ || hsz > cxt->sector_size) - goto invalid; if (_ents) *_ents = ents; |