You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by yl...@apache.org on 2020/11/23 16:12:29 UTC

svn commit: r1883753 - in /apr/apr/branches/1.7.x: ./ network_io/unix/sockaddr.c

Author: ylavic
Date: Mon Nov 23 16:12:29 2020
New Revision: 1883753

URL: http://svn.apache.org/viewvc?rev=1883753&view=rev
Log:
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.

Modified:
    apr/apr/branches/1.7.x/   (props changed)
    apr/apr/branches/1.7.x/network_io/unix/sockaddr.c

Propchange: apr/apr/branches/1.7.x/
------------------------------------------------------------------------------
  Merged /apr/apr/trunk:r1883728,1883742

Modified: apr/apr/branches/1.7.x/network_io/unix/sockaddr.c
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.7.x/network_io/unix/sockaddr.c?rev=1883753&r1=1883752&r2=1883753&view=diff
==============================================================================
--- apr/apr/branches/1.7.x/network_io/unix/sockaddr.c (original)
+++ apr/apr/branches/1.7.x/network_io/unix/sockaddr.c Mon Nov 23 16:12:29 2020
@@ -118,6 +118,14 @@ static apr_status_t get_remote_addr(apr_
 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;
     }