diff options
author | Lars Wirzenius <lars.wirzenius@codethink.co.uk> | 2014-09-30 10:17:05 +0100 |
---|---|---|
committer | Pedro Alvarez <pedro.alvarez@codethink.co.uk> | 2014-10-02 14:48:28 +0100 |
commit | 9b8eca5826cf32c790bbb1e1f8836dc1754a4ef9 (patch) | |
tree | 709c979a3147ef83f3b6179204fdc79798f67295 | |
parent | 626adf0eb70e059de498a01ab66864a45128c935 (diff) | |
download | definitions-9b8eca5826cf32c790bbb1e1f8836dc1754a4ef9.tar.gz |
xfer-hole: Fix bug in copy_slice_from_file.
os.read is limited to an int in size. copy_slice_from_file was trying
to os.read more than that causing an OverflowError.
-rwxr-xr-x | xfer-hole | 10 |
1 files changed, 8 insertions, 2 deletions
@@ -120,8 +120,14 @@ def make_xfer_instructions(fd): def copy_slice_from_file(to, fd, start, end): safe_lseek(fd, start, os.SEEK_SET) - data = os.read(fd, end - start) - to.write(data) + nbytes = end - start + max_at_a_time = 1024**2 + while nbytes > 0: + data = os.read(fd, min(nbytes, max_at_a_time)) + if not data: + break + to.write(data) + nbytes -= len(data) for kind, start, end in make_xfer_instructions(fd): |