libfdisk: verify partno from template
* verify partno from template when create a new partition * remove unnecessary l->ext_offset check Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
parent
9dc5644717
commit
e1cfb30466
|
@ -1548,7 +1548,7 @@ static int dos_add_partition(struct fdisk_context *cxt,
|
|||
}
|
||||
|
||||
/* pa specifies start, but outside extended partition */
|
||||
} else if (pa && fdisk_partition_has_start(pa) && l->ext_offset) {
|
||||
} else if (pa && fdisk_partition_has_start(pa)) {
|
||||
DBG(LABEL, ul_debug("DOS: pa template %p: add primary", pa));
|
||||
rc = get_partition_unused_primary(cxt, pa, &res);
|
||||
if (rc == 0) {
|
||||
|
|
|
@ -733,7 +733,8 @@ int fdisk_partition_next_partno(
|
|||
|
||||
DBG(PART, ul_debugobj(pa, "next partno (specified=%zu)", pa->partno));
|
||||
|
||||
if (pa->partno >= cxt->label->nparts_max)
|
||||
if (pa->partno >= cxt->label->nparts_max ||
|
||||
fdisk_is_partition_used(cxt, pa->partno))
|
||||
return -ERANGE;
|
||||
*n = pa->partno;
|
||||
} else
|
||||
|
|
Loading…
Reference in New Issue