You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by sf...@apache.org on 2013/05/03 20:35:14 UTC
svn commit: r1478905 - /apr/apr/trunk/network_io/unix/sockaddr.c
Author: sf
Date: Fri May 3 18:35:14 2013
New Revision: 1478905
URL: http://svn.apache.org/r1478905
Log:
Make sure apr_sockaddr_info_get() returns an error if
- getaddrinfo() returned only useless entries
- getaddrinfo() returned EAI_SYSTEM but errno == 0
- gethostbyname() returns no error but an empty address list
Submitted by: Jan Kaluža <jkaluza redhat com>, Stefan Fritsch
Modified:
apr/apr/trunk/network_io/unix/sockaddr.c
Modified: apr/apr/trunk/network_io/unix/sockaddr.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/network_io/unix/sockaddr.c?rev=1478905&r1=1478904&r2=1478905&view=diff
==============================================================================
--- apr/apr/trunk/network_io/unix/sockaddr.c (original)
+++ apr/apr/trunk/network_io/unix/sockaddr.c Fri May 3 18:35:14 2013
@@ -393,7 +393,7 @@ static apr_status_t call_resolver(apr_so
return apr_get_netos_error();
#else
if (error == EAI_SYSTEM) {
- return errno;
+ return errno ? errno : APR_EGENERAL;
}
else
{
@@ -448,6 +448,15 @@ static apr_status_t call_resolver(apr_so
ai = ai->ai_next;
}
freeaddrinfo(ai_list);
+
+ if (prev_sa == NULL) {
+ /*
+ * getaddrinfo returned only useless entries and *sa is still empty.
+ * This should be treated as an error.
+ */
+ return APR_EGENERAL;
+ }
+
return APR_SUCCESS;
}
@@ -581,6 +590,11 @@ static apr_status_t find_addresses(apr_s
++curaddr;
}
+ if (prev_sa == NULL) {
+ /* this should not happen but no result should be treated as error */
+ return APR_EGENERAL;
+ }
+
return APR_SUCCESS;
}