From: NeilBrown Date: Fri, 17 Jun 2011 04:48:33 +0000 (+1000) Subject: Don't index past the end of 'best' array in Assemble. X-Git-Tag: mdadm-3.2.2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b787bec6bd0ef74a65cc4fab28496996e4a3c12b;p=thirdparty%2Fmdadm.git Don't index past the end of 'best' array in Assemble. The 'best' array only has 'bestcnt' entries allocated, so 'i' should always be "< bestcnt", not "<= bestcnt". Reported-by: "Lawrence, Joe" Signed-off-by: NeilBrown --- diff --git a/Assemble.c b/Assemble.c index a426afb0..25cfec1d 100644 --- a/Assemble.c +++ b/Assemble.c @@ -1383,7 +1383,7 @@ int Assemble(struct supertype *st, char *mddev, * might allow them to be included, or * they will become spares. */ - for (i = 0; i <= bestcnt; i++) { + for (i = 0; i < bestcnt; i++) { int j = best[i]; if (j >= 0 && !devices[j].uptodate) { if (!disk_action_allows(&devices[j].i, st->ss->name, act_re_add))