Skip to content

Commit

Permalink
rtpproxy: fix ipv6 handling of timeout socket
Browse files Browse the repository at this point in the history
Reported by Dan Pascu on mailing list
  • Loading branch information
razvancrainea committed May 29, 2019
1 parent 566d8d4 commit 3e2aed0
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions modules/rtpproxy/timeout_process.c
Expand Up @@ -73,7 +73,7 @@ void timeout_listener_process(int rank)
struct sockaddr* saddr;
int len, i,n, left;
int optval = 1;
struct sockaddr rtpp_info;
struct sockaddr_storage rtpp_info;
struct rtpp_notify_node *rtpp_lst;
str terminate_reason = str_init("RTPProxy Timeout");
int offset = 0;
Expand Down Expand Up @@ -176,14 +176,14 @@ void timeout_listener_process(int rank)
if (pfds[0].revents & POLLIN) {
i = sizeof(rtpp_info);
memset(&rtpp_info, 0, i);
connect_fd = accept(socket_fd, &rtpp_info, (socklen_t *)&i);
connect_fd = accept(socket_fd, (struct sockaddr *)&rtpp_info, (socklen_t *)&i);
if(connect_fd < 0) {
LM_ERR("socket accept failed: %s(%d)\n", strerror(errno), errno);
continue;
}

/* if it is a unix socket, try to authenticate it */
if (rtpp_info.sa_family == AF_UNIX) {
if (((struct sockaddr *)&rtpp_info)->sa_family == AF_UNIX) {
s_un = (struct sockaddr_un*)&rtpp_info;
/* check if the socket is already opened */
lock_get(rtpp_notify_h->lock);
Expand Down Expand Up @@ -220,14 +220,14 @@ void timeout_listener_process(int rank)
}
} else {
/* search if I can find this connection */
if (rtpp_info.sa_family == AF_INET) {
if (((struct sockaddr *)&rtpp_info)->sa_family == AF_INET) {
s_in = (struct sockaddr_in*)&rtpp_info;
lock_get(rtpp_notify_h->lock);
for (rtpp_lst = rtpp_notify_h->rtpp_list; rtpp_lst; rtpp_lst = rtpp_lst->next)
if (rtpp_lst->mode == 1 && rtpp_lst->index == 0 &&
memcmp(rtpp_lst->addr, &s_in->sin_addr.s_addr, 4) == 0)
break;
} else if (rtpp_info.sa_family == AF_INET6) {
} else if (((struct sockaddr *)&rtpp_info)->sa_family == AF_INET6) {
s_in6 = (struct sockaddr_in6*)&rtpp_info;
lock_get(rtpp_notify_h->lock);
for (rtpp_lst = rtpp_notify_h->rtpp_list; rtpp_lst; rtpp_lst = rtpp_lst->next)
Expand All @@ -241,11 +241,11 @@ void timeout_listener_process(int rank)

if (!rtpp_lst) {
lock_release(rtpp_notify_h->lock);
if (rtpp_info.sa_family == AF_UNIX)
if (((struct sockaddr *)&rtpp_info)->sa_family == AF_UNIX)
p = ((struct sockaddr_un*)&rtpp_info)->sun_path;
else {
struct ip_addr ip;
sockaddr2ip_addr(&ip, &rtpp_info);
sockaddr2ip_addr(&ip, (struct sockaddr *)&rtpp_info);
p = ip_addr2a(&ip); \
}
LM_DBG("unknown rtpproxy %s -- ignoring\n", p);
Expand Down

0 comments on commit 3e2aed0

Please sign in to comment.