Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PR] WIP: Don't bind sockets to 0.0.0.0 by default for unicast UDP inputs (PR #21470)
@ 2026-01-15  0:40 Rost via ffmpeg-devel
  0 siblings, 0 replies; only message in thread
From: Rost via ffmpeg-devel @ 2026-01-15  0:40 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Rost

PR #21470 opened by Rost (rost.kurylo)
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21470
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21470.patch


>From 6bc89b9956a2bf5606a6d3bd89c7abcba1c61110 Mon Sep 17 00:00:00 2001
From: Rost Kurylo <rost.kurylo@netint.ca>
Date: Tue, 13 Jan 2026 11:17:57 -0800
Subject: [PATCH 1/2] Don't bind sockets to 0.0.0.0 by default for unicast UDP
 inputs

---
 libavformat/udp.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/libavformat/udp.c b/libavformat/udp.c
index 61e80c86c5..4718457f42 100644
--- a/libavformat/udp.c
+++ b/libavformat/udp.c
@@ -700,6 +700,7 @@ static int udp_open(URLContext *h, const char *uri, int flags)
     struct sockaddr_storage my_addr;
     socklen_t len;
     int ret;
+    const char *bind_addr = NULL;
 
     h->is_streamed = 1;
 
@@ -759,7 +760,12 @@ static int udp_open(URLContext *h, const char *uri, int flags)
     if ((s->is_multicast || s->local_port < 0) && (h->flags & AVIO_FLAG_READ))
         s->local_port = port;
 
-    udp_fd = udp_socket_create(h, &my_addr, &len, s->localaddr);
+    if (!s->is_multicast && (s->localaddr == NULL || s->localaddr[0] == '\0') && h->flags & AVIO_FLAG_READ)
+        bind_addr = hostname;
+    else
+        bind_addr = s->localaddr;
+
+    udp_fd = udp_socket_create(h, &my_addr, &len, bind_addr);
     if (udp_fd < 0) {
         ret = AVERROR(EIO);
         goto fail;
-- 
2.49.1


>From 0ed684751806933020deba95345b608284feb489 Mon Sep 17 00:00:00 2001
From: Rost Kurylo <rost.kurylo@netint.ca>
Date: Tue, 13 Jan 2026 11:28:04 -0800
Subject: [PATCH 2/2] Explicitly bind RTP sockets to 0.0.0.0 in rtsp

A better alternative is to bind to a local IP that is used to
communicate with RTSP server via signalling socket. Should be
considered as a further improvement.
---
 libavformat/rtsp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
index e8f44e571a..048f8de5bb 100644
--- a/libavformat/rtsp.c
+++ b/libavformat/rtsp.c
@@ -1566,7 +1566,7 @@ int ff_rtsp_make_setup_request(AVFormatContext *s, const char *host, int port,
             while (j + 1 <= rt->rtp_port_max) {
                 AVDictionary *opts = map_to_opts(rt);
 
-                ff_url_join(buf, sizeof(buf), "rtp", NULL, host, -1,
+                ff_url_join(buf, sizeof(buf), "rtp", NULL, "0.0.0.0", -1,
                             "?localport=%d", j);
                 /* we will use two ports per rtp stream (rtp and rtcp) */
                 j += 2;
-- 
2.49.1

_______________________________________________
ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org
To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-01-15  0:41 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-01-15  0:40 [FFmpeg-devel] [PR] WIP: Don't bind sockets to 0.0.0.0 by default for unicast UDP inputs (PR #21470) Rost via ffmpeg-devel

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git