const char *end;
char *file;
int fd;
- ssize_t count;
+ ssize_t rc, count = 0;
if (!out_len)
goto err_out;
goto err_free_out;
if (out) {
- count = read(fd, out, out_len);
- if (count == -1)
- goto err_free_close_out;
+ while (1) {
+ rc = read(fd, out, out_len - count);
+ if (rc == 0)
+ break;
+ if (rc == -1)
+ goto err_free_close_out;
+
+ count += rc;
+ out += rc;
+ }
} else {
count = lseek(fd, 0, SEEK_END);
if (count == -1)