Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

The CERT C Programming Language Secure Coding Standard was developed specifically for versions of the C programming language defined by

  • [ISO/IEC 9899:2011] ISO/IEC. Programming Languages—C, 3rd ed. [ISO/IEC 9899:2011]
  • ISO/IEC 9899:1999 Programming Languages—C, 2nd ed. 1999 Programming Languages — C, Second Edition [ISO/IEC 9899:1999]
  • Technical corrigenda TC1, TC2, and TC3
  • ISO/IEC TR 24731-1 Extensions to the C Library, Part I: Bounds-checking interfaces [ISO/IEC TR 24731-1-2007]
  • ISO/IEC PDTR 24731-2 Extensions to the C Library, Part II: Dynamic Allocation Functions [ISO/IEC PDTR 24731-2]

...

A secure coding standard for the C programming language can create the highest value for the longest period of time by focusing on C99 on the C Standard (C11) and the relevant post-C99 C11 technical reports.

The C standard Standard documents existing practice where possible. That is, most features must be tested in an implementation before being included in the standard. The CERT C secure coding standard Cding Standard has a different purpose. When existing practice serves this purpose, that is fine, but the goal is to create a new set of best practices, and that includes introducing some concepts that are not yet widely known. To put it a different way, the CERT C secure coding guidelines are attempting guidelines attempt to drive change rather than just document it.

For example, the C library technical report, part 1 (TR 24731-1) is gaining support , but at present is only implemented by a few vendors. It introduces functions such as memcpy_s(), which serve the purpose of security by adding the destination buffer size to the API. A forward-looking document could not reasonably ignore these simply because they are not yet widely implemented.

C99 is The C Standard is more widely implemented, but even if it were not yet, it is the direction in which the industry is moving. Developers of new C code, especially, need guidance that is usable on and makes the best use of the compilers and tools that are now being developed and are being supported into the future.

Some vendors have extensions to C, and some also have implemented only part of the C standard Standard before stopping development. Consequently, it is not possible to back up and discuss only discuss C95, C90, or C90C99. The vendor support equation is too complicated to draw a line and say that a certain compiler supports exactly a certain standard. Whatever demarcation point is selected, different vendors are on opposite sides of it for different parts of the language. Supporting all possibilities would require testing the cross-product of each compiler with each language feature. Consequently, we have selected a demarcation point that is the most recent in time, so that the rules and recommendations defined by the standard will be applicable for as long as possible. As a result of the variations in support, source-code portability is enhanced when the programmer uses only the features specified by C90C99. This is one of many trade-offs between security and portability inherent to C language programming.

The value of forward-looking information increases with time before it starts to decrease. The value of backward-looking information starts to decrease immediately.

For all these reasons, the priority of this standard is to support new code development using C99 C11 and the post-C99 C11 technical reports. A close-second priority is supporting remediation of old code using C99 and the technical reports.

...

Coding style issues are subjective, and it has proven impossible to develop a consensus on appropriate style guidelines. Consequently, the CERT C Secure Coding standard Standard does not require any particular coding style to be enforced but only that the user defines style guidelines and apply these guidelines consistently. The easiest way to consistently apply a coding style is with the use of a code-formatting tool. Many interactive development environments (IDEs) provide such capabilities.

...