diff --git a/src/userprog/process.c b/src/userprog/process.c index 1e7b227..e712e22 100644 --- a/src/userprog/process.c +++ b/src/userprog/process.c @@ -209,7 +209,7 @@ process_init_stack (char *cmd_saveptr, void **esp, char *file_name) /* filename has already been validated to be a safe-to-access string, so we can safely use strlen here. Filename has already been split from the command line arguments. */ - push_to_stack (esp, arg, strlen (arg) + 1); + push_to_stack (esp, arg, (strlen (arg) + 1) * sizeof (char)); /* Try to allocate memory for the argument pointer. */ struct arg_elem *arg_elem = malloc (sizeof (struct arg_elem)); @@ -376,9 +376,10 @@ process_exit (void) /* Clean up all open files */ hash_destroy (&cur->open_files, fd_cleanup); - /* Close the executable file. */ + /* Close the executable file, implicitly allowing it to be written to. */ if (cur->exec_file != NULL) { + /* Acquire the file system lock to prevent race conditions. */ lock_acquire (&filesys_lock); file_close (cur->exec_file); lock_release (&filesys_lock);