apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeff Trawick <traw...@gmail.com>
Subject [RFC] additional apr_getnameinfo error checking
Date Tue, 12 Nov 2013 14:45:30 GMT
Index: network_io/unix/sockaddr.c
--- network_io/unix/sockaddr.c (revision 1541061)
+++ network_io/unix/sockaddr.c (working copy)
@@ -672,6 +672,10 @@ APR_DECLARE(apr_status_t) apr_getnameinfo(char **h
     char tmphostname[256];

+    if (apr_sockaddr_is_wildcard(sockaddr)) {
+        return APR_EINVAL;
+    }
     /* don't know if it is portable for getnameinfo() to set h_errno;
      * clear it then see if it was set */
@@ -747,6 +751,10 @@ APR_DECLARE(apr_status_t) apr_getnameinfo(char **h
     int hosterror;
     struct hostent hs, *hptr;

+    if (apr_sockaddr_is_wildcard(sockaddr)) {
+        return APR_EINVAL;
+    }
     /* AIX, HP/UX, D/UX et alia */
     gethostbyaddr_r((char *)&sockaddr->sa.sin.sin_addr,

It seems sort of silly until you debug an app that shows different
representations of a sockaddr on different platforms, because

Linux: getnameinfo(INADDR_ANY) does DNS lookup then fails with not-found*
FreeBSD: getnameinfo(INADDR_ANY) fails immediately with not-found-or-no-arg*
Windows: getnameinfo(INADDR_ANY) succeeds, then returns the hostname of the

*didn't capture resolver error codes :(

Of course an app that is discovered to be getting bit is easy to fix with a
call to apr_sockaddr_is_wildcard() or local equivalent, and maybe some app
depends on the current behavior anyway.

Does anyone care either way?

Born in Roswell... married an alien...

View raw message