From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS6939 64.71.128.0/18 X-Spam-Status: No, score=-1.9 required=3.0 tests=AWL,BAYES_00, MSGID_FROM_MTA_HEADER shortcircuit=no autolearn=unavailable version=3.3.2 Path: news.gmane.org!not-for-mail From: Eric Wong Newsgroups: gmane.comp.lang.ruby.io-splice.general Subject: [PATCH] vmsplice: avoid referencing invalid stack address for strings Date: Sat, 19 Jan 2013 04:54:07 +0000 Message-ID: <20130119045407.GA3433@dcvr.yhbt.net> References: <20130119045407.GA3433@dcvr.yhbt.net> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1358571272 31328 80.91.229.3 (19 Jan 2013 04:54:32 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 19 Jan 2013 04:54:32 +0000 (UTC) To: ruby.io.splice@librelist.org Original-X-From: ruby.io.splice@librelist.org Sat Jan 19 05:54:50 2013 Return-path: Envelope-to: gclrig-ruby.io.splice@m.gmane.org In-Reply-To: <20130119045407.GA3433@dcvr.yhbt.net> List-Archive: List-Help: List-Id: List-Post: List-Subscribe: List-Unsubscribe: Precedence: list Original-Sender: ruby.io.splice@librelist.org Xref: news.gmane.org gmane.comp.lang.ruby.io-splice.general:35 Archived-At: Received: from zedshaw.xen.prgmr.com ([64.71.167.205]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1TwQS7-00089A-JS for gclrig-ruby.io.splice@m.gmane.org; Sat, 19 Jan 2013 05:54:47 +0100 Received: from zedshaw.xen.prgmr.com (localhost [IPv6:::1]) by zedshaw.xen.prgmr.com (Postfix) with ESMTP id E2BBA21FE9E for ; Sat, 19 Jan 2013 05:07:36 +0000 (UTC) Newer GCC more aggressively optimizes stack allocations away, so we need to avoid passing out-of-scope addresses to vmsplice. Not that vmsplice is useful in Ruby... --- pushed to "master" of git://bogomips.org/ruby_io_splice ext/io_splice/io_splice_ext.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/ext/io_splice/io_splice_ext.c b/ext/io_splice/io_splice_ext.c index 32de838..876d07d 100644 --- a/ext/io_splice/io_splice_ext.c +++ b/ext/io_splice/io_splice_ext.c @@ -492,19 +492,18 @@ static VALUE my_vmsplice(int argc, VALUE * argv, VALUE self) ssize_t rv = 0; ssize_t left; struct vmsplice_args a; + struct iovec iov; + VALUE io, data, flags; rb_scan_args(argc, argv, "21", &io, &data, &flags); switch (TYPE(data)) { - case T_STRING: { - struct iovec iov; - + case T_STRING: iov.iov_base = RSTRING_PTR(data); iov.iov_len = (size_t)(left = (ssize_t)RSTRING_LEN(data)); a.iov = &iov; a.nr_segs = 1; - } break; case T_ARRAY: ARY2IOVEC(a.iov, a.nr_segs, left, data); -- Eric Wong