[FFmpeg-cvslog] tcp: Pass NULL as hostname to getaddrinfo if the string is empty

Jordi Ortiz git at videolan.org
Thu Jun 28 01:09:05 CEST 2012


ffmpeg | branch: master | Jordi Ortiz <nenjordi at gmail.com> | Tue Jun 26 19:22:21 2012 +0200| [ef882e464ab270276f56c1088da646a8080b8460] | committer: Martin Storsjö

tcp: Pass NULL as hostname to getaddrinfo if the string is empty

This gives you the proper v4 or v6 version of the "any address",
allowing receiving connections on any address on the machine.

Signed-off-by: Martin Storsjö <martin at martin.st>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ef882e464ab270276f56c1088da646a8080b8460
---

 libavformat/tcp.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/libavformat/tcp.c b/libavformat/tcp.c
index 5313195..6a65860 100644
--- a/libavformat/tcp.c
+++ b/libavformat/tcp.c
@@ -65,7 +65,10 @@ static int tcp_open(URLContext *h, const char *uri, int flags)
     snprintf(portstr, sizeof(portstr), "%d", port);
     if (listen_socket)
         hints.ai_flags |= AI_PASSIVE;
-    ret = getaddrinfo(hostname, portstr, &hints, &ai);
+    if (!hostname[0])
+        ret = getaddrinfo(NULL, portstr, &hints, &ai);
+    else
+        ret = getaddrinfo(hostname, portstr, &hints, &ai);
     if (ret) {
         av_log(h, AV_LOG_ERROR,
                "Failed to resolve hostname %s: %s\n",



More information about the ffmpeg-cvslog mailing list