]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libfdisk: (gpt) check header size before verify CRC
authorKarel Zak <kzak@redhat.com>
Mon, 23 Mar 2015 11:03:30 +0000 (12:03 +0100)
committerKarel Zak <kzak@redhat.com>
Wed, 29 Apr 2015 10:23:19 +0000 (12:23 +0200)
Addresses: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=780834
Signed-off-by: Karel Zak <kzak@redhat.com>
libfdisk/src/gpt.c

index 61b0a32e1ea17d4fa3096f38e1c6435a04397244..9ceb01a6e921f40920be4c6fda683711188384ad 100644 (file)
@@ -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;