The variable parameters of a variadic function, that is, those that correspond with the position of the ellipsis, are interpreted by the va_arg()
macro. The va_arg()
macro is used to extract the next argument from an initialized argument list within the body of a variadic function implementation. The size of each parameter is determined by the specified type. If the type is inconsistent with the corresponding argument, the behavior is undefined and may result in misinterpreted data or an alignment error. (see See guideline EXP36-C. Do not convert pointers into more strictly aligned pointer types.).
The variable arguments to a variadic function are not checked for type by the compiler. As a result, the programmer is responsible for ensuring that they are compatible with the corresponding parameter after the default argument promotions:
...
Recommendation | Severity | Likelihood | Remediation Cost | Priority | Level |
---|---|---|---|---|---|
DCL11-C | high | probable | high | P6 | L2 |
Automated Detection
...
Tool | Version | Checker | Description | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
|
|
...
|
...
|
|
|
Related Vulnerabilities
Search for vulnerabilities resulting from the violation of this recommendation on the CERT website.
...
Wiki Markup |
---|
\[[ISO/IEC 9899:1999|AA. Bibliography#ISO/IEC 9899-1999]\] Section 6.5.2.2, "Function calls," and Section 7.15, "Variable arguments" \[[ISO/IEC PDTR 24772|AA. Bibliography#ISO/IEC PDTR 24772]\] "IHN Type system" and "OTR Subprogram Signature Mismatch" \[[MISRA 042004|AA. Bibliography#MISRA 04]\] Rule 16.1 |
...