From e6ea224009fb449e777ebfa64132b10589093981 Mon Sep 17 00:00:00 2001 From: Kenneth R Westerback Date: Mon, 7 Jan 2008 19:24:34 +0000 Subject: 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. --- sbin/disklabel/editor.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'sbin/disklabel') 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 @@ -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 @@ -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); /* -- cgit v1.2.3