summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdio/wsetup.c
diff options
context:
space:
mode:
authorespie <espie@openbsd.org>2002-04-29 06:36:12 +0000
committerespie <espie@openbsd.org>2002-04-29 06:36:12 +0000
commitde2bb04f47b8e85b00cbe7098330784c77eeabc2 (patch)
tree337b2897bf0d9ad782073fd31c746792f6e5f5ee /lib/libc/stdio/wsetup.c
parentsync (diff)
downloadwireguard-openbsd-de2bb04f47b8e85b00cbe7098330784c77eeabc2.tar.xz
wireguard-openbsd-de2bb04f47b8e85b00cbe7098330784c77eeabc2.zip
fix for NetBSD lib/16483
Do not even try to allocate buffer if SSTR and not SALC (e.g., from snprintf and not asprintf). vfprintf is smart enough to then not try and write to it. ok millert@, deraadt@
Diffstat (limited to 'lib/libc/stdio/wsetup.c')
-rw-r--r--lib/libc/stdio/wsetup.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/libc/stdio/wsetup.c b/lib/libc/stdio/wsetup.c
index 89d560158d7..bd824aa95f0 100644
--- a/lib/libc/stdio/wsetup.c
+++ b/lib/libc/stdio/wsetup.c
@@ -35,7 +35,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char rcsid[] = "$OpenBSD: wsetup.c,v 1.3 2001/07/09 06:57:45 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: wsetup.c,v 1.4 2002/04/29 06:36:12 espie Exp $";
#endif /* LIBC_SCCS and not lint */
#include <stdio.h>
@@ -75,8 +75,11 @@ __swsetup(fp)
/*
* Make a buffer if necessary, then set _w.
*/
- if (fp->_bf._base == NULL)
+ if (fp->_bf._base == NULL) {
+ if ((fp->_flags & (__SSTR | __SALC)) == __SSTR)
+ return (EOF);
__smakebuf(fp);
+ }
if (fp->_flags & __SLBF) {
/*
* It is line buffered, so make _lbfsize be -_bufsize