mirror of
https://git.proxmox.com/git/pve-common
synced 2025-08-14 11:06:15 +00:00
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:
parent
1e83e254ed
commit
fd58bb2bff
@ -986,10 +986,14 @@ sub df {
|
||||
my $res = eval { run_fork_with_timeout($timeout, $df) } // {};
|
||||
warn $@ if $@;
|
||||
|
||||
# untaint the values
|
||||
my ($blocks, $used, $bavail) = map { defined($_) ? (/^(\d+)$/) : 0 }
|
||||
$res->@{qw(blocks used bavail)};
|
||||
|
||||
return {
|
||||
total => $res->{blocks} // 0,
|
||||
used => $res->{used} // 0,
|
||||
avail => $res->{bavail} // 0,
|
||||
total => $blocks,
|
||||
used => $used,
|
||||
avail => $bavail,
|
||||
};
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user