Previous: Stack Smashing Protection, Up: Overflow Protection [Contents][Index]

### 12.2 Object Size Checking

Object Size Checking is a feature which wraps certain functions with checks to prevent buffer overflows. These are enabled when compiling with optimization (`-O1` and higher) and `_FORTIFY_SOURCE` defined to 1, or for stricter checks, to 2.

The following functions use object size checking to detect buffer overflows when enabled:

    String functions:

    bcopy           memmove         strcpy
    bzero           mempcpy         strcat
    explicit_bzero  memset          strncat
    memcpy          stpcpy          strncpy

    Wide Character String functions:

    fgetws          wcrtomb         wcsrtombs
    fgetws_unlocked wcscat          wmemcpy
    mbsnrtowcs      wcscpy          wmemmove
    mbsrtowcs       wcsncat         wmempcpy
    wcpcpy          wcsncpy         wmemset
    wcpncpy         wcsnrtombs

    Stdio functions:

    fgets           fread_unlocked  sprintf
    fgets_unlocked  gets            vsnprintf
    fread           snprintf        vsprintf

    Stdlib functions:

    mbstowcs        wcstombs        wctomb

    System functions:

    getcwd          read            ttyname_r
    pread           readlink