[前][次][番号順一覧][スレッド一覧]

ruby-changes:16464

From: akr <ko1@a...>
Date: Sun, 27 Jun 2010 13:30:54 +0900 (JST)
Subject: [ruby-changes:16464] Ruby:r28450 (trunk, ruby_1_9_2): * io.c (simple_sendfile): don't try to send data more than SSIZE_MAX

akr	2010-06-27 13:30:31 +0900 (Sun, 27 Jun 2010)

  New Revision: 28450

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=28450

  Log:
    * 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]

  Modified files:
    branches/ruby_1_9_2/ChangeLog
    branches/ruby_1_9_2/io.c
    trunk/ChangeLog
    trunk/io.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 28449)
+++ ChangeLog	(revision 28450)
@@ -1,3 +1,9 @@
+Sun Jun 27 13:25:07 2010  Tanaka Akira  <akr@f...>
+
+	* 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]
+
 Sun Jun 27 10:41:38 2010  Nobuyoshi Nakada  <nobu@r...>
 
 	* lib/rubygems/require_paths_builder.rb (write_require_paths_file_if_needed):
Index: io.c
===================================================================
--- io.c	(revision 28449)
+++ io.c	(revision 28450)
@@ -8078,9 +8078,14 @@
 #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
Index: ruby_1_9_2/ChangeLog
===================================================================
--- ruby_1_9_2/ChangeLog	(revision 28449)
+++ ruby_1_9_2/ChangeLog	(revision 28450)
@@ -1,3 +1,9 @@
+Sun Jun 27 13:25:07 2010  Tanaka Akira  <akr@f...>
+
+	* 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]
+
 Sun Jun 27 10:41:38 2010  Nobuyoshi Nakada  <nobu@r...>
 
 	* lib/rubygems/require_paths_builder.rb (write_require_paths_file_if_needed):
Index: ruby_1_9_2/io.c
===================================================================
--- ruby_1_9_2/io.c	(revision 28449)
+++ ruby_1_9_2/io.c	(revision 28450)
@@ -8068,9 +8068,14 @@
 #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

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]