#include /* based on your knowledge of stack frames, what would I have to type to get executable code into the input string and overwrite f's return address with that code's start address? */ char * gets(char * s) { int len = 0; while (1) { char c = getchar(); if (c == EOF) { if (len == 0) return NULL; else break; } if (c == '\n') break; s[len] = c; len += 1; } s[len] = 0; return s; } void f() { int a = 1234; char input[16]; int b = 9876; // this is so we can see how much padding the compiler inserts printf(" %u %u %u\n", & b, input, & a); printf(" %d '%s' %d\n", a, input, b); gets(input); printf(" %d '%s' %d\n", a, input, b); } int main() { printf("one\n"); f(); printf("\ntwo\n"); f(); printf("\nthree\n"); f(); printf("\nfour\n"); f(); printf("\nfive\n"); }