Do not make any assumptions about the size of environment variables because an adversary might have full control over the environment. If the environment variable needs to be stored, the length of the associated string should be calculated and the storage dynamically allocated . (See see STR31-C. Guarantee that storage for strings has sufficient space for character data and the null terminator).)
Noncompliant Code Example
...
Tool | Version | Checker | Description | ||||||
---|---|---|---|---|---|---|---|---|---|
CodeSonar |
| LANG.MEM.BO | Buffer Overrunoverrun | ||||||
|
| Can detect violations of the rule by using the same method as STR31-C. Guarantee that storage for strings has sufficient space for character data and the null terminator |
...
Search for vulnerabilities resulting from the violation of this rule on the CERT website.
Related Guidelines
...
...