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: AS47066 71.19.144.0/20 X-Spam-Status: No, score=-1.2 required=3.0 tests=AWL,BAYES_00,FREEMAIL_FROM, FROM_STARTS_WITH_NUMS,MSGID_FROM_MTA_HEADER shortcircuit=no autolearn=no version=3.3.2 Path: news.gmane.org!not-for-mail From: Hleb Valoshka <375gnu@gmail.com> Newsgroups: gmane.comp.lang.ruby.raindrops.general Subject: Re: Re: [PATCH] Remove Scope IDs from IPv6 addresses. Date: Tue, 10 Sep 2013 22:57:33 +0300 Message-ID: References: <1378826261-10771-1-git-send-email-375gnu@gmail.com> <20130910183504.GA502@dcvr.yhbt.net> <20130910183630.GB502@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 1378843057 14102 80.91.229.3 (10 Sep 2013 19:57:37 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 10 Sep 2013 19:57:37 +0000 (UTC) To: raindrops@librelist.org Original-X-From: raindrops@librelist.org Tue Sep 10 21:57:41 2013 Return-path: Envelope-to: gclrrg-raindrops@m.gmane.org List-Archive: List-Help: List-Id: List-Post: List-Subscribe: List-Unsubscribe: Precedence: list Original-Sender: raindrops@librelist.org Xref: news.gmane.org gmane.comp.lang.ruby.raindrops.general:131 Archived-At: Received: from zedshaw2.xen.prgmr.com ([71.19.156.177]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1VJU4C-0001jx-U3 for gclrrg-raindrops@m.gmane.org; Tue, 10 Sep 2013 21:57:41 +0200 Received: from zedshaw2.xen.prgmr.com (unknown [IPv6:::1]) by zedshaw2.xen.prgmr.com (Postfix) with ESMTP id DB07873D9F for ; Tue, 10 Sep 2013 20:07:08 +0000 (UTC) On 9/10/13, Eric Wong wrote: >> + newaddr = strdup(addr); >> + if (newaddr == NULL) >> + perror("strdup"); > > We'll segfault on strchr below if we perrored above. If we continue > using strdup, I would just use ruby_strdup() (works on both MRI/rbx). I haven't use C for a long time, so I thought that strchr checks its args. > But I'd rather avoid *strdup entirely. This is unlikely to > remove, right? Frankly speaking I dislike functions similar to strdup(), because using them you should remember to call free(), sometimes in many places (or to use goto). But I'm unfamiliar with internal ruby api, so it was the only variant for me. BTW, is anything bad with that variant: char *newaddr = alloca(...); remove_scope_id(oldaddr, newaddr); > Perhaps something like this (totally untested, likely off-by-one errors) Ok, I'll test your code tomorrow.