...
Following are the character classification functions that this rule addresses:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
XSI denotes an X/Open System Interfaces Extension to ISO/IEC 9945—POSIX. These functions are not defined by the C Standard.
...
Passing values to character handling functions that cannot be represented as an unsigned char
to character handling functions is undefined behavior.
Rule | Severity | Likelihood | Remediation Cost | Priority | Level |
---|---|---|---|---|---|
STR37-C | Low | Unlikely | Low | P3 | L3 |
Automated Detection
Tool | Version | Checker | Description | ||||
---|---|---|---|---|---|---|---|
Astrée |
|
Supported, but no explicit checker | |||||||||
CodeSonar |
| MISC.NEGCHAR | Negative character value | ||||||
Compass/ROSE |
Could detect violations of this rule by seeing if the argument to a character handling function (listed above) is not an | |||||||||
| CC2.STR37 | Fully implemented | |||||||
LDRA tool suite |
| 663 S | Fully implemented | ||||||
Polyspace Bug Finder | R2017a | Misuse of sign-extended character value | Data type conversion with sign extension causes unexpected behavior | ||||||
PRQA QA-C |
| 4413,4414 | Fully implemented | ||||||
PRQA QA-C++ | 4.2 | 3051 |
Related Vulnerabilities
Search for vulnerabilities resulting from the violation of this rule on the CERT website.
...
Key here (explains table format and definitions)
Taxonomy | Taxonomy item | Relationship |
---|---|---|
CERT C Secure Coding Standard | STR34-C. Cast characters to unsigned char before converting to larger integer sizes | Prior to 2018-01-12: CERT: Unspecified Relationship |
ISO/IEC TS 17961 | Passing arguments to character-handling functions that are not representable as unsigned char [chrsgnext] | Prior to 2018-01-12: CERT: Unspecified Relationship |
CWE 2.11 | CWE-704, Incorrect Type Conversion or Cast | 2017-06-14: CERT: Rule subset of CWE |
CERT-CWE Mapping Notes
Key here for mapping notes
...
STR37-C excludes mis-ordered function arguments (assuming they pass type-checking), because there is no easy way to reliably detect violations of CWE-683.
Bibliography
[ISO/IEC 9899:2011] | 7.4, "Character Handling <ctype.h >" |
[Kettlewell 2002] | Section 1.1, "<ctype.h > and Characters Types" |
...
...