summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYann Ylavic <ylavic@apache.org>2022-01-12 12:36:15 +0000
committerYann Ylavic <ylavic@apache.org>2022-01-12 12:36:15 +0000
commitfdf6309acb41cc038d76c031d3f7843eb4ac1230 (patch)
treeabdb8e678a07e45fa02ebab9f38f8cc9fff52062
parent05730f150d24f6da783f5cadc9caf7ad3cfe6664 (diff)
downloadapr-fdf6309acb41cc038d76c031d3f7843eb4ac1230.tar.gz
apr_sockaddr_ip_getbuf: Follow up to r1883728.
Return APR_ENOSPC if returned buf is truncated for an AF_UNIX. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1896956 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--network_io/unix/sockaddr.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/network_io/unix/sockaddr.c b/network_io/unix/sockaddr.c
index 5cee61933..16712fec2 100644
--- a/network_io/unix/sockaddr.c
+++ b/network_io/unix/sockaddr.c
@@ -110,9 +110,10 @@ APR_DECLARE(apr_status_t) apr_sockaddr_ip_getbuf(char *buf, apr_size_t buflen,
{
#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;
+ const char *ptr = sockaddr->ipaddr_ptr;
+ apr_size_t len = apr_cpystrn(buf, ptr, buflen) - buf;
+ /* assumes that sockaddr->ipaddr_ptr is nul terminated */
+ return ptr[len] ? APR_ENOSPC : APR_SUCCESS;
}
#endif