This reduces the chances of passwords and other secrets lying around in
memory when we're done. Arguably if anyone can just read memory of the
VPN client while it's running, the game is already lost... but still,
this is easy enough to do, and it's been reported as CVE-2018-20319.
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
if (!buf)
return;
- buf->pos = 0;
if (buf->data)
- buf->data[0] = 0;
+ memset(buf->data, 0, buf->pos);
+
+ buf->pos = 0;
}
int buf_ensure_space(struct oc_text_buf *buf, int len)
int error = buf_error(buf);
if (buf) {
+ buf_truncate(buf);
if (buf->data)
free(buf->data);
free(buf);