diff options
author | Rob Landley <rob@landley.net> | 2008-07-18 04:15:59 -0500 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2008-07-18 04:15:59 -0500 |
commit | 15b231591d3e95d502b2cee1d7d6192177230c15 (patch) | |
tree | 7bc8604defa380e0b394ee49b1d67572009c835f | |
parent | 2bfaaf25614985ada5490d08e005b36f948d8186 (diff) | |
download | toybox-15b231591d3e95d502b2cee1d7d6192177230c15.tar.gz |
Bug spotted by Roberto Foglietta: at EOF readall() should return count, not len.
-rw-r--r-- | lib/lib.c | 3 |
1 files changed, 2 insertions, 1 deletions
@@ -219,9 +219,10 @@ FILE *xfopen(char *path, char *mode) ssize_t readall(int fd, void *buf, size_t len) { size_t count = 0; + while (count<len) { int i = read(fd, buf+count, len-count); - if (!i) return len; + if (!i) break; if (i<0) return i; count += i; } |