sockaddr API question

Poul-Henning Kamp phk at phk.freebsd.dk
Mon Aug 5 07:05:15 UTC 2013


The theoretical variant of the question:
	Where the length of a sockaddr must be passed to an API,
	library or kernel, is it _always_ legal for the length to
	be larger than the relevant subtype of struct sockaddr ?

The practical variant of the question:
	Can I just use struct sockaddr_storage all over the place
	and give sizeof(struct sockaddr_storage) to sockaddr_len arguments ?

PS: Yes, I realize that there will be inefficiencies related to
moving more data than required, the question is only if it is safe,
not if it is a good idea.

-- 
Poul-Henning Kamp       | UNIX since Zilog Zeus 3.20
phk at FreeBSD.ORG         | TCP/IP since RFC 956
FreeBSD committer       | BSD since 4.3-tahoe
Never attribute to malice what can adequately be explained by incompetence.


More information about the freebsd-arch mailing list