summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdio/fvwrite.c
diff options
context:
space:
mode:
authortholo <tholo@openbsd.org>1996-10-26 06:58:58 +0000
committertholo <tholo@openbsd.org>1996-10-26 06:58:58 +0000
commit4eeaa86e7e174943a727c537bf918959ccb96bc5 (patch)
treebf72f3e30dbdc0c0c56eeb6138a45668b3322933 /lib/libc/stdio/fvwrite.c
parentDefine _POSIX_VDISABLE as (0377), not '\377' (diff)
downloadwireguard-openbsd-4eeaa86e7e174943a727c537bf918959ccb96bc5.tar.xz
wireguard-openbsd-4eeaa86e7e174943a727c537bf918959ccb96bc5.zip
Set errno when trying to write to a read-only stream
Diffstat (limited to 'lib/libc/stdio/fvwrite.c')
-rw-r--r--lib/libc/stdio/fvwrite.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/libc/stdio/fvwrite.c b/lib/libc/stdio/fvwrite.c
index 029e8b184ca..aa4108b16a1 100644
--- a/lib/libc/stdio/fvwrite.c
+++ b/lib/libc/stdio/fvwrite.c
@@ -35,7 +35,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char rcsid[] = "$OpenBSD: fvwrite.c,v 1.2 1996/08/19 08:32:49 tholo Exp $";
+static char rcsid[] = "$OpenBSD: fvwrite.c,v 1.3 1996/10/26 06:58:58 tholo Exp $";
#endif /* LIBC_SCCS and not lint */
#include <stdio.h>
@@ -63,8 +63,10 @@ __sfvwrite(fp, uio)
if ((len = uio->uio_resid) == 0)
return (0);
/* make sure we can write */
- if (cantwrite(fp))
+ if (cantwrite(fp)) {
+ errno = EBADF;
return (EOF);
+ }
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define COPY(n) (void)memcpy((void *)fp->_p, (void *)p, (size_t)(n))