mirror of
https://github.com/shadowsocks/shadowsocks-libev.git
synced 2026-10-28 11:43:50 +00:00
Fix a potential issue in parse_addr
This commit is contained in:
+7
-2
@@ -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 *
|
||||
|
||||
+6
-2
@@ -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;
|
||||
|
||||
+3
-3
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user