summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2023-02-02 00:20:50 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2023-02-02 00:20:50 +0000
commit4d216431b873ac80e4afb0c14c622feca2bfaf57 (patch)
tree794360d13804df72c824148012cedd6e48a690cb
parentace6f02e36625f0c34d7430e6a3db192514c2bc7 (diff)
Restore incorrectly deleted test for default partitions intruding
into the OpenBSD area that is about to be auto-allocated. Fixes resizing partitions on an auto-allocated disk that had a boot partition. Found by dv@
-rw-r--r--sbin/disklabel/editor.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/sbin/disklabel/editor.c b/sbin/disklabel/editor.c
index 9d4c14d4c6c..1c32ab76448 100644
--- a/sbin/disklabel/editor.c
+++ b/sbin/disklabel/editor.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: editor.c,v 1.399 2023/01/28 13:14:01 krw Exp $ */
+/* $OpenBSD: editor.c,v 1.400 2023/02/02 00:20:49 krw Exp $ */
/*
* Copyright (c) 1997-2000 Todd C. Miller <millert@openbsd.org>
@@ -536,6 +536,7 @@ editor_allocspace(struct disklabel *lp_org)
const struct diskchunk *chunk;
u_int64_t chunkstart, chunksize, start, stop;
u_int64_t secs, xtrasecs;
+ u_int64_t pstart, pend, psz;
char **partmp;
int i, lastalloc, index, partno, freeparts;
extern int64_t physmem;
@@ -549,10 +550,18 @@ editor_allocspace(struct disklabel *lp_org)
if (i == RAW_PART)
continue;
pp = &lp_org->d_partitions[i];
- if (DL_GETPSIZE(pp) == 0 || pp->p_fstype == FS_UNUSED)
+ psz = DL_GETPSIZE(pp);
+ if (DL_GETPSIZE(pp) == 0 || pp->p_fstype == FS_UNUSED) {
freeparts++;
- else
- resizeok = 0;
+ continue;
+ }
+ pstart = DL_GETPOFFSET(pp);
+ pend = pstart + psz;
+ if (i != RAW_PART && psz != 0 &&
+ ((pstart >= starting_sector && pstart < ending_sector) ||
+ (pend > starting_sector && pend <= ending_sector))) {
+ resizeok = 0; /* Non-default partition found! */
+ }
}
alloc = NULL;