summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYann Ylavic <ylavic@apache.org>2020-11-23 16:12:29 +0000
committerYann Ylavic <ylavic@apache.org>2020-11-23 16:12:29 +0000
commit1d73bd68279dfa83115ff99cc4670eb1e478f2fb (patch)
treec2e65dc590de683af750d6f07ddfbe62623b1779
parenta6fc15853e813e8d844dc85b33c7ab0572d390e2 (diff)
downloadapr-1d73bd68279dfa83115ff99cc4670eb1e478f2fb.tar.gz
Merge r1883728, r1883742 from trunk:
apr_sockaddr_ip_get[buf]: handle APR_UNIX family. For unix sockets, return the path (sun_path). Follow up to r1883728: uncomment the change, and fix apr_cpystrn() args orrder. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/branches/1.7.x@1883753 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--network_io/unix/sockaddr.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/network_io/unix/sockaddr.c b/network_io/unix/sockaddr.c
index 581177997..487e2ab99 100644
--- a/network_io/unix/sockaddr.c
+++ b/network_io/unix/sockaddr.c
@@ -118,6 +118,14 @@ static apr_status_t get_remote_addr(apr_socket_t *sock)
APR_DECLARE(apr_status_t) apr_sockaddr_ip_getbuf(char *buf, apr_size_t buflen,
apr_sockaddr_t *sockaddr)
{
+#if APR_HAVE_SOCKADDR_UN
+ if (sockaddr->family == APR_UNIX) {
+ apr_size_t len = (apr_size_t)sockaddr->ipaddr_len;
+ apr_cpystrn(buf, sockaddr->ipaddr_ptr, buflen < len ? buflen : len);
+ return APR_SUCCESS;
+ }
+#endif
+
if (!apr_inet_ntop(sockaddr->family, sockaddr->ipaddr_ptr, buf, buflen)) {
return APR_ENOSPC;
}