summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdio/wbuf.c
diff options
context:
space:
mode:
authortholo <tholo@openbsd.org>1997-05-31 08:45:51 +0000
committertholo <tholo@openbsd.org>1997-05-31 08:45:51 +0000
commit7016bbaf97824fce80f6344699a5fb517e969047 (patch)
tree696cebeb015b45a0af940b91493040fbefa969c9 /lib/libc/stdio/wbuf.c
parentlukem: Determine filesystem level (ref: fsck_ffs(8) -c ...) and display it. (diff)
downloadwireguard-openbsd-7016bbaf97824fce80f6344699a5fb517e969047.tar.xz
wireguard-openbsd-7016bbaf97824fce80f6344699a5fb517e969047.zip
Set errno to EBADF when trying to write to a stream not open for writing;
required by POSIX
Diffstat (limited to 'lib/libc/stdio/wbuf.c')
-rw-r--r--lib/libc/stdio/wbuf.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/libc/stdio/wbuf.c b/lib/libc/stdio/wbuf.c
index 0cef3704a27..ae6f05ca6a9 100644
--- a/lib/libc/stdio/wbuf.c
+++ b/lib/libc/stdio/wbuf.c
@@ -35,7 +35,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char rcsid[] = "$OpenBSD: wbuf.c,v 1.2 1996/08/19 08:33:15 tholo Exp $";
+static char rcsid[] = "$OpenBSD: wbuf.c,v 1.3 1997/05/31 08:45:51 tholo Exp $";
#endif /* LIBC_SCCS and not lint */
#include <stdio.h>
@@ -60,8 +60,10 @@ __swbuf(c, fp)
* calls might wrap _w from negative to positive.
*/
fp->_w = fp->_lbfsize;
- if (cantwrite(fp))
+ if (cantwrite(fp)) {
+ errno = EBADF;
return (EOF);
+ }
c = (unsigned char)c;
/*