diff --git a/btrbk b/btrbk index 6dbd79b..3e8ea56 100755 --- a/btrbk +++ b/btrbk @@ -806,7 +806,6 @@ sub _safe_cmd($;$) # NOTE: all files must be absolute if($offending) { push @$offending, $_ unless(defined(check_file($_, { absolute => 1 }))); - push @$offending, $_ unless(!$safe_commands || /^($safe_file_match)$/); } $_ = $prefix . quoteshell($_) . $postfix; } @@ -3787,6 +3786,10 @@ sub check_file($$;@) ERROR "Illegal leading/trailing whitespace ${error_statement}: \"$file\"" if(defined($error_statement)); return undef; } + if($safe_commands && $file !~ /^$safe_file_match$/) { + ERROR "Invalid file name (restricted by \"safe_commands\" option) ${error_statement}: \"$file\"" if(defined($error_statement)); + return undef; + } return $file; }