/* A simple Buffer Overflow Attack */ #include #include #include static int n; static void f1(void) { printf("%4d f1\n", n); } static void f2(void) { printf("%4d f2 ***\n", n); } int main(int argc, char *argv[]) { void (*func)(void) = f1; uintptr_t A[2]; A[n = atoi(argv[1])] = (uintptr_t) f2; (*func)(); printf("main out\n"); return 0; }