summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarel Zak2013-09-02 13:15:09 +0200
committerKarel Zak2013-09-16 16:47:09 +0200
commit879fadf173fdd51ab281cd0f94bdd8ee76602134 (patch)
tree088f03c02edc87f06056f8fabeeef1d8e6786074
parentfdisk: add -L to colorize output (diff)
downloadkernel-qcow2-util-linux-879fadf173fdd51ab281cd0f94bdd8ee76602134.tar.gz
kernel-qcow2-util-linux-879fadf173fdd51ab281cd0f94bdd8ee76602134.tar.xz
kernel-qcow2-util-linux-879fadf173fdd51ab281cd0f94bdd8ee76602134.zip
libfdisk: (gpt) more robust PMBR partition size check
According UEFI specification at least one (does not mean that the first) partition is 0xFF, it makes sense to check the size of the partition rather than check the first partition. Signed-off-by: Karel Zak <kzak@redhat.com>
-rw-r--r--libfdisk/src/gpt.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/libfdisk/src/gpt.c b/libfdisk/src/gpt.c
index eed7a6f06..4f2335024 100644
--- a/libfdisk/src/gpt.c
+++ b/libfdisk/src/gpt.c
@@ -460,7 +460,7 @@ static int gpt_mknew_header(struct fdisk_context *cxt,
*/
static int valid_pmbr(struct fdisk_context *cxt)
{
- int i, ret = 0; /* invalid by default */
+ int i, part = 0, ret = 0; /* invalid by default */
struct gpt_legacy_mbr *pmbr = NULL;
if (!cxt->firstsector)
@@ -484,6 +484,7 @@ static int valid_pmbr(struct fdisk_context *cxt)
* now check if there are other partition types for
* hybrid MBR.
*/
+ part = i;
ret = GPT_MBR_PROTECTIVE;
goto check_hybrid;
}
@@ -504,7 +505,7 @@ check_hybrid:
* Hybrid MBRs do not necessarily comply with this.
*/
if (ret == GPT_MBR_PROTECTIVE) {
- if (le32_to_cpu(pmbr->partition_record[0].size_in_lba) !=
+ if (le32_to_cpu(pmbr->partition_record[part].size_in_lba) !=
min((uint32_t) cxt->total_sectors - 1, 0xFFFFFFFF))
ret = 0;
}