aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2019-03-10 17:36:34 -0500
committerRob Landley <rob@landley.net>2019-03-10 17:36:34 -0500
commitbfd80bec14954ce2457d33dd4ce78903681c7a3a (patch)
tree347737d5b7ab38d9711f7f6bb139df7289a58605
parente9d3a2a38d4629b71de709335c22e4a9fde2ed45 (diff)
downloadtoybox-bfd80bec14954ce2457d33dd4ce78903681c7a3a.tar.gz
Make xsendfile() variants handle -1 length properly again.
-rw-r--r--lib/xwrap.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/xwrap.c b/lib/xwrap.c
index 25ec2a53..223356b3 100644
--- a/lib/xwrap.c
+++ b/lib/xwrap.c
@@ -809,7 +809,7 @@ long long sendfile_len(int in, int out, long long bytes)
len = bytes-total;
if (bytes<0 || len>sizeof(libbuf)) len = sizeof(libbuf);
- len = xread(in, libbuf, sizeof(libbuf)>(bytes-total));
+ len = xread(in, libbuf, len);
if (len<1) break;
xwrite(out, libbuf, len);
total += len;
@@ -823,7 +823,7 @@ long long xsendfile_len(int in, int out, long long bytes)
{
long long len = sendfile_len(in, out, bytes);
- if (bytes != len) error_exit("short file");
+ if (bytes != -1 && bytes != len) error_exit("short file");
return len;
}