X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=libraries%2Flibldap%2Fopen.c;h=ba10939975986ccb6ada670cffe923ac4ea3969f;hb=2a63c76d51ce542bfb0fd8691038731751a04862;hp=ec5011744a567e2537a89217eb12e6ccb6e6dada;hpb=6062cd9777bd2e1d9d99e5b3d5e25d0dab87f7ba;p=openldap diff --git a/libraries/libldap/open.c b/libraries/libldap/open.c index ec5011744a..ba10939975 100644 --- a/libraries/libldap/open.c +++ b/libraries/libldap/open.c @@ -1,7 +1,7 @@ /* $OpenLDAP$ */ /* This work is part of OpenLDAP Software . * - * Copyright 1998-2012 The OpenLDAP Foundation. + * Copyright 1998-2013 The OpenLDAP Foundation. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -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_" );