[FFmpeg-cvslog] os_support: Don' t try to return the service name as a string in getnameinfo

Martin Storsjö git at videolan.org
Mon Nov 2 11:44:53 CET 2015


ffmpeg | branch: master | Martin Storsjö <martin at martin.st> | Wed Oct 28 22:19:12 2015 +0200| [00b62968d079e63bf22028f253ac297292436ebe] | committer: Martin Storsjö

os_support: Don't try to return the service name as a string in getnameinfo

Some systems may be lacking getservbyport; the previous ifdef wasn't
quite enough since it still assumed that struct servent was defined,
as pointed out by Clément Gregoire.

Simply remove the possibility to return non-numeric services in
getnameinfo; no caller of getnameinfo within libavformat
currently try to use getnameinfo for retrieving the port number without
NI_NUMERICSERV, and falling back on getservbyport may be non-threadsafe.

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

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

 configure                |    2 --
 libavformat/os_support.c |   11 ++---------
 2 files changed, 2 insertions(+), 11 deletions(-)

diff --git a/configure b/configure
index d941d95..cbd8c5a 100755
--- a/configure
+++ b/configure
@@ -1513,7 +1513,6 @@ SYSTEM_FUNCS="
     GetProcessMemoryInfo
     GetProcessTimes
     getrusage
-    getservbyport
     GetSystemTimeAsFileTime
     gettimeofday
     gmtime_r
@@ -4240,7 +4239,6 @@ fi
 
 if ! disabled network; then
     check_func getaddrinfo $network_extralibs
-    check_func getservbyport $network_extralibs
     check_func inet_aton $network_extralibs
 
     check_type netdb.h "struct addrinfo"
diff --git a/libavformat/os_support.c b/libavformat/os_support.c
index 650baea..e9b1f88 100644
--- a/libavformat/os_support.c
+++ b/libavformat/os_support.c
@@ -204,16 +204,9 @@ int ff_getnameinfo(const struct sockaddr *sa, int salen,
     }
 
     if (serv && servlen > 0) {
-        struct servent *ent = NULL;
-#if HAVE_GETSERVBYPORT
         if (!(flags & NI_NUMERICSERV))
-            ent = getservbyport(sin->sin_port, flags & NI_DGRAM ? "udp" : "tcp");
-#endif /* HAVE_GETSERVBYPORT */
-
-        if (ent)
-            snprintf(serv, servlen, "%s", ent->s_name);
-        else
-            snprintf(serv, servlen, "%d", ntohs(sin->sin_port));
+            return EAI_FAIL;
+        snprintf(serv, servlen, "%d", ntohs(sin->sin_port));
     }
 
     return 0;



More information about the ffmpeg-cvslog mailing list