...
This compliant solution ensures the size
argument used to allocate vla
is in a valid range (between 1 and a programmer-defined maximum); otherwise, it uses an algorithm that relies on dynamic memory allocation.:
Code Block | ||||
---|---|---|---|---|
| ||||
enum { MAX_ARRAY = 1024 }; void func(size_t size) { if (0 < size && size < MAX_ARRAY) { int vla[size]; /* ... */ } else { /* Use dynamic allocation */ } } /* ... */ |
...
Tool | Version | Checker | Description | ||||||
---|---|---|---|---|---|---|---|---|---|
Coverity | 6.5 | REVERSE_NEGATIVE | Fully Implemented | ||||||
PRQA QA-C |
| 1051 | Partially implemented. |
Related Vulnerabilities
Search for vulnerabilities resulting from the violation of this rule on the CERT website.
...
Bibliography
...