Yahoo Groups archive

Milter-greylist

Index last updated: 2026-04-28 23:32 UTC

Message

Re: sync.c:local_addr() use

2005-03-26 by ranko_z

--- In milter-greylist@yahoogroups.com, manu@n... wrote:
> Ranko Zivojnovic <ranko@s...> wrote:
> 
> > Looking further through the code, I saw that local_addr()
function can
> > return three values: 1, 0 and -1, but it is used in the code as
"true" -
> > "false" kind of call:
> >    if(local_addr(...)) {
> >      ...
> >    }
> > 
> > Then I went back couple of days in my logs and found the following
> > error:
> > local_addr: bind failed: Bad file number
> (snip)
> > I did fix it localy to return 0 rather than -1, however I thought
I
> > should let you know of the issue and you might want to reconsider
the
> > use of local_addr() in a different way.
> 
> I think your fix just ignore if the address is local or not, and
force
> it to be non local. 
> 
> Here socket() returned a positive file descriptor, but it's still a
bad
> file descriptor. Bad file number is EBADF, right? Anyone used to
Solaris
> can comment on this?

True. bind() should have set errno to EADDRNOTAVAIL, however (here at
least) to me it _always_ gives EBADF, on both systems, so what I've
changed was:
  if (errno != EADDRNOTAVAIL)

to 
  if (errno != EADDRNOTAVAIL && errno != EBADF)

... in order to bypass the problem.

I did however further tests with regards to the behavior on Solaris
and in all the tests I did, errno was always set to EADDRNOTAVAIL as
it should. I could not reproduce (yet) the case outside sync.c code
where bind() would give me EBADF on a valid socket.

Something is really strange here...

R.

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.