aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2011-12-28 13:01:12 -0600
committerRob Landley <rob@landley.net>2011-12-28 13:01:12 -0600
commitf265d04ab8214f4789a7ff971acba3d97b84a0e0 (patch)
treed2c943f2fe86681c21ffb1e87621a64061177c6d
parent9272a9dfbc9acb2b6201bb7556a523d56ff2c0f0 (diff)
downloadtoybox-f265d04ab8214f4789a7ff971acba3d97b84a0e0.tar.gz
Bugfix (spotted by Nathan McSween): xread can't detect <0 if the return type is stored in an unsigned variable.
-rw-r--r--lib/lib.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/lib.c b/lib/lib.c
index 8e557a8a..82e32aee 100644
--- a/lib/lib.c
+++ b/lib/lib.c
@@ -246,10 +246,10 @@ ssize_t writeall(int fd, void *buf, size_t len)
// Die if there's an error other than EOF.
size_t xread(int fd, void *buf, size_t len)
{
- len = read(fd, buf, len);
- if (len < 0) perror_exit("xread");
+ ssize_t ret = read(fd, buf, len);
+ if (ret < 0) perror_exit("xread");
- return len;
+ return ret;
}
void xreadall(int fd, void *buf, size_t len)