summaryrefslogtreecommitdiffstats
path: root/lib/libutil/imsg.c
diff options
context:
space:
mode:
authorreyk <reyk@openbsd.org>2017-04-11 09:57:19 +0000
committerreyk <reyk@openbsd.org>2017-04-11 09:57:19 +0000
commitf00211be2215c47e0b35fca6de4d2cdcdf1596d3 (patch)
treed0e416cf6d8cb1b5c2516f6647d2007688431605 /lib/libutil/imsg.c
parentRevise 'struct fpreg' and dump floating-point register in core dumps. Also (diff)
downloadwireguard-openbsd-f00211be2215c47e0b35fca6de4d2cdcdf1596d3.tar.xz
wireguard-openbsd-f00211be2215c47e0b35fca6de4d2cdcdf1596d3.zip
Use freezero(3) for the imsg framework in imsg_free(3) and ibuf_free(3).
In our privsep model, imsg is often used to transport sensitive information between processes. But a process might free an imsg, and reuse the memory for a different thing. iked uses some explicit_bzero() to clean imsg-buffer but doing it in the library with the freezero() is less error-prone and also benefits other daemons. OK deraadt@ jsing@ claudio@
Diffstat (limited to 'lib/libutil/imsg.c')
-rw-r--r--lib/libutil/imsg.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/libutil/imsg.c b/lib/libutil/imsg.c
index ab9ef851ce2..89d16ae8fc9 100644
--- a/lib/libutil/imsg.c
+++ b/lib/libutil/imsg.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: imsg.c,v 1.14 2017/03/24 09:34:12 nicm Exp $ */
+/* $OpenBSD: imsg.c,v 1.15 2017/04/11 09:57:19 reyk Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -263,7 +263,7 @@ imsg_close(struct imsgbuf *ibuf, struct ibuf *msg)
void
imsg_free(struct imsg *imsg)
{
- free(imsg->data);
+ freezero(imsg->data, imsg->hdr.len - IMSG_HEADER_SIZE);
}
int