Subject: Re: Use of sun_len in AF_UNIX socket addresses
To: None <tech-net@NetBSD.org>
From: Christian Biere <christianbiere@gmx.de>
List: tech-net
Date: 10/18/2006 18:47:12
SODA Noriyuki wrote:
> >>>>> On Wed, 11 Oct 2006 23:24:12 +0200,
>       Christian Biere <christianbiere@gmx.de> said:
> Is the latest version of the unix(4) man page OK for you?

Yes, it's fine by me. It seems you want to ignore the case of
overlong paths but I don't mind since it's non-portable.

> Or, perhaps you want to add something like the following code fragment
> in some section like PORTABILITY ISSUE?
> 	On systems which don't have the SUN_LEN() macro,
> 	the following definition is recommended,
> 	since using strlen((su)->sun_path) like our native SUN_LEN()
> 	implementation truncates the path on IRIX.
> 
> 	#ifndef SUN_LEN
> 	#define SUN_LEN(su)	sizeof(struct(sockaddr_un))
> 	#endif
> But this sort of description may be too much for a man page....

I'd appreciate it. I don't think there can be too much documentation
unless it starts repeating itself. I also appreciate the "EXAMPLE"
section of other manpages like strlcpy(3), strncpy(3) etc. because
these are truly essential.

> Maybe we should change the strlcpy() line as you said in lib/34744,
> though. e.g.
> 	if (strlcpy(sunx.sun_path, THE_PATH, sizeof(sunx.sun_path)) >=
> 	    sizeof(sunx.sun_path))
> 		errx(EXIT_FAILURE, "%s: too long socket name", THE_PATH);

I'd prefer this as well. Albeit as said I'd use strlen() and strncpy()
because for some people (not me), copying or implementing strlcpy()
seems to be unthinkable.

-- 
Christian