From 72afecfbda6effc5db27ac5017d671b8a3e66791 Mon Sep 17 00:00:00 2001 From: EDiasAlberto Date: Mon, 11 Nov 2024 23:10:02 +0000 Subject: [PATCH] Add validation to check for missing files in exec() args --- src/userprog/process.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/userprog/process.c b/src/userprog/process.c index 1286893..3d12bd1 100644 --- a/src/userprog/process.c +++ b/src/userprog/process.c @@ -81,6 +81,10 @@ process_execute (const char *cmd) of the process. */ char *file_name = strtok_r (cmd_copy, " ", &data->cmd_saveptr); +/* Validates that the current file to be executed is a valid file */ +if (filesys_open (file_name) == NULL) + return TID_ERROR; + /* Create a new thread to execute the command, by initializing it running the function 'start_process' with the appropriate arguments. For details of arguments, see 'start_process'. */