...
Code Block | ||
---|---|---|
| ||
float x, result;
if ( islessequal(x,-1) || isgreaterequal(x, 1) ){
/* handle domain error */
}
result = acos(x);
|
...
Code Block | ||
---|---|---|
| ||
float x, y, result;
if ( fpclassify(x) == FP_ZERO && fpclassify(y) == FP_ZERO){
/* handle domain error */
}
result = atan2(y, x);
|
...
Code Block | ||
---|---|---|
| ||
float result, x;
if (islessequal(x, 0)){
/* handle domain and range errors */
}
result = log(x);
|
...
Code Block | ||
---|---|---|
| ||
float x, y, result;
result = pow(x, y);
|
Compliant Solution
This code tests x and y to ensure that there will be no range or domain errors.
Code Block | ||
---|---|---|
| ||
float x, y, result;
if (fpclassify(x) == FP_ZERO && islessequal(y, 0)){
/* handle domain error condition */
}
result = pow(x, y);
|
...
Code Block | ||
---|---|---|
| ||
float x, result;
if (isless(x, 0)){
/* handle domain error */
}
result = sqrt(x);
|
...
Rule | Severity | Likelihood | Remediation Cost | Priority | Level |
---|---|---|---|---|---|
FLP32-C | 2 (medium) | 2 (probable) | 2 (medium) | P8 | L2 |
Related Vulnerabilities
Search for vulnerabilities resulting from the violation of this rule on the CERT website.
Search for vulnerabilities resulting from the violation of this rule on the CERT website
...