Implement function to validate user memory pointers w/ S.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#include "userprog/syscall.h"
|
||||
#include "devices/shutdown.h"
|
||||
#include "threads/vaddr.h"
|
||||
#include <stdio.h>
|
||||
#include <syscall-nr.h>
|
||||
#include "threads/interrupt.h"
|
||||
@@ -51,4 +52,15 @@ static void
|
||||
exit (int status)
|
||||
{
|
||||
//TODO
|
||||
}
|
||||
|
||||
/* A function to validate if a block of memory starting at PTR and of
|
||||
size SIZE bytes is fully contained within user virtual memory. */
|
||||
static void *
|
||||
validate_user_pointer (void *ptr, size_t size)
|
||||
{
|
||||
if (ptr == NULL || !is_user_vaddr (ptr) || !is_user_vaddr (ptr + size - 1))
|
||||
thread_exit ();
|
||||
|
||||
return ptr;
|
||||
}
|
||||
Reference in New Issue
Block a user