]> git.proxmox.com Git - pve-installer.git/commitdiff
common: enforce even number of disks for ZFS RAID-10
authorChristoph Heiss <c.heiss@proxmox.com>
Tue, 21 Nov 2023 10:45:51 +0000 (11:45 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 21 Nov 2023 12:11:50 +0000 (13:11 +0100)
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>
proxmox-installer-common/src/disk_checks.rs

index bcf2e2155ac35dba244165257f106f1da5d17789..7cbdf1933846125e26c838def3665a234f1d6846 100644 (file)
@@ -81,6 +81,14 @@ pub fn check_zfs_raid_config(level: ZfsRaidLevel, disks: &[Disk]) -> Result<(),
         }
         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])?;