diff options
Diffstat (limited to 'inet')
-rw-r--r-- | inet/getnameinfo.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/inet/getnameinfo.c b/inet/getnameinfo.c index 709f9ecbfe..9a0709229e 100644 --- a/inet/getnameinfo.c +++ b/inet/getnameinfo.c @@ -172,8 +172,20 @@ getnameinfo (const struct sockaddr *sa, socklen_t addrlen, char *host, int herrno; char *tmpbuf = alloca (tmpbuflen); struct hostent th; + socklen_t min_addrlen = 0; - if (sa == NULL) + if (sa == NULL || addrlen < sizeof (sa_family_t)) + return -1; + + switch (sa->sa_family) + { + case AF_LOCAL: + min_addrlen = (socklen_t) (((struct sockaddr_un *) NULL)->sun_path); + break; + default: + min_addrlen = __libc_sa_len (sa->sa_family); + } + if (addrlen < min_addrlen) return -1; if (host != NULL && hostlen > 0) |