Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

-fstack-protector, -fstack-protector-all and -fmudflap

Tags:

c

linux

gcc

Do -fstack-protector and -fstack-protector-all protect heap-based memory allocations too or only stack-based ones ?

What is the difference between the first 2 and -fmudflap ?

Any recommendations as to which is better for debugging ?

(I'm not sure if the gcc man page is clear enough or I simply do not understand it...)

char foobar[10]; // stack-based

char *foobar = malloc(10); // heap-based
like image 409
Jane Watson Avatar asked Oct 18 '11 15:10

Jane Watson


1 Answers

-fstack-protector and -fstack-protector-all have nothing to do with heap allocations.
-fstack-protector protects strings only (main problem target for buffer overflow attacks), -fstack-protector-all protects all types. Some descriptions here: http://en.wikipedia.org/wiki/Buffer_overflow_protection

like image 155
TJD Avatar answered Oct 25 '22 00:10

TJD