From 7a4a54db97ab564f051ce4c5ea01fc4e1dd28cce Mon Sep 17 00:00:00 2001 From: Axel Burri Date: Sat, 19 Nov 2022 19:31:57 +0100 Subject: [PATCH] btrbk: disallow newline in files While most functionality works fine, raw backups fail to write correct "FILE=" information in info sidecar. Disallowing newlines in files is a good idea in general. --- btrbk | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/btrbk b/btrbk index 6cecf11..6dbd79b 100755 --- a/btrbk +++ b/btrbk @@ -3768,7 +3768,10 @@ sub check_file($$;@) die("accept_type must contain either 'relative' or 'absolute'"); } - # check directory traversal + if($file =~ /\n/) { + ERROR "Unsupported newline in file ${error_statement}: " . ($file =~ s/\n/\\n/gr) if(defined($error_statement)); + return undef; + } if(($file =~ /^\.\.$/) || ($file =~ /^\.\.\//) || ($file =~ /\/\.\.\//) || ($file =~ /\/\.\.$/)) { ERROR "Illegal directory traversal ${error_statement}: $file" if(defined($error_statement)); return undef;