Bug 61080 - apr_sockaddr_info_get() with hostname is NULL
Summary: apr_sockaddr_info_get() with hostname is NULL
Status: UNCONFIRMED
Alias: None
Product: APR
Classification: Unclassified
Component: APR (show other bugs)
Version: HEAD
Hardware: All Linux
: P2 normal (vote)
Target Milestone: ---
Assignee: Apache Portable Runtime bugs mailinglist
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-05-08 15:23 UTC by Armin Abfalterer
Modified: 2023-01-21 16:15 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Armin Abfalterer 2017-05-08 15:23:12 UTC
Hi,

apr_sockaddr_info_get() does not allow to set the flag (APR_IPV4_ADDR_OK or APR_IPV6_ADDR_OK) and to pass NULL for the hostname. In this case APR_EINVAL is returned, see https://github.com/apache/apr/blob/trunk/network_io/unix/sockaddr.c#L614-L618

However, the documentation says "The hostname [...] or NULL to build an address that corresponds to 0.0.0.0 or :: [...]", see https://apr.apache.org/docs/apr/1.6/group__apr__network__io.html#gaa2f399ca2b60b35c0abf7630298c6c9f

Also the manual of getaddrinfo says "If the AI_PASSIVE flag is specified in hints.ai_flags, and node is NULL, then the returned socket addresses will be suitable for bind(2)ing a socket that will accept(2) connections. The returned socket address will contain the "wildcard address" (INADDR_ANY for IPv4 addresses, IN6ADDR_ANY_INIT for IPv6 address). The wildcard address is used by applications (typically servers) that intend to accept connections on any of the hosts's network addresses. If node is not NULL, then the AI_PASSIVE flag is ignored.

If the AI_PASSIVE flag is not set in hints.ai_flags, then the returned socket addresses will be suitable for use with connect(2), sendto(2), or sendmsg(2). If node is NULL, then the network address will be set to the loopback interface address (INADDR_LOOPBACK for IPv4 addresses, IN6ADDR_LOOPBACK_INIT for IPv6 address); this is used by applications that intend to communicate with peers running on the same host."

Cheers, Armin