diff options
author | Joursoir <chat@joursoir.net> | 2022-08-25 19:38:00 +0300 |
---|---|---|
committer | Joursoir <chat@joursoir.net> | 2022-08-25 20:36:12 +0300 |
commit | 95705e381b2256df902ae36f64167b882dba7548 (patch) | |
tree | b2b98c404e66ebd76c5ca22e5f8c5be298631f8a /src/exec-cmd.c | |
parent | e0810c5c7ae73c5e12d20fb169507e121c6b01e1 (diff) | |
download | lock-password-95705e381b2256df902ae36f64167b882dba7548.tar.gz lock-password-95705e381b2256df902ae36f64167b882dba7548.tar.bz2 lock-password-95705e381b2256df902ae36f64167b882dba7548.zip |
tree: move printing error into check_sneaky_paths()
Avoid repeating the same error messages.
Diffstat (limited to 'src/exec-cmd.c')
-rw-r--r-- | src/exec-cmd.c | 30 |
1 files changed, 9 insertions, 21 deletions
diff --git a/src/exec-cmd.c b/src/exec-cmd.c index 570bdb5..1bfc3ff 100644 --- a/src/exec-cmd.c +++ b/src/exec-cmd.c @@ -95,10 +95,8 @@ int cmd_insert(int argc, char *argv[]) } result = check_sneaky_paths(path); - if(result) { - print_error("Error: You have used forbidden paths\n"); + if(result) return 1; - } if(file_exist(path) == F_ISFILE) { if(!flag_force) { @@ -176,10 +174,8 @@ int cmd_edit(int argc, char *argv[]) } result = check_sneaky_paths(path); - if(result) { - print_error("Error: You have used forbidden paths\n"); + if(result) return 1; - } result = file_exist(path); if(result == F_NOEXIST) { @@ -304,10 +300,8 @@ int cmd_generate(int argc, char *argv[]) } result = check_sneaky_paths(path); - if(result) { - print_error("Error: You have used forbidden paths\n"); + if(result) return 1; - } result = file_exist(path); if(result == F_ISFILE) { @@ -351,10 +345,8 @@ int cmd_remove(int argc, char *argv[]) } result = check_sneaky_paths(path); - if(result) { - print_error("Error: You have used forbidden paths\n"); + if(result) return 1; - } result = file_exist(path); if(result == F_NOEXIST) { @@ -409,10 +401,9 @@ int cmd_move(int argc, char *argv[]) dbgprint("new-path = %s\n", new_path); result = check_sneaky_paths(old_path); - if(result) { - print_error("Error: You have used forbidden paths\n"); + if(result) return 1; - } + result = file_exist(old_path); if(result == F_NOEXIST) { print_error("Error: No such file exists\n"); @@ -420,10 +411,9 @@ int cmd_move(int argc, char *argv[]) } result = check_sneaky_paths(new_path); - if(result) { - print_error("Error: You have used forbidden paths\n"); + if(result) return 1; - } + result = file_exist(new_path); if(result != F_NOEXIST) { if(!flag_force) { @@ -506,10 +496,8 @@ int cmd_showtree(int argc, char *argv[]) const char *path = "."; if(argv[optind]) { result = check_sneaky_paths(argv[optind]); - if(result) { - print_error("Error: You have used forbidden paths\n"); + if(result) return 1; - } path = argv[optind]; } |