diff options
author | 1996-10-28 05:32:54 +0000 | |
---|---|---|
committer | 1996-10-28 05:32:54 +0000 | |
commit | 2acecd74411762657c5fae5246919db82e7f476c (patch) | |
tree | c205bc40270999ec73ba828d4e2491f9a85d98e7 /lib/libc/stdio/putc.c | |
parent | remove(3) should be able to remove empty directories (diff) | |
download | wireguard-openbsd-2acecd74411762657c5fae5246919db82e7f476c.tar.xz wireguard-openbsd-2acecd74411762657c5fae5246919db82e7f476c.zip |
Verify that file pointer is writable
Diffstat (limited to 'lib/libc/stdio/putc.c')
-rw-r--r-- | lib/libc/stdio/putc.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/libc/stdio/putc.c b/lib/libc/stdio/putc.c index db1edd14bd0..b43af508a55 100644 --- a/lib/libc/stdio/putc.c +++ b/lib/libc/stdio/putc.c @@ -35,10 +35,12 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD: putc.c,v 1.2 1996/08/19 08:32:58 tholo Exp $"; +static char rcsid[] = "$OpenBSD: putc.c,v 1.3 1996/10/28 05:32:55 tholo Exp $"; #endif /* LIBC_SCCS and not lint */ #include <stdio.h> +#include <errno.h> +#include "local.h" /* * A subroutine version of the macro putc. @@ -49,5 +51,9 @@ putc(c, fp) int c; register FILE *fp; { + if (cantwrite(fp)) { + errno = EBADF; + return (EOF); + } return (__sputc(c, fp)); } |