summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorThorsten Lockert <tholo@cvs.openbsd.org>1996-10-28 05:32:56 +0000
committerThorsten Lockert <tholo@cvs.openbsd.org>1996-10-28 05:32:56 +0000
commit22e7043adb0bc1aba7f6fd174346f76192f0b5f1 (patch)
treed63c29957244bbb9d5ca680e30acda4eac1e25b2 /lib
parentfafff148e10ab137d6494753a47905a2262a870d (diff)
Verify that file pointer is writable
Diffstat (limited to 'lib')
-rw-r--r--lib/libc/stdio/fputc.c8
-rw-r--r--lib/libc/stdio/putc.c8
2 files changed, 14 insertions, 2 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));
}
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));
}