diff options
author | pfg <pfg@FreeBSD.org> | 2014-07-20 21:24:29 +0000 |
---|---|---|
committer | pfg <pfg@FreeBSD.org> | 2014-07-20 21:24:29 +0000 |
commit | 4116752e681819b04fba157cf62b81c7432011ee (patch) | |
tree | 7c1f5231a148a0b9e1489646eb32f94be3a5e8b7 /lib/libc | |
parent | d83317ec90360b529ba9e0ef55d6a089c2a0dfac (diff) | |
download | FreeBSD-src-4116752e681819b04fba157cf62b81c7432011ee.zip FreeBSD-src-4116752e681819b04fba157cf62b81c7432011ee.tar.gz |
Adjust errno on failed prepwrite.
Obtained from: Apple Inc. (Libc 997.90.3)
Phabric: D442
MFC after: 1 week
Diffstat (limited to 'lib/libc')
-rw-r--r-- | lib/libc/stdio/vfprintf.c | 4 | ||||
-rw-r--r-- | lib/libc/stdio/vfwprintf.c | 4 | ||||
-rw-r--r-- | lib/libc/stdio/wbuf.c | 5 |
3 files changed, 10 insertions, 3 deletions
diff --git a/lib/libc/stdio/vfprintf.c b/lib/libc/stdio/vfprintf.c index ea47d36..e54e8ac 100644 --- a/lib/libc/stdio/vfprintf.c +++ b/lib/libc/stdio/vfprintf.c @@ -455,8 +455,10 @@ __vfprintf(FILE *fp, locale_t locale, const char *fmt0, va_list ap) return (__xvprintf(fp, fmt0, ap)); /* sorry, fprintf(read_only_file, "") returns EOF, not 0 */ - if (prepwrite(fp) != 0) + if (prepwrite(fp) != 0) { + errno = EBADF; return (EOF); + } convbuf = NULL; fmt = (char *)fmt0; diff --git a/lib/libc/stdio/vfwprintf.c b/lib/libc/stdio/vfwprintf.c index 4350c48..b75c504 100644 --- a/lib/libc/stdio/vfwprintf.c +++ b/lib/libc/stdio/vfwprintf.c @@ -531,8 +531,10 @@ __vfwprintf(FILE *fp, locale_t locale, const wchar_t *fmt0, va_list ap) /* sorry, fwprintf(read_only_file, L"") returns WEOF, not 0 */ - if (prepwrite(fp) != 0) + if (prepwrite(fp) != 0) { + errno = EBADF; return (EOF); + } convbuf = NULL; fmt = (wchar_t *)fmt0; diff --git a/lib/libc/stdio/wbuf.c b/lib/libc/stdio/wbuf.c index 3f697e2..5bc3c4d 100644 --- a/lib/libc/stdio/wbuf.c +++ b/lib/libc/stdio/wbuf.c @@ -36,6 +36,7 @@ static char sccsid[] = "@(#)wbuf.c 8.1 (Berkeley) 6/4/93"; #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); +#include <errno.h> #include <stdio.h> #include "local.h" @@ -59,8 +60,10 @@ __swbuf(int c, FILE *fp) * calls might wrap _w from negative to positive. */ fp->_w = fp->_lbfsize; - if (prepwrite(fp) != 0) + if (prepwrite(fp) != 0) { + errno = EBADF; return (EOF); + } c = (unsigned char)c; ORIENT(fp, -1); |