Compile with those flags:
-O2 -D_FORTIFY_SOURCE=2
to enable basic bounds checks for functions like memcpy or strcpy.
Compiling with -O2 -D_FORTIFY_SOURCE=2 makes glibc functions like memcpy
or strcpy do bounds checking for cases where the bounds are known at compile
time, such as with statically defined, local buffers.
Higher fortify levels (currently from 1 up to 3) enable stricter behavior and add runtime checks (e.g. if the bounds are known to depend on a variable).
This of requires support for certain compiler builtins and optimization needs to be enabled.
sigma star gmbh
Eduard-Bodem-Gasse 6, 1st floor
6020 Innsbruck | Austria