btrbk: tidy map relative subvol argument

pull/409/head
Axel Burri 2021-07-25 13:32:27 +02:00
parent 2824668c0e
commit 16cec0f6d4
1 changed files with 3 additions and 11 deletions

14
btrbk
View File

@ -5601,18 +5601,10 @@ MAIN:
# input validation # input validation
foreach (@subvol_args) { foreach (@subvol_args) {
my ($url_prefix, $path) = check_url($_); my ($url_prefix, $path) = check_url($_);
if(!defined($path) && $subvol_args_allow_relative) { if(!defined($path) && $subvol_args_allow_relative && ($url_prefix eq "")) {
# map relative path to absolute # map relative path to absolute
$url_prefix = ""; if((-d $_) && ($_ =~ /^(.*)$/)) { # untaint ANY argument!
if(-d $_) { $path = check_file(`readlink -f -q '$1'`, { absolute => 1 })
$path = $1 if($_ =~ /^(.*)$/); # untaint ANY argument, real check below
$path = `readlink -f -q '$path'` if(defined($path));
$path = check_file($path, { absolute => 1 });
}
unless(defined($path)) {
ERROR "Bad argument: not a valid path: $_";
HELP_MESSAGE(0);
exit 2;
} }
} }
unless(defined($path)) { unless(defined($path)) {