]> git.sur5r.net Git - openldap/commitdiff
ITS#7583 Fix ldap_init_fd() for LDAP_PROTO_UDP
authorStef Walter <stefw@redhat.com>
Fri, 3 May 2013 07:20:14 +0000 (09:20 +0200)
committerHoward Chu <hyc@openldap.org>
Thu, 23 May 2013 19:40:09 +0000 (12:40 -0700)
ldap_init_fd() tried to handle UDP sockets but was missing
certain key pieces to make it work. Fill in the address and
set the UDP flag correctly.

libraries/libldap/open.c

index 24d8a41e0b30803b8577db64c8b7864edc4c641a..ba10939975986ccb6ada670cffe923ac4ea3969f 100644 (file)
@@ -268,6 +268,9 @@ ldap_init_fd(
        int rc;
        LDAP *ld;
        LDAPConn *conn;
+#ifdef LDAP_CONNECTIONLESS
+       ber_socklen_t   len;
+#endif
 
        *ldp = NULL;
        rc = ldap_create( &ld );
@@ -308,6 +311,15 @@ ldap_init_fd(
 
 #ifdef LDAP_CONNECTIONLESS
        case LDAP_PROTO_UDP:
+               LDAP_IS_UDP(ld) = 1;
+               if( ld->ld_options.ldo_peer )
+                       ldap_memfree( ld->ld_options.ldo_peer );
+               ld->ld_options.ldo_peer = ldap_memalloc( sizeof( struct sockaddr ) );
+               len = sizeof( struct sockaddr );
+               if( getpeername ( fd, ld->ld_options.ldo_peer, &len ) < 0) {
+                       ldap_unbind_ext( ld, NULL, NULL );
+                       return( AC_SOCKET_ERROR );
+               }
 #ifdef LDAP_DEBUG
                ber_sockbuf_add_io( conn->lconn_sb, &ber_sockbuf_io_debug,
                        LBER_SBIOD_LEVEL_PROVIDER, (void *)"udp_" );