Macros are frequently used in the remediation of existing code to globally replace one identifier with another, for example, when an existing API changes. Although some risk is always involved, this practice becomes particularly dangerous if a function name is replaced with the function name of a deprecated or obsolescent function. Deprecated functions are defined by the C standard Standard and Technical Corrigenda. Obsolescent functions are defined by MSC34-C. Do not use deprecated or obsolete functions.
...
The Internet Systems Consortium's (ISC) Dynamic Host Configuration Protocol (DHCP) contained a vulnerability that introduced several potential buffer overflow conditions [VU#654390]. ISC DHCP makes use of the vsnprintf()
function for writing various log file strings, which is defined in the Open Group Base Specifications Issue 6 [Open Group 2004] as well as C11 [ISO/IEC 9899:2011]. For systems that do not support vsnprintf()
, a C include file was created that defines the vsnprintf()
function to vsprintf()
, as shown in this noncompliant code example:
...
Replacing secure functions with less secure functions is a very risky practice because developers can be easily fooled into trusting the function to perform a security check that is absent. This may be a concern, for example, as developers attempt to adopt more secure functions, like the ISO/IEC TR 24731-1 functions that might not be available on all platforms. (See STR07-C. Use the bounds-checking interfaces for remediation of existing string manipulation code.)
...
Search for vulnerabilities resulting from the violation of this rule on the CERT website.
Related Guidelines
...
...
...
CWE-684, "Failure to provide specified functionality" |
...
Bibliography
[ISO/IEC 9899:2011] | Section 7.21.6.12, "The vsnprintf Function" |
---|---|
[Open Group 2004] | vsnprintf() |
[Seacord 2005a] | Chapter 6, "Formatted Output" |
[VU#654390] |
...