Versions Compared

Key

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

...

This compliant example uses the Linux scanf() implementation's built-in error handling to validate input. On Linux platforms, scanf() sets errno to ERANGE if the result of integer conversion cannot be represented within the size specified by the format string [Linux 2008]. Note that this solution is a platform - dependent solution. Therefore, so it should be used only where portability is not a concern.

...

Tool

Version

Checker

Description

Fortify SCA

V. 5.0

 

Can detect violations of this recommendation with the CERT C Rule Pack.

Compass/ROSE

 

 

Can detect violations of this recommendation. In particular, it notes uses of the scanf() family of functions where on the type specifier is a floating-point or integer type.

PRQA QA-C
Include Page
PRQA_V
PRQA_V
Warncall for scanf etcFully implemented.

Related Vulnerabilities

Search for vulnerabilities resulting from the violation of this rule on the CERT website.

Related Guidelines

...

Bibliography

...

]Section 7.22.1.4, "The strtol, strtoll, strtoul, and strtoull

...

Functions," and

...

MITRE CWE: CWE-192, "Integer coercion error"

MITRE CWE: CWE-197, "Numeric truncation error"

Bibliography

section 7.21.6, "Formatted

...

Input/Output Functions"

...