From df8c4e9cd15bfc2c5cb4c854a8f876c02c2eb1d6 Mon Sep 17 00:00:00 2001 From: netblue30 Date: Mon, 24 Apr 2017 08:38:56 -0400 Subject: fcopy - fix trailing char --- src/fcopy/main.c | 6 ++++++ test/fcopy/fcopy.sh | 3 +++ test/fcopy/trailing.exp | 25 +++++++++++++++++++++++++ 3 files changed, 34 insertions(+) create mode 100755 test/fcopy/trailing.exp 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) { exit(1); } + // trim trailing chars + if (src[strlen(src) - 1] == '/') + src[strlen(src) - 1] = '\0'; + if (dest[strlen(dest) - 1] == '/') + dest[strlen(dest) - 1] = '\0'; + // check the two files; remove ending / int len = strlen(src); 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)" echo "TESTING: fcopy link (test/fcopy/linkcopy.exp)" ./linkcopy.exp +echo "TESTING: fcopy trailing char (test/copy/trailing.exp)" +./linkcopy.exp + 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 @@ +#!/usr/bin/expect -f +# This file is part of Firejail project +# Copyright (C) 2014-2017 Firejail Authors +# License GPL v2 + +# +# copy directory src to dest +# +set timeout 10 +spawn $env(SHELL) +match_max 100000 + +send -- "firejail --private-etc=group,passwd,firejail/ ls /etc/firejail\r" +expect { + timeout {puts "TESTING ERROR 0\n";exit} + "Child process initialized" +} +expect { + timeout {puts "TESTING ERROR 0\n";exit} + "0ad.profile" +} +after 100 + + +puts "\nall done\n" -- cgit v1.2.3-54-g00ecf