openssh-portable segmentation faults

Dimitry Andric dim at
Fri Feb 8 21:46:20 UTC 2013

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

   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.

More information about the freebsd-ports mailing list