diff options
author | Rob Landley <rob@landley.net> | 2011-12-28 13:01:12 -0600 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2011-12-28 13:01:12 -0600 |
commit | f265d04ab8214f4789a7ff971acba3d97b84a0e0 (patch) | |
tree | d2c943f2fe86681c21ffb1e87621a64061177c6d | |
parent | 9272a9dfbc9acb2b6201bb7556a523d56ff2c0f0 (diff) | |
download | toybox-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.c | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -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) |