Fix Bug in syscall handler related to pointer arithmetic: add sizeof uintptr_t instead of 1

This commit is contained in:
sBubshait
2024-11-04 00:44:55 +00:00
parent 3a258cf064
commit 79f6a8e808

View File

@@ -57,10 +57,11 @@ syscall_handler (struct intr_frame *f)
syscall_arguments syscall = syscall_lookup[syscall_number]; syscall_arguments syscall = syscall_lookup[syscall_number];
/* Next, read and copy the arguments from the stack pointer. */ /* Next, read and copy the arguments from the stack pointer. */
validate_user_pointer (f->esp, syscall.arity); validate_user_pointer (f->esp + sizeof (uintptr_t),
uintptr_t args[3]; syscall.arity * sizeof (uintptr_t));
uintptr_t args[3] = {0};
for (int i=0; i < syscall.arity; i++) for (int i=0; i < syscall.arity; i++)
args[i] = *(uintptr_t *) (f->esp + 1 + i); args[i] = *(uintptr_t *) (f->esp + sizeof (uintptr_t) * (i + 1));
/* Call the function that handles this system call with the arguments. When /* Call the function that handles this system call with the arguments. When
there is a return value it is stored in f->eax. */ there is a return value it is stored in f->eax. */