...
| Code Block | ||
|---|---|---|
| ||
enum { BLOCKSIZE = 16 };
/* ... */
void* AllocBlocks(size_t cBlocks) {
if (cBlocks == 0) return NULL;
unsigned long long alloc = cBlocks * BLOCKSIZE ;
return (alloc < UINT_MAX)
? malloc(cBlocks * BLOCKSIZE )
: NULL;
}
|
...
| Code Block | ||
|---|---|---|
| ||
enum { BLOCKSIZE = 16 };
/* ... */
void *AllocBlocks(size_t cBlocks) {
if (cBlocks == 0 || cBlocks > SIZE_MAX / BLOCKSIZE) return NULL;
return malloc (cBlocks * BLOCKSIZE);
} /* end AllocBlocks */
|
...
Rule | Severity | Likelihood | Remediation Cost | Priority | Level |
|---|---|---|---|---|---|
MEM35-C | 3 ( high ) | 2 ( probable ) | 1 ( high ) | P6 | L2 |
Automated Detection
Fortify SCA Version 5.0 with CERT C Rule Pack can detect violations of this rule, except those involving the sizeof operator.
...