Fortified system functions

QNX SDP8.0QNX OS System Security GuideAPIConfiguration

QNX OS fortified system functions are designed to detect out-of-bounds memory accesses by performing lightweight parameter validation at compile-time, runtime, or both.

If a component does not currently use fortified system functions, you need to recompile it to make use of this feature.

The following example makefile excerpt illustrates how to enable the use of fortified system functions for all modules of a project via the CPPFLAGS variable:

CPPFLAGS += -D_FORTIFY_SOURCE=2 
  • The _FORTIFY_SOURCE feature test macro is defined with a value of 2. A value of 1 or 2 enables the feature. For a description of the difference between these settings, see the Fortified System Functions chapter.
  • The default compiler optimization setting (-O0) does not support _FORTIFY_SOURCE. Makefiles are responsible for enabling compiler optimization. QNX recursive makefiles enable compiler optimization implicitly (either -O2 or -Os, depending on the target architecture; see Conventions for Recursive Makefiles and Directories in the QNX OS Programmer's Guide).
  • Although _FORTIFY_SOURCE can function with a compiler optimization setting of -O1, it might not detect as many buffer overflow anomalies as it would with a higher optimization setting. QNX recommends a setting of -Os or -Om, where m is greater than or equal to 2.

Alternatively, you can enable the use of fortified system functions by setting a shell environment variable before the make utility is invoked. For a QNX recursive makefile project, you can use CCOPTS (CXXOPTS for component written in C++). For example:

CCOPTS="-D_FORTIFY_SOURCE=2" make 

For projects that don't use QNX recursive makefiles, see the project's documentation to determine the correct variable or variables to use to specify the -D_FORTIFY_SOURCE=2 option and, if necessary, a compatible compiler optimization setting. For more information, see Fortified system functions in Security Features for System Integrators.

For more information, including how to enable fortified system functions for specific source files and diagnostic messages related to the feature, see the Fortified System Functions chapter.

Page updated: