From 845fcbc891d8254f64c0000ba1af87f2de17eda3 Mon Sep 17 00:00:00 2001 From: Nikos Mavrogiannopoulos Date: Fri, 18 Sep 2015 14:37:48 +0200 Subject: [PATCH] forward all routes sent to client to occtl --- src/main-ctl-unix.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/main-ctl-unix.c b/src/main-ctl-unix.c index b5e4b64b..c0d41887 100644 --- a/src/main-ctl-unix.c +++ b/src/main-ctl-unix.c @@ -392,20 +392,22 @@ static int append_user_info(method_ctx *ctx, rep->n_nbns = ctx->s->config->network.nbns_size; } - if (ctmp->config.routes_size > 0) { - rep->routes = ctmp->config.routes; - rep->n_routes = ctmp->config.routes_size; + rep->n_routes = ctmp->config.routes_size + ctx->s->config->network.routes_size; + rep->routes = talloc_size(rep, sizeof(char*)*rep->n_routes); + if (rep->routes != NULL) { + memcpy(rep->routes, ctmp->config.routes, sizeof(char*)*ctmp->config.routes_size); + memcpy(&rep->routes[ctmp->config.routes_size], ctx->s->config->network.routes, sizeof(char*)*ctx->s->config->network.routes_size); } else { - rep->routes = ctx->s->config->network.routes; - rep->n_routes = ctx->s->config->network.routes_size; + rep->n_routes = 0; } - if (ctmp->config.no_routes_size > 0) { - rep->no_routes = ctmp->config.no_routes; - rep->n_no_routes = ctmp->config.no_routes_size; + rep->n_no_routes = ctmp->config.no_routes_size + ctx->s->config->network.no_routes_size; + rep->no_routes = talloc_size(rep, sizeof(char*)*rep->n_no_routes); + if (rep->no_routes != NULL) { + memcpy(rep->no_routes, ctmp->config.no_routes, sizeof(char*)*ctmp->config.no_routes_size); + memcpy(&rep->no_routes[ctmp->config.no_routes_size], ctx->s->config->network.no_routes, sizeof(char*)*ctx->s->config->network.no_routes_size); } else { - rep->no_routes = ctx->s->config->network.no_routes; - rep->n_no_routes = ctx->s->config->network.no_routes_size; + rep->n_no_routes = 0; } if (ctmp->config.iroutes_size > 0) {