aboutsummaryrefslogtreecommitdiff
path: root/lib/lib.c
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2008-07-18 04:15:59 -0500
committerRob Landley <rob@landley.net>2008-07-18 04:15:59 -0500
commit15b231591d3e95d502b2cee1d7d6192177230c15 (patch)
tree7bc8604defa380e0b394ee49b1d67572009c835f /lib/lib.c
parent2bfaaf25614985ada5490d08e005b36f948d8186 (diff)
downloadtoybox-15b231591d3e95d502b2cee1d7d6192177230c15.tar.gz
Bug spotted by Roberto Foglietta: at EOF readall() should return count, not len.
Diffstat (limited to 'lib/lib.c')
-rw-r--r--lib/lib.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/lib.c b/lib/lib.c
index 8467f866..959cd46c 100644
--- a/lib/lib.c
+++ b/lib/lib.c
@@ -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;
}