skalibs

Mirror/fork of https://skarnet.org/software/skalibs/
git clone https://ccx.te2000.cz/git/skalibs
Log | Files | Refs | README | LICENSE

commit 13a62c4ac5feb8d3bc68346eb987bd04d05e3457
parent fa1c2eda11277a24770d7506aafd5e437c658d33
Author: Laurent Bercot <ska-skaware@skarnet.org>
Date:   Fri, 12 May 2017 00:49:46 +0000

 bugfix: error reporting in openreadclose

Diffstat:
Msrc/libstddjb/openreadnclose.c | 13+++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/src/libstddjb/openreadnclose.c b/src/libstddjb/openreadnclose.c @@ -7,11 +7,16 @@ static ssize_t readnclose (int fd, char *s, size_t n) { - ssize_t r = allread(fd, s, n) ; - int e = errno ; + size_t r = allread(fd, s, n) ; + if (errno) + { + int e = errno ; + fd_close(fd) ; + errno = e ; + return -1 ; + } fd_close(fd) ; - if ((r > 0) && (r < (ssize_t)n)) e = EPIPE ; - errno = e ; + if (r < n) errno = EPIPE ; return r ; }