Add support for some basic system calls and args handling correctly. #29

Merged
sb3923 merged 49 commits from system-calls into master 2024-11-07 19:36:30 +00:00
2 changed files with 90 additions and 19 deletions
Showing only changes of commit 3a258cf064 - Show all commits

View File

@@ -80,11 +80,15 @@ exit (int status UNUSED)
} }
/* Validates if a block of memory starting at PTR and of size SIZE bytes is /* Validates if a block of memory starting at PTR and of size SIZE bytes is
fully contained within user virtual memory. */ fully contained within user virtual memory. Kills the thread (by calling
thread_exit) if the memory is invalid. Otherwise, returns the PTR given.
If the size is 0, the function does no checks and returns PTR.*/
static void * static void *
validate_user_pointer (void *ptr, size_t size) validate_user_pointer (void *ptr, size_t size)
{ {
if (ptr == NULL || !is_user_vaddr (ptr) || !is_user_vaddr (ptr + size - 1)) if (size > 0 && (ptr == NULL ||
!is_user_vaddr (ptr) ||
!is_user_vaddr (ptr + size - 1)))
thread_exit (); thread_exit ();
return ptr; return ptr;