Subject: Re: garbage at sockaddr_in.sin_zero
To: Shin'ichiro TAYA <email@example.com>
From: None <firstname.lastname@example.org>
Date: 10/22/2000 03:20:42
sin_zero simply represents the padding of a sockaddr_in struct to fit the
same size as a sockaddr. Standard C union/struct tricks.
I don't have a posix reference handy but anything I've ever read on network
or C programming says to clear the structs before sending them. Anything else
is undefined behavior in your program.
See page 60 of Steven's 2nd edition network programming book for this as well
>Subject: Re: garbage at sockaddr_in.sin_zero
>Date: Sun, 22 Oct 2000 01:11:19 -0400 (EDT)
>> Your "in" var is an automatic variable. You can't depend on it being
>> zero'd out. So, garbage in, garbage out as far as the bind call goes.
>> bzero it first before setting values.
>I know why it fails and should clear whole structure before set each member.
>My question is:
>I set sin_family to AF_INET, so only sin_port & sin_addr should be meaningfull.
>But library or kernel is refering sin_zero.
>Is it a right behavor and is it documented in somewhere?
>I'm playing with PSM(Personal Security Manager) for mozilla.
>With PSM you can use SSL with mozilla.
>There is a bug like my sample code.
>I'm going to submit a fix for this(bzero(&in, sizeof(in))). But before
>submit, I want to clarify it's a bug of PSM code or bug of NetBSD.