forked from jengelh/openldap2
103 lines
2.6 KiB
Plaintext
103 lines
2.6 KiB
Plaintext
|
Index: openldap-2.4.7/servers/slapd/daemon.c
|
||
|
===================================================================
|
||
|
--- openldap-2.4.7.orig/servers/slapd/daemon.c
|
||
|
+++ openldap-2.4.7/servers/slapd/daemon.c
|
||
|
@@ -1120,7 +1120,8 @@ slap_get_listener_addresses(
|
||
|
{
|
||
|
#ifdef HAVE_GETADDRINFO
|
||
|
struct addrinfo hints, *res, *sai;
|
||
|
- int n, err;
|
||
|
+ struct sockaddr **sap2;
|
||
|
+ int n, err, cmpres;
|
||
|
char serv[7];
|
||
|
|
||
|
memset( &hints, '\0', sizeof(hints) );
|
||
|
@@ -1146,43 +1147,60 @@ slap_get_listener_addresses(
|
||
|
*sap = NULL;
|
||
|
|
||
|
for ( sai=res; sai; sai=sai->ai_next ) {
|
||
|
+ cmpres=1;
|
||
|
if( sai->ai_addr == NULL ) {
|
||
|
Debug( LDAP_DEBUG_ANY, "slap_get_listener_addresses: "
|
||
|
"getaddrinfo ai_addr is NULL?\n", 0, 0, 0 );
|
||
|
freeaddrinfo(res);
|
||
|
goto errexit;
|
||
|
}
|
||
|
-
|
||
|
- switch (sai->ai_family) {
|
||
|
-# ifdef LDAP_PF_INET6
|
||
|
- case AF_INET6:
|
||
|
- *sap = ch_malloc(sizeof(struct sockaddr_in6));
|
||
|
- if (*sap == NULL) {
|
||
|
- freeaddrinfo(res);
|
||
|
- goto errexit;
|
||
|
+ /* check for duplicates */
|
||
|
+ for ( sap2 = *sal; sap && *sap2; sap2++ ){
|
||
|
+ if ( sai->ai_family == (*sap2)->sa_family ) {
|
||
|
+ if (sai->ai_family == AF_INET6) {
|
||
|
+ cmpres = memcmp(sai->ai_addr, *sap2,
|
||
|
+ sizeof(struct sockaddr_in6));
|
||
|
+ } else if (sai->ai_family == AF_INET) {
|
||
|
+ cmpres = memcmp(sai->ai_addr, *sap2,
|
||
|
+ sizeof(struct sockaddr_in));
|
||
|
+ }
|
||
|
+ if (! cmpres ){
|
||
|
+ break;
|
||
|
+ }
|
||
|
}
|
||
|
- *(struct sockaddr_in6 *)*sap =
|
||
|
- *((struct sockaddr_in6 *)sai->ai_addr);
|
||
|
- break;
|
||
|
+ }
|
||
|
+ if (cmpres){
|
||
|
+ switch (sai->ai_family) {
|
||
|
+# ifdef LDAP_PF_INET6
|
||
|
+ case AF_INET6:
|
||
|
+ *sap = ch_malloc(sizeof(struct sockaddr_in6));
|
||
|
+ if (*sap == NULL) {
|
||
|
+ freeaddrinfo(res);
|
||
|
+ goto errexit;
|
||
|
+ }
|
||
|
+ *(struct sockaddr_in6 *)*sap =
|
||
|
+ *((struct sockaddr_in6 *)sai->ai_addr);
|
||
|
+ break;
|
||
|
# endif /* LDAP_PF_INET6 */
|
||
|
- case AF_INET:
|
||
|
- *sap = ch_malloc(sizeof(struct sockaddr_in));
|
||
|
- if (*sap == NULL) {
|
||
|
- freeaddrinfo(res);
|
||
|
- goto errexit;
|
||
|
+ case AF_INET:
|
||
|
+ *sap = ch_malloc(sizeof(struct sockaddr_in));
|
||
|
+ if (*sap == NULL) {
|
||
|
+ freeaddrinfo(res);
|
||
|
+ goto errexit;
|
||
|
+ }
|
||
|
+ *(struct sockaddr_in *)*sap =
|
||
|
+ *((struct sockaddr_in *)sai->ai_addr);
|
||
|
+ break;
|
||
|
+ default:
|
||
|
+ *sap = NULL;
|
||
|
+ break;
|
||
|
}
|
||
|
- *(struct sockaddr_in *)*sap =
|
||
|
- *((struct sockaddr_in *)sai->ai_addr);
|
||
|
- break;
|
||
|
- default:
|
||
|
- *sap = NULL;
|
||
|
- break;
|
||
|
- }
|
||
|
|
||
|
- if (*sap != NULL) {
|
||
|
- (*sap)->sa_family = sai->ai_family;
|
||
|
- sap++;
|
||
|
- *sap = NULL;
|
||
|
+ if (*sap != NULL) {
|
||
|
+ (*sap)->sa_family = sai->ai_family;
|
||
|
+ sap++;
|
||
|
+ *sap = NULL;
|
||
|
+ }
|
||
|
}
|
||
|
}
|
||
|
|