...
Code Block |
---|
|
void func(signed long s_a;
, signed long s_b;
signed long result;
void func(void) {
/*signed Initialize s_a and s_b */
long result = s_a / s_b;
/* ... */
} |
...
Code Block |
---|
|
#include <limits.h>
void func(signed long s_a;
, signed long s_b;
signed long result;
void func(void) {
/*signed Initialize s_a, s_b and result */
long result;
if ( (s_b == 0) || ( (s_a == LONG_MIN) && (s_b == -1) ) ) {
/* Handle error condition */
} else {
result = s_a / s_b;
}
/* ... */
} |
...
Code Block |
---|
|
void func(signed long s_a;
, signed long s_b;
signed long result;
void func(void) {
/* Initialize s_a and s_b */
signed long result = s_a % s_b;
/* ... */
} |
...
Code Block |
---|
|
#include <limits.h>
void func(signed long s_a;
, signed long s_b;
signed long result;
void func(void) {
/* Initialize s_a, s_b and result */
signed long result;
if ( (s_b == 0 ) || ( (s_a == LONG_MIN) && (s_b == -1) ) ) {
/* Handle error condition */
} else {
result = s_a % s_b;
}
/* ... */
} |
Risk Assessment
...
Search for vulnerabilities resulting from the violation of this rule on the CERT website.
Related Guidelines
Bibliography
...