Skip to content
Snippets Groups Projects
Commit a53fbc9b authored by ja3-saxby's avatar ja3-saxby
Browse files

Fix issue where void pointers were being dereferenced

In calls to move_stack_pointer(), intial_stack_pointer should not be dereferenced in the call
This was causing page faults but this has now been corrected
parent c2d18c92
No related branches found
No related tags found
1 merge request!5Alex/6 implement populate stack process
...@@ -29,27 +29,27 @@ void populate_stack(void** stack_pointer, int argc, char** argv) { ...@@ -29,27 +29,27 @@ void populate_stack(void** stack_pointer, int argc, char** argv) {
memcpy(*stack_pointer, argv[i], strlen(argv[i]) + 1); memcpy(*stack_pointer, argv[i], strlen(argv[i]) + 1);
} }
move_stack_pointer(*stack_pointer, -4); //Moves the stack pointer back 4 move_stack_pointer(stack_pointer, -4); //Moves the stack pointer back 4
(*(int *)(*stack_pointer)) = 0;//sentinel (*(int *)(*stack_pointer)) = 0;//sentinel
i = argc; i = argc;
while (--i >= 0) while (--i >= 0)
{ {
move_stack_pointer(*stack_pointer, -4); //32bit Moves the stack pointer back 4 move_stack_pointer(stack_pointer, -4); //32bit Moves the stack pointer back 4
(*(uint32_t **)(*stack_pointer)) = arr[i]; (*(uint32_t **)(*stack_pointer)) = arr[i];
} }
move_stack_pointer(*stack_pointer, -4); move_stack_pointer(stack_pointer, -4);
move_stack_pointer(*stack_pointer, 4); //Moves the stack pointer forwards 4 move_stack_pointer(stack_pointer, 4); //Moves the stack pointer forwards 4
// TODO: Test if still required in later version // TODO: Test if still required in later version
(*(uintptr_t **)(*stack_pointer)) = *stack_pointer; (*(uintptr_t **)(*stack_pointer)) = *stack_pointer;
move_stack_pointer(*stack_pointer, -4); //Moves the stack pointer back 4 move_stack_pointer(stack_pointer, -4); //Moves the stack pointer back 4
*(int *)(*stack_pointer) = argc; *(int *)(*stack_pointer) = argc;
move_stack_pointer(*stack_pointer, -4); //Moves the stack pointer back 4 move_stack_pointer(stack_pointer, -4); //Moves the stack pointer back 4
(*(int *)(*stack_pointer)) = 0; (*(int *)(*stack_pointer)) = 0;
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment