You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by yl...@apache.org on 2021/01/05 10:23:21 UTC
svn commit: r1885139 - in /httpd/httpd/branches/2.4.x: ./ server/core.c
Author: ylavic
Date: Tue Jan 5 10:23:21 2021
New Revision: 1885139
URL: http://svn.apache.org/viewvc?rev=1885139&view=rev
Log:
Merge r1883729 from trunk:
core: fix c->client_ip for unix socket connections.
Catch apr_socket_addr_get() error in core_create_conn() to avoid uninitialized
conn_rec->client_ip. This can happen for mod_proxy connections using unix
sockets, which are not handled by apr_socket_addr_get() until APR's r1883728
(trunk only for now).
Submitted by: ylavic
Reviewed by: ylavic, jorton, covener
Modified:
httpd/httpd/branches/2.4.x/ (props changed)
httpd/httpd/branches/2.4.x/server/core.c
Propchange: httpd/httpd/branches/2.4.x/
------------------------------------------------------------------------------
Merged /httpd/httpd/trunk:r1883729
Modified: httpd/httpd/branches/2.4.x/server/core.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/server/core.c?rev=1885139&r1=1885138&r2=1885139&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/server/core.c (original)
+++ httpd/httpd/branches/2.4.x/server/core.c Tue Jan 5 10:23:21 2021
@@ -5086,10 +5086,10 @@ static conn_rec *core_create_conn(apr_po
/* Got a connection structure, so initialize what fields we can
* (the rest are zeroed out by pcalloc).
*/
+ c->pool = ptrans;
c->conn_config = ap_create_conn_config(ptrans);
c->notes = apr_table_make(ptrans, 5);
- c->pool = ptrans;
if ((rv = apr_socket_addr_get(&c->local_addr, APR_LOCAL, csd))
!= APR_SUCCESS) {
ap_log_error(APLOG_MARK, APLOG_INFO, rv, server, APLOGNO(00137)
@@ -5097,8 +5097,17 @@ static conn_rec *core_create_conn(apr_po
apr_socket_close(csd);
return NULL;
}
+ if (apr_sockaddr_ip_get(&c->local_ip, c->local_addr)) {
+#if APR_HAVE_SOCKADDR_UN
+ if (c->local_addr->family == APR_UNIX) {
+ c->local_ip = apr_pstrndup(c->pool, c->local_addr->ipaddr_ptr,
+ c->local_addr->ipaddr_len);
+ }
+ else
+#endif
+ c->local_ip = apr_pstrdup(c->pool, "unknown");
+ }
- apr_sockaddr_ip_get(&c->local_ip, c->local_addr);
if ((rv = apr_socket_addr_get(&c->client_addr, APR_REMOTE, csd))
!= APR_SUCCESS) {
ap_log_error(APLOG_MARK, APLOG_INFO, rv, server, APLOGNO(00138)
@@ -5106,8 +5115,17 @@ static conn_rec *core_create_conn(apr_po
apr_socket_close(csd);
return NULL;
}
+ if (apr_sockaddr_ip_get(&c->client_ip, c->client_addr)) {
+#if APR_HAVE_SOCKADDR_UN
+ if (c->client_addr->family == APR_UNIX) {
+ c->client_ip = apr_pstrndup(c->pool, c->client_addr->ipaddr_ptr,
+ c->client_addr->ipaddr_len);
+ }
+ else
+#endif
+ c->client_ip = apr_pstrdup(c->pool, "unknown");
+ }
- apr_sockaddr_ip_get(&c->client_ip, c->client_addr);
c->base_server = server;
c->id = id;