diff options
author | Maarten Vanraes <alien@mageia.org> | 2015-07-25 00:42:43 +0200 |
---|---|---|
committer | Maarten Vanraes <alien@mageia.org> | 2016-05-14 09:25:23 +0200 |
commit | deb2a17be4faac7bd241a0f5045a75f8750f0453 (patch) | |
tree | 9ccbf74a191f12886b92afd7437d50d06bfe4fef | |
parent | b22dff107538fb3bd5bfe3971575bd067a49de3b (diff) | |
download | manatools-deb2a17be4faac7bd241a0f5045a75f8750f0453.tar manatools-deb2a17be4faac7bd241a0f5045a75f8750f0453.tar.gz manatools-deb2a17be4faac7bd241a0f5045a75f8750f0453.tar.bz2 manatools-deb2a17be4faac7bd241a0f5045a75f8750f0453.tar.xz manatools-deb2a17be4faac7bd241a0f5045a75f8750f0453.zip |
safeguard if losetup or parted ever changes
-rw-r--r-- | lib/ManaTools/Shared/disk_backend/PartitionTable.pm | 4 | ||||
-rw-r--r-- | lib/ManaTools/Shared/disk_backend/Plugin/Loop.pm | 1 |
2 files changed, 5 insertions, 0 deletions
diff --git a/lib/ManaTools/Shared/disk_backend/PartitionTable.pm b/lib/ManaTools/Shared/disk_backend/PartitionTable.pm index 9636fae0..fc4900f7 100644 --- a/lib/ManaTools/Shared/disk_backend/PartitionTable.pm +++ b/lib/ManaTools/Shared/disk_backend/PartitionTable.pm @@ -75,7 +75,9 @@ has 'disk' => ( # the disk was not detected return undef; } + chomp($lines[1]); my @fields = split(':', $lines[1]); + (scalar(@fields) == 8) or die('unexpected parted output...'); # set the partition table device file $self->device($fields[0]); # set the partition table sectors @@ -93,7 +95,9 @@ has 'disk' => ( my $parts = $self->partitions(); my $i = 2; while (defined($lines[$i])) { + chomp($lines[$i]); @fields = split(':', $lines[$i]); + (scalar(@fields) == 7) or die('unexpected parted output...'); $parts->{$fields[0]} = { file => $self->device() . $fields[0], begin => $fields[1] =~ s/s$//r, diff --git a/lib/ManaTools/Shared/disk_backend/Plugin/Loop.pm b/lib/ManaTools/Shared/disk_backend/Plugin/Loop.pm index 024c5026..b82ab80a 100644 --- a/lib/ManaTools/Shared/disk_backend/Plugin/Loop.pm +++ b/lib/ManaTools/Shared/disk_backend/Plugin/Loop.pm @@ -130,6 +130,7 @@ override ('probe', sub { for my $line (@lines) { chomp($line); my @fields = split(' ', $line); + (scalar(@fields) == 9) or die('unexpected losetup output...'); my $loopfile = $self->_sanitize_string($fields[1]); my $bdfile = '/sys/block/'. basename($loopfile); my $io = $self->parent->mkio('Disk', {id => basename($loopfile), path => $bdfile}); |