From 464cf74c7321069b51c10f0c37f19ba16c2e7138 Mon Sep 17 00:00:00 2001 From: Orgad Shaneh Date: Wed, 22 Jan 2025 14:43:43 +0200 Subject: [PATCH] RTPStream: Add protection for bad input If min_rtp_port is 0 and max_rtp_port is -2147483648, we try to bind to port 0. Fixes #771. --- src/rtpstream.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rtpstream.cpp b/src/rtpstream.cpp index b4d606ad..64e4f2f7 100644 --- a/src/rtpstream.cpp +++ b/src/rtpstream.cpp @@ -1876,7 +1876,7 @@ static int rtpstream_get_localport(int* rtpsocket, int* rtcpsocket) /* create socket for rtcp - ignore any errors, we only bind so we * won't send icmp-port-unreachable when rtcp arrives */ *rtcpsocket = socket(media_ip_is_ipv6?PF_INET6:PF_INET, SOCK_DGRAM, 0); - if (*rtcpsocket != -1) { + if (*rtcpsocket != -1 && port_number > 0) { /* try to bind it to our preferred address */ sockaddr_update_port(&address, port_number + 1); if (::bind(*rtcpsocket, (sockaddr *) (void *)&address,