untaint df return values

since we sometimes use their length in a format string for printf

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Co-authored-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Dominik Csapak 2018-04-24 10:15:14 +02:00 committed by Thomas Lamprecht
parent 1e83e254ed
commit fd58bb2bff

View File

@ -986,10 +986,14 @@ sub df {
my $res = eval { run_fork_with_timeout($timeout, $df) } // {}; my $res = eval { run_fork_with_timeout($timeout, $df) } // {};
warn $@ if $@; warn $@ if $@;
# untaint the values
my ($blocks, $used, $bavail) = map { defined($_) ? (/^(\d+)$/) : 0 }
$res->@{qw(blocks used bavail)};
return { return {
total => $res->{blocks} // 0, total => $blocks,
used => $res->{used} // 0, used => $used,
avail => $res->{bavail} // 0, avail => $bavail,
}; };
} }