mirror of https://github.com/digint/btrbk
btrbk: remove double-slash from file arguments
Sanitize file (or subvolume path) arguments in safe_cmd, effectively removing leading double slash. Files originating from "volume /" can be assembled as "//some/subvol", which is useful internally but undesired as command arguments, as ancient systems might interpret leading double slash "//" in a special way. Posix states: > A pathname that begins with two successive slashes may be > interpreted in an implementation-defined manner, although more than > two leading slashes shall be treated as a single slash.pull/542/head
parent
b9c5e3fc29
commit
799d235218
8
btrbk
8
btrbk
|
@ -806,10 +806,12 @@ sub _safe_cmd($;$)
|
|||
$_ = $_->{unsafe};
|
||||
die "cannot quote leading dash for command: $_" if(/^-/);
|
||||
# NOTE: all files must be absolute
|
||||
if($offending) {
|
||||
push @$offending, $_ unless(defined(check_file($_, { absolute => 1 })));
|
||||
my $file = check_file($_, { absolute => 1 }, sanitize => 1 );
|
||||
unless(defined($file)) {
|
||||
die "uncaught unsafe file: $_" unless($offending);
|
||||
push @$offending, $_;
|
||||
}
|
||||
$_ = $prefix . quoteshell($_) . $postfix;
|
||||
$_ = $prefix . quoteshell($file // $_) . $postfix;
|
||||
}
|
||||
$_
|
||||
} @$aref;
|
||||
|
|
Loading…
Reference in New Issue