]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Don't index past the end of 'best' array in Assemble.
authorNeilBrown <neilb@suse.de>
Fri, 17 Jun 2011 04:48:33 +0000 (14:48 +1000)
committerNeilBrown <neilb@suse.de>
Fri, 17 Jun 2011 04:48:33 +0000 (14:48 +1000)
The 'best' array only has 'bestcnt' entries allocated, so 'i' should
always be "< bestcnt", not "<= bestcnt".

Reported-by: "Lawrence, Joe" <Joe.Lawrence@stratus.com>
Signed-off-by: NeilBrown <neilb@suse.de>
Assemble.c

index a426afb08cad42c285029166b8b0f27f797efb09..25cfec1d2800e3915e304a68e9d3b8a01295cf47 100644 (file)
@@ -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))