fix multiple stdio functions' behavior on zero-length operations
authorRich Felker <dalias@aerifal.cx>
Fri, 5 Sep 2014 02:21:17 +0000 (22:21 -0400)
committerRich Felker <dalias@aerifal.cx>
Fri, 5 Sep 2014 02:21:17 +0000 (22:21 -0400)
commit6e2bb7acf42589fb7130b039d0623e2ca42503dd
tree7af4719cfa84bc8cf0c6fa73fdca42035eaf03e9
parent402611c3ba3be5b3b0486835d98e22ac7ced2722
fix multiple stdio functions' behavior on zero-length operations

previously, fgets, fputs, fread, and fwrite completely omitted locking
and access to the FILE object when their arguments yielded a zero
length read or write operation independent of the FILE state. this
optimization was invalid; it wrongly skipped marking the stream as
byte-oriented (a C conformance bug) and exposed observably missing
synchronization (a POSIX conformance bug) where one of these functions
could wrongly complete despite another thread provably holding the
lock.
src/stdio/fgets.c
src/stdio/fputs.c
src/stdio/fread.c
src/stdio/fwrite.c