c - "Hacking: The Art of Exploitation": why does example program work with just gcc but not with -m32? -



c - "Hacking: The Art of Exploitation": why does example program work with just gcc but not with -m32? -

the next code "hacking: fine art of exploitation" 2nd edition called input.c

int main() { char message[10]; int count, i; strcpy(message, "hello, world!"); printf("repeat how many times? "); scanf("%d", &count); for(i=0; < count; i++) printf("%3d - %s\n", i, message); }

this seems memory error(overflow) me since array message 10 bytes. however, when compile gcc , execute program, runs fine.

when add together in flag gcc -m32 compilation process, abort trap 6 or errors signify wrong ( tried on personal mac , on college's linux computer cluster see whether there different. on latter, there more of explicit error of stack smashing memory map , backtrace, while mac there abort trap 6).

anyway, here questions: why code work gcc , not gcc -m32 ? additionally, why after compile file gcc -m32, if seek compile file 1 time again gcc, still won't work?

there multiple things don't understand, additional info on why happening appreciated. thanks.

writing beyond arrays(and reading beyond them too) undefined behavior, it's coincidence depends on compiler options.

c gcc

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -