#include /* for printf, etc. */ #include /* for sleep, etc. */ #include /* for getpid(), see "man getpid" */ #include /* for getpid(), see "man getpid" */ /* blowup.c D. Parson for CSC343 to show a segmentation fault when a * process tries to use memory outside of its range. April 2020. * blowstack.c blows out the heap with recursive pmapCommandBuffer [ 84000 ] ; */ void recursion() ; int main() { int i = 4 ; int *ip = &i ; printf("at ip address %lx is value %d\n", ip, *ip); system("ps -fu parson"); /* sleep(10); */ recursion(); return 0 ; } void recursion() { char pmapCommandBuffer [ 84000 ] ; /* just make it big */ sprintf(pmapCommandBuffer, "pmap %ld", (int)getpid()); /* get's process ID */ printf("\nCMD %s\n", pmapCommandBuffer); system(pmapCommandBuffer); sprintf(pmapCommandBuffer, "pstack %ld", (int)getpid()); /* get's process ID */ printf("\nCMD %s\n", pmapCommandBuffer); system(pmapCommandBuffer); // sleep(4); recursion() ; }