From 4d3d3270883140535cc6ea5a190aebdf6f3dc120 Mon Sep 17 00:00:00 2001 From: smitsohu Date: Thu, 10 Mar 2022 14:43:17 +0100 Subject: refactor meta character filtering --- src/fcopy/main.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'src/fcopy') diff --git a/src/fcopy/main.c b/src/fcopy/main.c index c64d20127..e56d853c8 100644 --- a/src/fcopy/main.c +++ b/src/fcopy/main.c @@ -472,18 +472,12 @@ int main(int argc, char **argv) { size_t len = strlen(src); while (len > 1 && src[len - 1] == '/') src[--len] = '\0'; - if (strcspn(src, "\\*&!?\"'<>%^(){}[];,") != len) { - fprintf(stderr, "Error fcopy: invalid source file name %s\n", src); - exit(1); - } + reject_meta_chars(src, 0); len = strlen(dest); while (len > 1 && dest[len - 1] == '/') dest[--len] = '\0'; - if (strcspn(dest, "\\*&!?\"'<>%^(){}[];,~") != len) { - fprintf(stderr, "Error fcopy: invalid dest file name %s\n", dest); - exit(1); - } + reject_meta_chars(dest, 0); // the destination should be a directory; struct stat s; -- cgit v1.2.3-54-g00ecf