From 00b62968d079e63bf22028f253ac297292436ebe Mon Sep 17 00:00:00 2001 From: Martin Storsjö Date: Wed, 28 Oct 2015 22:19:12 +0200 Subject: os_support: Don't try to return the service name as a string in getnameinfo MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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ö --- libavformat/os_support.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'libavformat/os_support.c') diff --git a/libavformat/os_support.c b/libavformat/os_support.c index 650baea0d0..e9b1f88fb8 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; -- cgit v1.2.3