From 8b89f59929d1cde44f2f67bc413e7f252a774615 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Franti=C5=A1ek=20Dvo=C5=99=C3=A1k?= Date: Thu, 19 Aug 2010 17:43:26 +0000 Subject: [PATCH] Backport port extraction fixes. --- org.glite.lb.client/src/dump.c | 2 +- org.glite.lb.client/src/load.c | 2 +- org.glite.lb.client/src/notification.c | 2 +- org.glite.lb.client/src/perftest_jobreg.c | 2 +- org.glite.lb.client/src/purge.c | 2 +- org.glite.lb.common/src/lb_perftest.c | 2 +- org.glite.lb.common/src/param.c | 4 ++-- org.glite.lb.logger/src/event_queue.c | 2 +- org.glite.lb.server/src/notif_match.c | 2 +- org.glite.lb.server/src/notification.c | 10 ++++++---- 10 files changed, 16 insertions(+), 14 deletions(-) diff --git a/org.glite.lb.client/src/dump.c b/org.glite.lb.client/src/dump.c index b561aa9..f215f55 100644 --- a/org.glite.lb.client/src/dump.c +++ b/org.glite.lb.client/src/dump.c @@ -140,7 +140,7 @@ int main(int argc,char *argv[]) edg_wll_InitContext(&ctx); if ( server ) { - char *p = strchr(server, ':'); + char *p = strrchr(server, ':'); if ( p ) { edg_wll_SetParam(ctx, EDG_WLL_PARAM_QUERY_SERVER_PORT, atoi(p+1)); diff --git a/org.glite.lb.client/src/load.c b/org.glite.lb.client/src/load.c index ed71a4c..b5b6d42 100644 --- a/org.glite.lb.client/src/load.c +++ b/org.glite.lb.client/src/load.c @@ -112,7 +112,7 @@ int main(int argc,char *argv[]) edg_wll_InitContext(&ctx); if ( server ) { - char *p = strchr(server, ':'); + char *p = strrchr(server, ':'); if ( p ) { edg_wll_SetParam(ctx, EDG_WLL_PARAM_QUERY_SERVER_PORT, atoi(p+1)); diff --git a/org.glite.lb.client/src/notification.c b/org.glite.lb.client/src/notification.c index 017240f..e02ff93 100644 --- a/org.glite.lb.client/src/notification.c +++ b/org.glite.lb.client/src/notification.c @@ -81,7 +81,7 @@ static void get_name_and_port(const char *address, char **name, int *port) char *n = NULL, *p; n = strdup(address); - p = strchr(n, ':'); + p = strrchr(n, ':'); if (p) { *port = atoi(p+1); diff --git a/org.glite.lb.client/src/perftest_jobreg.c b/org.glite.lb.client/src/perftest_jobreg.c index 3d863a3..344041a 100644 --- a/org.glite.lb.client/src/perftest_jobreg.c +++ b/org.glite.lb.client/src/perftest_jobreg.c @@ -100,7 +100,7 @@ int main(int argc, char *argv[]) dprintf(("generating jobids...")); { char *name=server?server:strdup(PROXY_SERVER); - char *p = strchr(name,':'); + char *p = strrchr(name,':'); int port; if (p) { *p=0; port = atoi(p+1); } diff --git a/org.glite.lb.client/src/purge.c b/org.glite.lb.client/src/purge.c index 8e93e99..1c81a84 100644 --- a/org.glite.lb.client/src/purge.c +++ b/org.glite.lb.client/src/purge.c @@ -315,7 +315,7 @@ static int read_jobIds(const char *file, char ***jobs_out) fprintf(stderr, "Error reading file\n"); return 1; } - nl = strchr(buf,'\n'); + nl = strrchr(buf,'\n'); if (nl) *nl = 0; /* TODO: check if it is really jobId, e.g. by edg_wlc_JobIdParse() */ diff --git a/org.glite.lb.common/src/lb_perftest.c b/org.glite.lb.common/src/lb_perftest.c index c87f942..1e6532f 100644 --- a/org.glite.lb.common/src/lb_perftest.c +++ b/org.glite.lb.common/src/lb_perftest.c @@ -216,7 +216,7 @@ glite_wll_perftest_init(const char *host, { char *p; - p = strchr(host, ':'); + p = strrchr(host, ':'); if(p) *p = 0; dest_host = strdup(host); diff --git a/org.glite.lb.common/src/param.c b/org.glite.lb.common/src/param.c index cda46b4..20b598d 100644 --- a/org.glite.lb.common/src/param.c +++ b/org.glite.lb.common/src/param.c @@ -85,7 +85,7 @@ static int extract_port(edg_wll_ContextParam param,int dflt) { char *p = NULL,*s = mygetenv(param); - if (s) p = strchr(s,':'); + if (s) p = strrchr(s,':'); return p ? atoi(p+1) : dflt; } @@ -102,7 +102,7 @@ static char *extract_host(edg_wll_ContextParam param,const char *dflt) s = mygetenv(param); if (!s && !dflt) return NULL; s = strdup(s?s:dflt), - p = strchr(s,':'); + p = strrchr(s,':'); if (p) *p = 0; return s; } diff --git a/org.glite.lb.logger/src/event_queue.c b/org.glite.lb.logger/src/event_queue.c index fcfcfbc..2028b8f 100644 --- a/org.glite.lb.logger/src/event_queue.c +++ b/org.glite.lb.logger/src/event_queue.c @@ -27,7 +27,7 @@ event_queue_create(char *server_name) struct event_queue *eq; char *p; - p = strchr(server_name, ':'); + p = strrchr(server_name, ':'); if(p) *p++ = 0; diff --git a/org.glite.lb.server/src/notif_match.c b/org.glite.lb.server/src/notif_match.c index 3180751..61940ce 100644 --- a/org.glite.lb.server/src/notif_match.c +++ b/org.glite.lb.server/src/notif_match.c @@ -79,7 +79,7 @@ int edg_wll_NotifMatch(edg_wll_Context ctx, const edg_wll_JobStat *stat) free(ju); dest = strdup(jobc[1]); - if ( !(aux = strchr(dest, ':')) ) + if ( !(aux = strrchr(dest, ':')) ) { edg_wll_SetError(ctx, EINVAL, "Can't parse notification destination"); free(dest); diff --git a/org.glite.lb.server/src/notification.c b/org.glite.lb.server/src/notification.c index 787fa3c..b40cb6e 100644 --- a/org.glite.lb.server/src/notification.c +++ b/org.glite.lb.server/src/notification.c @@ -125,12 +125,13 @@ int edg_wll_NotifNewServer( { char *aux; - if ( !(aux = strchr(address_override, ':')) ) + if ( !(aux = strrchr(address_override, ':')) ) { edg_wll_SetError(ctx, EINVAL, "Addres overrirde not in format host:port"); goto cleanup; } - if ( !strncmp(address_override, "0.0.0.0", aux-address_override) ) + if ( !strncmp(address_override, "0.0.0.0", aux-address_override) || + !strncmp(address_override, "::", aux-address_override) ) trio_asprintf(&addr_s, "%s:%s", ctx->connections->serverConnection->peerName, aux+1); } @@ -228,12 +229,13 @@ int edg_wll_NotifBindServer( { char *aux; - if ( !(aux = strchr(address_override, ':')) ) + if ( !(aux = strrchr(address_override, ':')) ) { edg_wll_SetError(ctx, EINVAL, "Addres overrirde not in format host:port"); goto cleanup; } - if ( !strncmp(address_override, "0.0.0.0", aux-address_override) ) + if ( !strncmp(address_override, "0.0.0.0", aux-address_override) || + !strncmp(address_override, "::", aux-address_override) ) trio_asprintf(&addr_s, "%s:%s", ctx->connections->serverConnection->peerName, aux+1); } -- 1.8.2.3