summaryrefslogtreecommitdiff
path: root/sbin/disklabel
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2008-01-07 19:24:34 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2008-01-07 19:24:34 +0000
commite6ea224009fb449e777ebfa64132b10589093981 (patch)
treed61eadc8e51500be49280b664635e949b3d881fb /sbin/disklabel
parent13f23c54bbd3d677a1f799c888ebedc1ac476060 (diff)
When increasing d_npartitions as a result of (a)dd'ing a partition in
-E, zero intervening partitions as well as the specified partition so no partitions are inadvertantly activated.
Diffstat (limited to 'sbin/disklabel')
-rw-r--r--sbin/disklabel/editor.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/sbin/disklabel/editor.c b/sbin/disklabel/editor.c
index f38f18bac5a..7488289594f 100644
--- a/sbin/disklabel/editor.c
+++ b/sbin/disklabel/editor.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: editor.c,v 1.144 2008/01/07 16:51:35 krw Exp $ */
+/* $OpenBSD: editor.c,v 1.145 2008/01/07 19:24:33 krw Exp $ */
/*
* Copyright (c) 1997-2000 Todd C. Miller <Todd.Miller@courtesan.com>
@@ -17,7 +17,7 @@
*/
#ifndef lint
-static char rcsid[] = "$OpenBSD: editor.c,v 1.144 2008/01/07 16:51:35 krw Exp $";
+static char rcsid[] = "$OpenBSD: editor.c,v 1.145 2008/01/07 19:24:33 krw Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -489,12 +489,13 @@ editor_add(struct disklabel *lp, char **mp, u_int64_t *freep, char *p)
return;
}
- /* Increase d_npartitions if necessary */
- if (partno >= lp->d_npartitions)
- lp->d_npartitions = partno + 1;
+ /*
+ * Increase d_npartitions if necessary. Ensure all new partitions are
+ * zero'ed to avoid inadvertant overlaps.
+ */
+ for(; lp->d_npartitions <= partno; lp->d_npartitions++)
+ memset(&lp->d_partitions[lp->d_npartitions], 0, sizeof(*pp));
- /* Set defaults */
- memset(pp, 0, sizeof(*pp));
chunks = free_chunks(lp);
/*