diff options
author | A. Wilcox <AWilcox@Wilcox-Tech.com> | 2019-03-12 15:31:22 -0500 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2019-03-12 16:44:41 -0400 |
commit | 00d3d577cac8dc05e683b16bfe3dbe4a692cb172 (patch) | |
tree | b57a62996a5ac8d994f0d04feca2f993c77aa047 | |
parent | f368d9fd26ae002fe2fce20add4cb2b806f48972 (diff) | |
download | musl-00d3d577cac8dc05e683b16bfe3dbe4a692cb172.tar.gz |
setvbuf: return failure if mode is invalid
POSIX requires setvbuf to return non-zero if `mode` is not one of _IONBF,
_IOLBF, or _IOFBF.
-rw-r--r-- | src/stdio/setvbuf.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/stdio/setvbuf.c b/src/stdio/setvbuf.c index 06ea296c..523dddc8 100644 --- a/src/stdio/setvbuf.c +++ b/src/stdio/setvbuf.c @@ -12,13 +12,15 @@ int setvbuf(FILE *restrict f, char *restrict buf, int type, size_t size) if (type == _IONBF) { f->buf_size = 0; - } else { + } else if (type == _IOLBF || type == _IOFBF) { if (buf && size >= UNGET) { f->buf = (void *)(buf + UNGET); f->buf_size = size - UNGET; } if (type == _IOLBF && f->buf_size) f->lbf = '\n'; + } else { + return -1; } f->flags |= F_SVB; |