summaryrefslogtreecommitdiffstats
path: root/libfdisk/src/gpt.c
diff options
context:
space:
mode:
authorKarel Zak2015-09-17 11:44:08 +0200
committerKarel Zak2015-09-17 11:44:08 +0200
commitc949fa98d8737cd0a14ea071d141d2c6a0b35faa (patch)
tree2834c34c468b3b2267b46620253843ab1170370b /libfdisk/src/gpt.c
parentipcs: fix ipc_sem_get_limits() (diff)
downloadkernel-qcow2-util-linux-c949fa98d8737cd0a14ea071d141d2c6a0b35faa.tar.gz
kernel-qcow2-util-linux-c949fa98d8737cd0a14ea071d141d2c6a0b35faa.tar.xz
kernel-qcow2-util-linux-c949fa98d8737cd0a14ea071d141d2c6a0b35faa.zip
libfdisk: (gpt) control ranges in set_partition
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libfdisk/src/gpt.c')
-rw-r--r--libfdisk/src/gpt.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/libfdisk/src/gpt.c b/libfdisk/src/gpt.c
index 98da5aac9..81741679a 100644
--- a/libfdisk/src/gpt.c
+++ b/libfdisk/src/gpt.c
@@ -1751,11 +1751,20 @@ static int gpt_set_partition(struct fdisk_context *cxt, size_t n,
end = xstart + xsize - 1ULL;
}
- if (!FDISK_IS_UNDEF(start))
+ if (!FDISK_IS_UNDEF(start)) {
+ if (start < le64_to_cpu(gpt->pheader->first_usable_lba)) {
+ fdisk_warnx(cxt, _("The begin of the partition overflows FirstUsableLBA."));
+ return -EINVAL;
+ }
e->lba_start = cpu_to_le64(start);
- if (!FDISK_IS_UNDEF(end))
+ }
+ if (!FDISK_IS_UNDEF(end)) {
+ if (end > le64_to_cpu(gpt->pheader->last_usable_lba)) {
+ fdisk_warnx(cxt, _("The end of the partition overflows LastUsableLBA."));
+ return -EINVAL;
+ }
e->lba_end = cpu_to_le64(end);
-
+ }
gpt_recompute_crc(gpt->pheader, gpt->ents);
gpt_recompute_crc(gpt->bheader, gpt->ents);