AutosarC++19_03-M18.0.5¶
The unbounded functions of library <cstring> shall not be used
Required inputs: IR
| Level | required |
|---|---|
| Target | implementation |
| Enforcement | automated |
[Undefined 5.7]
Rationale
The strcpy, strcmp, strcat, strchr, strspn, strcspn, strpbrk, strrchr, strstr, strtok and strlen functions within the <cstring> library can read or write beyond the end of a buffer, resulting in undefined behaviour.
Ideally, a safe string handling library should be used.
Example
#include <cstring>
void fn ( const char_t * pChar )
{
char_t array [ 10 ];
strcpy ( array, pChar ); // Non-compliant
}
Note
For legal reasons, this rule’s description is not part of the public documentation.