From owner-freebsd-ports@FreeBSD.ORG Fri Feb 8 21:46:20 2013 Return-Path: Delivered-To: ports@FreeBSD.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 9B98151B; Fri, 8 Feb 2013 21:46:20 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from tensor.andric.com (tensor.andric.com [IPv6:2001:7b8:3a7:1:2d0:b7ff:fea0:8c26]) by mx1.freebsd.org (Postfix) with ESMTP id 4446E2A3; Fri, 8 Feb 2013 21:46:20 +0000 (UTC) Received: from [192.168.0.6] (spaceball.home.andric.com [192.168.0.6]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by tensor.andric.com (Postfix) with ESMTPSA id 3CEE25C43; Fri, 8 Feb 2013 22:46:18 +0100 (CET) Message-ID: <5115722A.3050400@FreeBSD.org> Date: Fri, 08 Feb 2013 22:46:18 +0100 From: Dimitry Andric Organization: The FreeBSD Project User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:19.0) Gecko/20130117 Thunderbird/19.0 MIME-Version: 1.0 To: Konstantin Belousov Subject: Re: openssh-portable segmentation faults References: <67A39057348F4D1BA43004DB5F0E8DBB@white> <5113B343.303@FreeBSD.org> <511435D8.8000900@FreeBSD.org> <20130207232853.GO2522@kib.kiev.ua> In-Reply-To: <20130207232853.GO2522@kib.kiev.ua> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: ports@FreeBSD.org, Brooks Davis , Bryan Drewery , Dewayne Geraghty X-BeenThere: freebsd-ports@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Porting software to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Feb 2013 21:46:20 -0000 On 2013-02-08 00:28, Konstantin Belousov wrote: > On Fri, Feb 08, 2013 at 12:16:40AM +0100, Dimitry Andric wrote: ... >> I guess a similar approach as take in the above thread should be taken, >> e.g. rename the function in the port to openbsd_strnvis(), and have the >> port call that. Or use macro trickery to swap the arguments... :) > > I suggest taking a reverse approach, and rename our libc function to > e.g. NetBSD_strnvis(). This way, at least linking binaries would > result in the build-time failure. For shared libraries, we also get > some semi-helpful message from rtld which would allow to identify > the problem without obtaining the backtrace. Anyway, the porter will > see the issue cleanly. > > This should be done before merging the libc changes to stable. The merge to stable/9 was already done in r245439. :-/ Unfortunately, this function is not standardized, but at first sight, the NetBSD prototype: int strnvis(char *dst, size_t dlen, const char *src, int flag); is more logical than the OpenBSD prototype: int strnvis(char *dst, const char *src, size_t siz, int flag) because the 'siz' argument is really the length of 'dst'. On the other hand, OpenBSD added this function in 2000, while NetBSD was late to the party in 2011... :) That said, it is possible the semantics of the NetBSD implementation are subtly different from what OpenSSH expects, so it is safer to let the port use its own implementation anyway. The question is also how many third-party software uses strnvis(), and what the prevalent expectation is about the argument order. If most external software expects the OpenBSD order, it would be better to use that instead.