summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdio/fputc.c
diff options
context:
space:
mode:
authortholo <tholo@openbsd.org>1996-10-28 05:32:54 +0000
committertholo <tholo@openbsd.org>1996-10-28 05:32:54 +0000
commit2acecd74411762657c5fae5246919db82e7f476c (patch)
treec205bc40270999ec73ba828d4e2491f9a85d98e7 /lib/libc/stdio/fputc.c
parentremove(3) should be able to remove empty directories (diff)
downloadwireguard-openbsd-2acecd74411762657c5fae5246919db82e7f476c.tar.xz
wireguard-openbsd-2acecd74411762657c5fae5246919db82e7f476c.zip
Verify that file pointer is writable
Diffstat (limited to 'lib/libc/stdio/fputc.c')
-rw-r--r--lib/libc/stdio/fputc.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/libc/stdio/fputc.c b/lib/libc/stdio/fputc.c
index b7630b1a3a1..ed6c256f5c9 100644
--- a/lib/libc/stdio/fputc.c
+++ b/lib/libc/stdio/fputc.c
@@ -35,14 +35,20 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char rcsid[] = "$OpenBSD: fputc.c,v 1.2 1996/08/19 08:32:42 tholo Exp $";
+static char rcsid[] = "$OpenBSD: fputc.c,v 1.3 1996/10/28 05:32:54 tholo Exp $";
#endif /* LIBC_SCCS and not lint */
#include <stdio.h>
+#include <errno.h>
+#include "local.h"
fputc(c, fp)
int c;
register FILE *fp;
{
+ if (cantwrite(fp)) {
+ errno = EBADF;
+ return (EOF);
+ }
return (putc(c, fp));
}