diff --git a/src/jconf.c b/src/jconf.c index 769896c2..4f9d3371 100644 --- a/src/jconf.c +++ b/src/jconf.c @@ -62,14 +62,17 @@ free_addr(ss_addr_t *addr) } void -parse_addr(const char *str, ss_addr_t *addr) +parse_addr(const char *str_in, ss_addr_t *addr) { + if (str_in == NULL) return; + int ipv6 = 0, ret = -1, n = 0; char *pch; + char *str = strdup(str_in); struct cork_ip ip; if (cork_ip_init(&ip, str) != -1) { - addr->host = strdup(str); + addr->host = str; addr->port = NULL; return; } @@ -102,6 +105,8 @@ parse_addr(const char *str, ss_addr_t *addr) } addr->port = strdup(str + ret + 1); } + + free(str); } jconf_t * diff --git a/src/redir.c b/src/redir.c index ea29738c..a13da640 100644 --- a/src/redir.c +++ b/src/redir.c @@ -943,6 +943,9 @@ main(int argc, char **argv) if (plugin_opts == NULL) { plugin_opts = conf->plugin_opts; } + if (mode == TCP_ONLY) { + mode = conf->mode; + } if (mtu == 0) { mtu = conf->mtu; } @@ -1046,11 +1049,12 @@ main(int argc, char **argv) FATAL("failed to initialize ciphers"); // Setup proxy context - listen_ctx_t listen_ctx; + struct listen_ctx listen_ctx; + memset(&listen_ctx, 0, sizeof(struct listen_ctx)); listen_ctx.remote_num = remote_num; listen_ctx.remote_addr = ss_malloc(sizeof(struct sockaddr *) * remote_num); memset(listen_ctx.remote_addr, 0, sizeof(struct sockaddr *) * remote_num); - for (int i = 0; i < remote_num; i++) { + for (i = 0; i < remote_num; i++) { char *host = remote_addr[i].host; char *port = remote_addr[i].port == NULL ? remote_port : remote_addr[i].port; diff --git a/src/tunnel.c b/src/tunnel.c index dd56921e..8998a48e 100644 --- a/src/tunnel.c +++ b/src/tunnel.c @@ -755,7 +755,7 @@ main(int argc, char **argv) { "plugin-opts", required_argument, NULL, GETOPT_VAL_PLUGIN_OPTS }, { "reuse-port", no_argument, NULL, GETOPT_VAL_REUSE_PORT }, { "help", no_argument, NULL, GETOPT_VAL_HELP }, - { NULL, 0, NULL, 0} + { NULL, 0, NULL, 0 } }; opterr = 0; @@ -1055,10 +1055,10 @@ main(int argc, char **argv) int listenfd; listenfd = create_and_bind(local_addr, local_port); if (listenfd == -1) { - FATAL("bind() error:"); + FATAL("bind() error"); } if (listen(listenfd, SOMAXCONN) == -1) { - FATAL("listen() error:"); + FATAL("listen() error"); } setnonblocking(listenfd);