From: Zdeněk Šustr Date: Wed, 6 Mar 2013 09:44:11 +0000 (+0000) Subject: - Notification client can bind to addresses specified by hostname (Fixes SB #100721) X-Git-Url: http://scientific.zcu.cz/git/?a=commitdiff_plain;h=f8d8f7d017aaeb013e0738e8c92620882ebb5e51;p=jra1mw.git - Notification client can bind to addresses specified by hostname (Fixes SB #100721) - Conservative solution: hostname resolution is done multiple times by the client. - Notification client recognizes square brackets enclosing host address in endpoint specification --- diff --git a/org.glite.lb.client/src/notification.c b/org.glite.lb.client/src/notification.c index b20663d..ff20bbb 100644 --- a/org.glite.lb.client/src/notification.c +++ b/org.glite.lb.client/src/notification.c @@ -90,7 +90,12 @@ static void get_name_and_port(const char *address, char **name, int *port) *port = atoi(p+1); *p = 0; } - *name = strdup(n); + if (p = strrchr(n, '[')) { + int len = strcspn(p+1, "]"); + *name = (char*)malloc(sizeof(char*) * (len+1)); + strncpy(*name, p+1, len); + } + else *name = strdup(n); free(n); } @@ -102,7 +107,7 @@ static int daemon_listen(edg_wll_Context ctx, const char *name, char *port, int int gaie; memset (&hints, '\0', sizeof (hints)); - hints.ai_flags = AI_NUMERICHOST | AI_NUMERICSERV | AI_PASSIVE | AI_ADDRCONFIG; + hints.ai_flags = AI_NUMERICSERV | AI_PASSIVE | AI_ADDRCONFIG; hints.ai_socktype = SOCK_STREAM; hints.ai_family = AF_INET6;