Refactor process_init_stack to add asserts and comments
This commit is contained in:
@@ -191,6 +191,10 @@ start_process (void *proc_start_data)
|
||||
static bool
|
||||
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.
|
||||
This can't cause overflow due to enforcing that the size of
|
||||
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;
|
||||
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));
|
||||
if (arg_elem == NULL)
|
||||
|
||||
Reference in New Issue
Block a user