svn commit: r311233 - head/contrib/netbsd-tests/fs/tmpfs

Juli Mallett juli at clockworksquid.com
Wed Jan 4 23:45:33 UTC 2017


On Wed, Jan 4, 2017 at 3:36 PM, Jilles Tjoelker <jilles at stack.nl> wrote:
> On Wed, Jan 04, 2017 at 02:46:36AM +0000, Ngie Cooper wrote:
>>   - Initialize .sun_len before passing it to strlcpy and bind.
> It would be better to avoid naming the non-portable sun_len field if it
> is just to make Coverity happy. I suggest initializing the structure
> with designated initializers or memset().
>
> Apart from that, the value for sun_len is wrong; it should be the length
> of the whole structure and not just the sun_path part. Fortunately, the
> field is ignored by bind(), which uses the addrlen parameter instead.

This is incorrect, too.  It's the length of the sockaddr_un header
plus the actual length of the pathname, not the available size of the
path field.  It's kind of awful that it's inconsistent with the other
sockaddr types, but that's the fun of sockaddr_un, to accommodate the
fact that the path name is naturally a variable-length field.  In
fact, the calculation here seems to be wrong, also; we have the
SUN_LEN macro in <sys/un.h> for a reason, and it's what the unix(4)
manpage suggests.  Of course, sun_len is sort of needlessly obscure
and in general it's best for us to fix anything which requires the
_len fields to be accurate, and to just ignore them :(


More information about the svn-src-all mailing list