An uneven number of disks otherwise causes a panic due to an
out-of-bounds array access in the loop below.
Reported-by: Fiona Ebner <f.ebner@proxmox.com>
Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
}
ZfsRaidLevel::Raid10 => {
check_raid_min_disks(disks, 4)?;
}
ZfsRaidLevel::Raid10 => {
check_raid_min_disks(disks, 4)?;
+
+ if disks.len() % 2 != 0 {
+ return Err(format!(
+ "Needs an even number of disks, currently selected: {}",
+ disks.len(),
+ ));
+ }
+
// Pairs need to have the same size
for i in (0..disks.len()).step_by(2) {
check_mirror_size(&disks[i], &disks[i + 1])?;
// Pairs need to have the same size
for i in (0..disks.len()).step_by(2) {
check_mirror_size(&disks[i], &disks[i + 1])?;