Skip to content

Commit

Permalink
tls: if port is 0 in tls client profile cfg definition, ignore matchi…
Browse files Browse the repository at this point in the history
…ng port

- tcp port can be randomly allocated by OS, making hard to guess it in
  advance
  • Loading branch information
miconda committed Feb 24, 2015
1 parent 5e3880f commit 20d0a18
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 10 deletions.
2 changes: 1 addition & 1 deletion modules/tls/tls_domain.c
Expand Up @@ -1308,7 +1308,7 @@ tls_domain_t* tls_lookup_cfg(tls_domains_cfg_t* cfg, int type,
p->server_name.len, ZSW(p->server_name.s),
sname->len, ZSW(sname->s));
}
if ((p->port == port) && ip_addr_cmp(&p->ip, ip)) {
if ((p->port==0 || p->port == port) && ip_addr_cmp(&p->ip, ip)) {
if(sname && sname->len>0) {
if(p->server_name.len==sname->len
&& strncasecmp(p->server_name.s, sname->s, sname->len)==0) {
Expand Down
10 changes: 1 addition & 9 deletions modules/tls/tls_server.c
Expand Up @@ -196,16 +196,8 @@ static int tls_complete_init(struct tcp_connection* c)
} else {
state=S_TLS_CONNECTING;
sname = tls_get_connect_server_name();
if(&c->rcv.bind_address!=NULL) {
/* if there is a bind_address, use it, because the src port
* for connection can be randomly assigned by OS */
dom = tls_lookup_cfg(cfg, TLS_DOMAIN_CLI,
&c->rcv.bind_address->address,
c->rcv.bind_address->port_no, sname);
} else {
dom = tls_lookup_cfg(cfg, TLS_DOMAIN_CLI,
dom = tls_lookup_cfg(cfg, TLS_DOMAIN_CLI,
&c->rcv.dst_ip, c->rcv.dst_port, sname);
}
}
if (unlikely(c->state<0)) {
BUG("Invalid connection (state %d)\n", c->state);
Expand Down

0 comments on commit 20d0a18

Please sign in to comment.