summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdio/fvwrite.c
diff options
context:
space:
mode:
authormillert <millert@openbsd.org>2017-03-17 16:06:33 +0000
committermillert <millert@openbsd.org>2017-03-17 16:06:33 +0000
commit4af449f85a4862bfa80c9967859a5d52f49d6a13 (patch)
tree046e34356160f77c7ccbec38990b097f83e0a482 /lib/libc/stdio/fvwrite.c
parentrecallocarray() the string buffer, to avoid leaving such contents (diff)
downloadwireguard-openbsd-4af449f85a4862bfa80c9967859a5d52f49d6a13.tar.xz
wireguard-openbsd-4af449f85a4862bfa80c9967859a5d52f49d6a13.zip
Use recallocarray() to avoid leaving detritus in memory when resizing
the string buffer used by asprintf() and vasprintf(). OK deraadt@
Diffstat (limited to 'lib/libc/stdio/fvwrite.c')
-rw-r--r--lib/libc/stdio/fvwrite.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/libc/stdio/fvwrite.c b/lib/libc/stdio/fvwrite.c
index d7b2ec69bdc..ba58f9de01d 100644
--- a/lib/libc/stdio/fvwrite.c
+++ b/lib/libc/stdio/fvwrite.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: fvwrite.c,v 1.19 2017/03/16 14:26:18 millert Exp $ */
+/* $OpenBSD: fvwrite.c,v 1.20 2017/03/17 16:06:33 millert Exp $ */
/*-
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
@@ -112,7 +112,8 @@ __sfvwrite(FILE *fp, struct __suio *uio)
/* Round up to nearest page. */
_size = ((blen + len + 1 + pgmsk) & ~pgmsk) - 1;
- _base = realloc(fp->_bf._base, _size + 1);
+ _base = recallocarray(fp->_bf._base,
+ fp->_bf._size + 1, _size + 1, 1);
if (_base == NULL)
goto err;
fp->_w += _size - fp->_bf._size;