From 3867f4543ac9c8a1247d822e2c75bb4e04866895 Mon Sep 17 00:00:00 2001 From: Sam Talonborn Date: Mon, 15 Jan 2024 16:15:16 -0800 Subject: [PATCH] Make sure to actually check code returned from user_can_... before moving on! --- app/dexter.pl | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/app/dexter.pl b/app/dexter.pl index 19b402c..30c8bf9 100755 --- a/app/dexter.pl +++ b/app/dexter.pl @@ -343,7 +343,8 @@ sub make_size_human_readable ($size) { sub user_save_file_to_path ($user, $file, $path) { my ( $code, $message ) = check_user_can_create_file($user, $path); - ( $code, $message ) = check_dexter_can_create_file($path); + return $code, $message if $code != 200; + ( $code, $message ) = check_dexter_can_create_file($path); return $code, $message if $code != 200; my $path_string = $ROOT_DIRECTORY . $path->to_route; @@ -355,7 +356,8 @@ sub user_save_file_to_path ($user, $file, $path) { sub user_mkdir_at_path ($user, $path) { my ( $code, $message ) = check_user_can_create_file($user, $path); - ( $code, $message ) = check_dexter_can_create_file($path); + return $code, $message if $code != 200; + ( $code, $message ) = check_dexter_can_create_file($path); return $code, $message if $code != 200; my $path_string = $ROOT_DIRECTORY . $path->to_route; @@ -367,7 +369,8 @@ sub user_mkdir_at_path ($user, $path) { sub user_delete_path ($user, $path) { my ( $code, $message ) = check_user_can_delete_file($user, $path); - ( $code, $message ) = check_dexter_can_edit_file($path); + return $code, $message if $code != 200; + ( $code, $message ) = check_dexter_can_edit_file($path); return $code, $message if $code != 200; my $path_string = $ROOT_DIRECTORY . $path->to_route; @@ -388,10 +391,12 @@ sub user_delete_path ($user, $path) { sub user_move_path_to_path ($user, $path, $new_path) { my ( $code, $message ) = check_user_can_delete_file($user, $path); - ( $code, $message ) = check_dexter_can_edit_file($path); + return $code, $message if $code != 200; + ( $code, $message ) = check_dexter_can_edit_file($path); return $code, $message if $code != 200; ( $code, $message ) = check_user_can_create_file($user, $new_path); + return $code, $message if $code != 200; ( $code, $message ) = check_dexter_can_create_file($new_path); return $code, $message if $code != 200;