r1.18 of rdist/docmd.c changed
while ((len = read(fd, buf, sizeof(buf))) != (size_t)-1)
to
while ((len = read(fd, buf, sizeof(buf))) > 0)
when fixing PR#5009. Which allowed detection of a return value of 0,
i.e. end of file. However len is size_t and thus does not grok -1
and the test would now seem unable to detect the error return
value. :-)
I took out the (void) just so the use of len is shown. Passing
ssize_t to the size_t parameter of fwrite() seems safe.
If there is a better idiom for this, let me know.
.... Ken
Index: docmd.c
===================================================================
RCS file: /cvs/src/usr.bin/rdist/docmd.c,v
retrieving revision 1.22
diff -u -p -r1.22 docmd.c
--- docmd.c 10 Apr 2011 15:47:28 -0000 1.22
+++ docmd.c 18 Apr 2011 13:03:46 -0000
@@ -94,7 +94,7 @@ static void
notify(char *rhost, struct namelist *to, time_t lmod)
{
int fd;
- size_t len;
+ ssize_t len;
FILE *pf;
struct stat stb;
static char buf[BUFSIZ];
@@ -180,7 +180,7 @@ notify(char *rhost, struct namelist *to,
(void) fprintf(pf, "Options: %s\n\n", getondistoptlist(options));
while ((len = read(fd, buf, sizeof(buf))) > 0)
- (void) fwrite(buf, 1, len, pf);
+ fwrite(buf, 1, len, pf);
(void) pclose(pf);
(void) close(fd);