summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorManuel Novoa III <mjn3@codepoet.org>2001-07-25 21:01:10 +0000
committerManuel Novoa III <mjn3@codepoet.org>2001-07-25 21:01:10 +0000
commit5838c4acc08947c7bf643afcef12726899edc004 (patch)
treeb12ce55e5351924696cf37c6d534afa84ce5ae2e
parente696b81beae7ec2440dfdf235b7439ae5c4ee874 (diff)
Fix fread bug reported by Vodz. The fix is straightforward, but I haven't
tested it (lack of time).
-rw-r--r--libc/stdio/stdio.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/libc/stdio/stdio.c b/libc/stdio/stdio.c
index a42750832..d6c950fd0 100644
--- a/libc/stdio/stdio.c
+++ b/libc/stdio/stdio.c
@@ -423,17 +423,19 @@ off_t _uClibc_fread(unsigned char *buf, off_t bytes, FILE *fp)
goto FROM_BUF;
}
- TRY_READ:
- len = read(fp->fd, p, (unsigned) bytes);
- if (len < 0) {
- if (errno == EINTR) { /* We were interrupted, so try again. */
- goto TRY_READ;
- }
- fp->mode |= __MODE_ERR;
- } else {
- p += len;
- if (len == 0) {
- fp->mode |= __MODE_EOF;
+ while (bytes) {
+ if ((len = read(fp->fd, p, (unsigned) bytes)) < 0) {
+ if (errno != EINTR) { /* We weren't interrupted, so error. */
+ fp->mode |= __MODE_ERR;
+ break;
+ }
+ } else {
+ if (len == 0) {
+ fp->mode |= __MODE_EOF;
+ break;
+ }
+ bytes -= len;
+ p += len;
}
}
}