CSC-4730 / P2 / modified / guard.c
guard.c
Raw
//Created 9.22.21 for Carthage CSC_4730 P2 | Caleb Collar & Kai Kuebler
//Null pointer dereference test
//Test code initially provided by Dr. Kivolowitz

#include "types.h"
#include "user.h" 
 
int main(int argc, char ** argv) { 
  unsigned char * p = (unsigned char *) 1024; 
  unsigned char c; 
  printf(1, "Reading from address 0x%x value: 0x%x\n", p, (unsigned int) 
(c = *p)); 
  printf(1, "Writing to address 0x%x\n", p); 
  *p = c; 
  printf(1, "Reading from address 0x%x value: 0x%x\n", p, (unsigned int) 
*p); 
  exit(); 
}