Skip to content

Commit

Permalink
nat_traversal: use local variable for port and proto on keepalive res…
Browse files Browse the repository at this point in the history
…olve

- safe execution for those resolving functions expecting PROTO_NONE
- reported by Jason Penton, FS#491

(cherry picked from commit 0bbcbe8)
(cherry picked from commit b97ee87)
  • Loading branch information
miconda committed Jan 15, 2015
1 parent 74e5c23 commit 5b5044c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion modules/nat_traversal/nat_traversal.c
Expand Up @@ -1510,6 +1510,8 @@ send_keepalive(NAT_Contact *contact)
struct dest_info dst;
int nat_port, len;
str nat_ip;
unsigned short lport;
char lproto;

if (keepalive_params.from == NULL) {
if (contact->socket != last_socket) {
Expand Down Expand Up @@ -1554,7 +1556,9 @@ send_keepalive(NAT_Contact *contact)
ptr = strchr(nat_ip.s, ':');
nat_ip.len = ptr - nat_ip.s;
nat_port = strtol(ptr+1, NULL, 10);
hostent = sip_resolvehost(&nat_ip, NULL, NULL);
lport = 0;
lproto = PROTO_NONE;
hostent = sip_resolvehost(&nat_ip, &lport, &lproto);
hostent2su(&dst.to, hostent, 0, nat_port);
dst.proto=PROTO_UDP;
dst.send_sock=contact->socket;
Expand Down

0 comments on commit 5b5044c

Please sign in to comment.