_FORTIFY_SOURCE (since glibc 2.3.4)
Defining this macro causes some lightweight checks to be performed to detect some buffer overflow errors
when employing various string and memory manipulation functions (for example, memcpy(3), memset(3),
stpcpy(3), strcpy(3), strncpy(3), strcat(3), strncat(3), sprintf(3), snprintf(3), vsprintf(3),
vsnprintf(3), gets(3), and wide character variants thereof). For some functions, argument consistency is
checked; for example, a check is made that open(2) has been supplied with a mode argument when the speci‐
fied flags include O_CREAT. Not all problems are detected, just some common cases.
If _FORTIFY_SOURCE is set to 1, with compiler optimization level 1 (gcc -O1) and above, checks that
shouldn't change the behavior of conforming programs are performed. With _FORTIFY_SOURCE set to 2, some
more checking is added, but some conforming programs might fail.
Some of the checks can be performed at compile time (via macros logic implemented in header files), and
result in compiler warnings; other checks take place at run time, and result in a run-time error if the
check fails.
Use of this macro requires compiler support, available with gcc(1) since version 4.0.