OSDN Git Service

Bug spotted by Roberto Foglietta: at EOF readall() should return count, not len.
authorRob Landley <rob@landley.net>
Fri, 18 Jul 2008 09:15:59 +0000 (04:15 -0500)
committerRob Landley <rob@landley.net>
Fri, 18 Jul 2008 09:15:59 +0000 (04:15 -0500)
lib/lib.c

index 8467f86..959cd46 100644 (file)
--- 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;
        }