From a6614e587048a2ef33ef43d53ffdc3a570ed293a Mon Sep 17 00:00:00 2001 From: deraadt <> Date: Fri, 17 Mar 2017 14:51:26 +0000 Subject: [PATCH] Grow buffers using recallocarray, to avoid the potential dribble that the standard realloc*() functions can leave behind. imsg buffers are sometimes used in protocol stacks which require some secrecy, and layering violations would be needed to resolve this issue otherwise. Discussed with many. --- src/lib/libutil/imsg-buffer.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/libutil/imsg-buffer.c b/src/lib/libutil/imsg-buffer.c index 58c6655f..f12d4ef5 100644 --- a/src/lib/libutil/imsg-buffer.c +++ b/src/lib/libutil/imsg-buffer.c @@ -1,4 +1,4 @@ -/* $OpenBSD: imsg-buffer.c,v 1.8 2015/12/29 18:05:01 benno Exp $ */ +/* $OpenBSD: imsg-buffer.c,v 1.9 2017/03/17 14:51:26 deraadt Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer @@ -78,7 +78,7 @@ ibuf_realloc(struct ibuf *buf, size_t len) return (-1); } - b = realloc(buf->buf, buf->wpos + len); + b = recallocarray(buf->buf, buf->size, buf->wpos + len, 1); if (b == NULL) return (-1); buf->buf = b;