From d53a5b6c559c0e5864d40dbca5317ac5bb8ce93f Mon Sep 17 00:00:00 2001 From: Hiten Pandya Date: Tue, 8 Jun 2004 04:04:11 +0000 Subject: [PATCH] If handed a bad file pointer that we can't write to, set the errno value to EBADF in order to get SUSv2 conformant behavior in higher level calls like fputs() and puts(). Obtained-from: FreeBSD (HEAD) --- lib/libc/stdio/fvwrite.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/libc/stdio/fvwrite.c b/lib/libc/stdio/fvwrite.c index 4021768d9e..2623dd0e03 100644 --- a/lib/libc/stdio/fvwrite.c +++ b/lib/libc/stdio/fvwrite.c @@ -35,9 +35,10 @@ * * @(#)fvwrite.c 8.1 (Berkeley) 6/4/93 * $FreeBSD: src/lib/libc/stdio/fvwrite.c,v 1.10 1999/08/28 00:01:06 peter Exp $ - * $DragonFly: src/lib/libc/stdio/fvwrite.c,v 1.4 2004/06/07 20:35:41 hmp Exp $ + * $DragonFly: src/lib/libc/stdio/fvwrite.c,v 1.5 2004/06/08 04:04:11 hmp Exp $ */ +#include #include #include #include @@ -63,8 +64,10 @@ __sfvwrite(FILE *fp, struct __suio *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)) -- 2.41.0