Static Analysis Problem Type Reference
An attempt to access outside the bounds of a variable (usually an array) was found.
Bounds violations can corrupt memory or read from uninitialized data, leading to unpredictable behavior. Bounds violations are one of the leading causes of software security issues. It is often possible to exploit a bounds violation to write arbitrary code into memory and then execute that code, effectively taking control over the process.
Some bounds violations are certain in the sense that the flagged statement, if executed, would always perform a bounds violation. Others are speculative, meaning that the statement might perform a bounds violation, depending on the values of related variables. Both kinds should be carefully investigated and repaired the ensure that a bounds violation cannot happen at run time.
|
ID |
Code Location |
Description |
|---|---|---|
|
1 |
Buffer overflow |
The statement containing the bounds overflow |
int a[10], b[10];
void f() {
int i;
for (i = 0; i <= 10; i++) {
a[i] = 0; // will assign to a[10] (bounds error)
b[i - 1] = 0; // will assign to b[-1] (bounds error)
}
}