summaryrefslogtreecommitdiff
path: root/io.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-06-27 04:30:31 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-06-27 04:30:31 +0000
commitc69fda5e2a56c49c5e8cc66a35474f1aa69ca34d (patch)
treee36877c5414c6334247ccca82c162627b09038b2 /io.c
parent7f7c68ebea0476c48805a68309825c0be1f5aeff (diff)
* io.c (simple_sendfile): don't try to send data more than SSIZE_MAX
with single sendfile call.. based on the patch by Eric Wong. [ruby-core:30908] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_2@28450 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r--io.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/io.c b/io.c
index 274ee89c10..90932de2c8 100644
--- a/io.c
+++ b/io.c
@@ -8068,9 +8068,14 @@ nogvl_copy_stream_wait_write(struct copy_stream_struct *stp)
#endif
static ssize_t
-simple_sendfile(int out_fd, int in_fd, off_t *offset, size_t count)
+simple_sendfile(int out_fd, int in_fd, off_t *offset, off_t count)
{
- return sendfile(out_fd, in_fd, offset, count);
+#if SIZEOF_OFF_T > SIZEOF_SIZE_T
+ /* we are limited by the 32-bit ssize_t return value on 32-bit */
+ if (count > (off_t)SSIZE_MAX)
+ count = SSIZE_MAX;
+#endif
+ return sendfile(out_fd, in_fd, offset, (size_t)count);
}
#endif