[Date Prev][Date Next]
[Chronological]
[Thread]
[Top]
Re: bogus cast in daemon.c, breaks LDAPI (ITS#863)
You're right, I actually knew of this bug, there are some other
problems as well. These problems are fixed with the new code in
head. So we should either start using the code in head, or we
need to fix the bugs in daemon.c without doing any major changes.
If we do the latter, I'll have a look at it in a few days. Or could
you Jacques check? Are chmod and unlink done on the same file that
is used in the bind? I think there were some problems there.
The same error is repeated 7 and 8 lines further down.
I haven't got the time to test right now, but I think a fix
could be:
case AF_LOCAL: {
char *addr = ((struct sockaddr_un *)sai->ai_addr)->sun_path;
if ( chmod( addr, S_IRWXU ) < 0 ) {
int err = sock_errno();
Debug( LDAP_DEBUG_ANY, "daemon: fchmod(%ld) failed errno=%d (%s)",
(long) l.sl_sd, err, sock_errstr(err) );
tcp_close( l.sl_sd );
return NULL;
}
l.sl_name = ch_malloc( strlen(addr) + sizeof("PATH=") );
sprintf( l.sl_name, "PATH=%s", addr );
} break;
I think I like my way, but the first line could also be
char *addr = (char *)sai->ai_addr->sa_data;
which is like you suggest.
Stig