/* See glibc-2.5/elf/stackguard-macros.h for non-x86 STACK_CHK_GUARD's */ #include #include #include # define STACK_CHK_GUARD \ ({ uintptr_t x; asm ("movl %%gs:0x14, %0" : "=r" (x)); x; }) int overflow(char *test) { char buffer[7]; sprintf(buffer, "12345678901234567890123456789012345678901234567890"); return(1234); } int main(int argc, char **argv) { printf("__stack_chk_guard\t=\t0x%08x;\n", STACK_CHK_GUARD); overflow("test"); printf("This line should never get printed.\n"); }