Refactor System Calls and Process for Readability; Change FD to local counter and use it as hash #47
@@ -191,6 +191,10 @@ start_process (void *proc_start_data)
|
|||||||
static bool
|
static bool
|
||||||
process_init_stack (char *cmd_saveptr, void **esp, char *file_name)
|
process_init_stack (char *cmd_saveptr, void **esp, char *file_name)
|
||||||
{
|
{
|
||||||
|
ASSERT (cmd_saveptr != NULL);
|
||||||
|
ASSERT (esp != NULL);
|
||||||
|
ASSERT (file_name != NULL);
|
||||||
|
|
||||||
/* Load command line argument *data* to user process stack.
|
/* Load command line argument *data* to user process stack.
|
||||||
This can't cause overflow due to enforcing that the size of
|
This can't cause overflow due to enforcing that the size of
|
||||||
command line input must fit in a page. Also keep track
|
command line input must fit in a page. Also keep track
|
||||||
@@ -202,7 +206,10 @@ process_init_stack (char *cmd_saveptr, void **esp, char *file_name)
|
|||||||
int arg_count = 0;
|
int arg_count = 0;
|
||||||
while (arg != NULL)
|
while (arg != NULL)
|
||||||
{
|
{
|
||||||
push_to_stack (esp, arg, (strlen (arg) + 1) * sizeof (char));
|
/* 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);
|
||||||
|
|
||||||
struct arg_elem *arg_elem = malloc (sizeof (struct arg_elem));
|
struct arg_elem *arg_elem = malloc (sizeof (struct arg_elem));
|
||||||
if (arg_elem == NULL)
|
if (arg_elem == NULL)
|
||||||
|
|||||||
Reference in New Issue
Block a user