diff options
-rw-r--r-- | src/fcopy/main.c | 6 | ||||
-rwxr-xr-x | test/fcopy/fcopy.sh | 3 | ||||
-rwxr-xr-x | test/fcopy/trailing.exp | 25 |
3 files changed, 34 insertions, 0 deletions
diff --git a/src/fcopy/main.c b/src/fcopy/main.c index 88379001c..b9d2c19a8 100644 --- a/src/fcopy/main.c +++ b/src/fcopy/main.c | |||
@@ -322,6 +322,12 @@ int main(int argc, char **argv) { | |||
322 | exit(1); | 322 | exit(1); |
323 | } | 323 | } |
324 | 324 | ||
325 | // trim trailing chars | ||
326 | if (src[strlen(src) - 1] == '/') | ||
327 | src[strlen(src) - 1] = '\0'; | ||
328 | if (dest[strlen(dest) - 1] == '/') | ||
329 | dest[strlen(dest) - 1] = '\0'; | ||
330 | |||
325 | // check the two files; remove ending / | 331 | // check the two files; remove ending / |
326 | int len = strlen(src); | 332 | int len = strlen(src); |
327 | if (src[len - 1] == '/') | 333 | if (src[len - 1] == '/') |
diff --git a/test/fcopy/fcopy.sh b/test/fcopy/fcopy.sh index 362ed66e0..fffdbd606 100755 --- a/test/fcopy/fcopy.sh +++ b/test/fcopy/fcopy.sh | |||
@@ -27,4 +27,7 @@ echo "TESTING: fcopy file (test/fcopy/filecopy.exp)" | |||
27 | echo "TESTING: fcopy link (test/fcopy/linkcopy.exp)" | 27 | echo "TESTING: fcopy link (test/fcopy/linkcopy.exp)" |
28 | ./linkcopy.exp | 28 | ./linkcopy.exp |
29 | 29 | ||
30 | echo "TESTING: fcopy trailing char (test/copy/trailing.exp)" | ||
31 | ./linkcopy.exp | ||
32 | |||
30 | rm -fr dest/* | 33 | rm -fr dest/* |
diff --git a/test/fcopy/trailing.exp b/test/fcopy/trailing.exp new file mode 100755 index 000000000..1bff4e6c8 --- /dev/null +++ b/test/fcopy/trailing.exp | |||
@@ -0,0 +1,25 @@ | |||
1 | #!/usr/bin/expect -f | ||
2 | # This file is part of Firejail project | ||
3 | # Copyright (C) 2014-2017 Firejail Authors | ||
4 | # License GPL v2 | ||
5 | |||
6 | # | ||
7 | # copy directory src to dest | ||
8 | # | ||
9 | set timeout 10 | ||
10 | spawn $env(SHELL) | ||
11 | match_max 100000 | ||
12 | |||
13 | send -- "firejail --private-etc=group,passwd,firejail/ ls /etc/firejail\r" | ||
14 | expect { | ||
15 | timeout {puts "TESTING ERROR 0\n";exit} | ||
16 | "Child process initialized" | ||
17 | } | ||
18 | expect { | ||
19 | timeout {puts "TESTING ERROR 0\n";exit} | ||
20 | "0ad.profile" | ||
21 | } | ||
22 | after 100 | ||
23 | |||
24 | |||
25 | puts "\nall done\n" | ||