...
Code Block | ||
---|---|---|
| ||
...
char *new_secret;
size_t size = strlen(secret);
if (size == SIZE_MAX) {
/* Handle Error */
}
new_secret = malloc(size+1); /* use calloc() to zero-out allocated space */
if (!new_secret) {
/* Handle Error */
}
strcpy(new_secret, secret);
/* Process new_secret... */
free(new_secret);
...
|
...
Code Block | ||
---|---|---|
| ||
... temp_buff = calloc(new_size,sizeof(char)); /* use calloc() to zero-out allocated space */ if (temp_buff == NULL) { /* Handle Error */ } memcpy(temp_buff, buffer, buffer_size); memset(buffer,'\0',buffer_size); /* sanitize the buffer */ free(buffer); /* free old space */ buffer = temp_buff; /* install the resized buffer */ temp_buff = 0; ... |
...
Rule | Severity | Likelihood | Remediation Cost | Priority | Level |
---|---|---|---|---|---|
MEM33-C | 2 (medium) | 1 (unlikely) | 3 (low) | P6 | L2 |
...
References
http://vulncat.fortifysoftware.com/2/HI.html
http://samate.nist.gov/docs/SAMATE_source_code_analysis_tool_spec_09_15_06.pdf
MEM33-C. Do not assume memory allocation routines initialize memory