...
Code Block | ||
---|---|---|
| ||
...
size_t secret_size, new_secret_size;
...
if (secret_size > SIZE_MAX/2) {
/* handle error condition */
}
temp_buff = calloc(secret_size * 2, sizeof(char)); /* calloc() initializes memory to zero */
if (temp_buff == NULL) {
/* Handle Error */
}
memcpy(temp_buff, secret, secret_size);
memset(secret, '\0', secret_size); /* sanitize the buffer */
free(secret);
secret = temp_buff; /* install the resized buffer */
temp_buff = NULL;
...
|
...