diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2002-04-29 06:36:13 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2002-04-29 06:36:13 +0000 |
commit | 0b9f832710043487d06d6c864886495eda2d4a68 (patch) | |
tree | f26844a04c1209117cdae099cbdd0124275ed51d /lib/libc | |
parent | 75aec4421a6707f0b3b2ca01babc105c58daf687 (diff) |
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')
-rw-r--r-- | lib/libc/stdio/wsetup.c | 7 |
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 |