here is a revisted patch.
it takes care, that spare (index == 0xffff) or faulty (index == 0xfffe)
drives don't increment array->nr_devs. otherwise the function
grub_is_array_readable would return wrong results.
sorry, i didn't recognize that in my first attempt.
=== modified file 'grub-core/disk/raid.c'
--- grub-core/disk/raid.c 2010-09-13 21:59:22 +0000
+++ grub-core/disk/raid.c 2010-09-25 22:20:29 +0000
@@ -501,7 +501,8 @@
grub_dprintf ("raid", "array->nr_devs > array->total_devs (%d)?!?",
array->total_devs);
- if (array->device[new_array->index] != NULL)
+ if ((new_array->index < GRUB_RAID_MAX_DEVICES) &&
+ (array->device[new_array->index] != NULL))
/* We found multiple devices with the same number. Again,
this shouldn't happen. */
grub_dprintf ("raid", "Found two disks with the number %d?!?",
@@ -609,9 +610,14 @@
}
/* Add the device to the array. */
- array->device[new_array->index] = disk;
- array->start_sector[new_array->index] = start_sector;
- array->nr_devs++;
+
+ /* ignore spare/faulty disks and more then GRUB_RAID_MAX_DEVICES */
+ if (new_array->index < GRUB_RAID_MAX_DEVICES)
+ {
+ array->device[new_array->index] = disk;
+ array->start_sector[new_array->index] = start_sector;
+ array->nr_devs++;
+ }
return 0;
}