1
1
/*
2
2
* ProFTPD - mod_proxy conn implementation
3
- * Copyright (c) 2012-2024 TJ Saunders
3
+ * Copyright (c) 2012-2025 TJ Saunders
4
4
*
5
5
* This program is free software; you can redistribute it and/or modify
6
6
* it under the terms of the GNU General Public License as published by
@@ -677,7 +677,7 @@ conn_t *proxy_conn_get_server_conn(pool *p, struct proxy_session *proxy_sess,
677
677
const char * remote_ipstr = NULL ;
678
678
unsigned int remote_port ;
679
679
conn_t * server_conn , * ctrl_conn ;
680
- int res , default_inet_family = 0 ;
680
+ int res , default_inet_family = 0 , xerrno ;
681
681
682
682
if (proxy_sess -> connect_timeout > 0 ) {
683
683
const char * notes_key = "mod_proxy.proxy-connect-address" ;
@@ -816,9 +816,14 @@ conn_t *proxy_conn_get_server_conn(pool *p, struct proxy_session *proxy_sess,
816
816
}
817
817
818
818
server_conn = pr_inet_create_conn (p , -1 , bind_addr , INPORT_ANY , FALSE);
819
- if (server_conn == NULL ) {
820
- int xerrno = errno ;
819
+ xerrno = errno ;
820
+
821
+ /* Restore the previous default inet family if necessary. */
822
+ if (bind_addr == NULL ) {
823
+ (void ) pr_inet_set_default_family (p , default_inet_family );
824
+ }
821
825
826
+ if (server_conn == NULL ) {
822
827
(void ) pr_log_writefile (proxy_logfd , MOD_PROXY_VERSION ,
823
828
"error creating connection to %s: %s" , pr_netaddr_get_ipstr (bind_addr ),
824
829
strerror (xerrno ));
@@ -828,19 +833,14 @@ conn_t *proxy_conn_get_server_conn(pool *p, struct proxy_session *proxy_sess,
828
833
return NULL ;
829
834
}
830
835
831
- /* Restore the previous default inet family if necessary. */
832
- if (bind_addr == NULL ) {
833
- (void ) pr_inet_set_default_family (p , default_inet_family );
834
- }
835
-
836
836
pr_trace_msg (trace_channel , 12 ,
837
837
"connecting to backend address %s#%u from %s#%u" , remote_ipstr , remote_port ,
838
838
pr_netaddr_get_ipstr (server_conn -> local_addr ), server_conn -> local_port );
839
839
840
840
res = pr_inet_connect_nowait (p , server_conn , remote_addr ,
841
841
ntohs (pr_netaddr_get_port (remote_addr )));
842
842
if (res < 0 ) {
843
- int xerrno = errno ;
843
+ xerrno = errno ;
844
844
845
845
(void ) pr_log_writefile (proxy_logfd , MOD_PROXY_VERSION ,
846
846
"error starting connect to %s#%u: %s" , remote_ipstr , remote_port ,
@@ -903,7 +903,7 @@ conn_t *proxy_conn_get_server_conn(pool *p, struct proxy_session *proxy_sess,
903
903
nstrm = proxy_netio_open (p , PR_NETIO_STRM_OTHR , server_conn -> listen_fd ,
904
904
nstrm_mode );
905
905
if (nstrm == NULL ) {
906
- int xerrno = errno ;
906
+ xerrno = errno ;
907
907
908
908
(void ) pr_log_writefile (proxy_logfd , MOD_PROXY_VERSION ,
909
909
"error opening stream to %s#%u: %s" , remote_ipstr , remote_port ,
@@ -927,7 +927,7 @@ conn_t *proxy_conn_get_server_conn(pool *p, struct proxy_session *proxy_sess,
927
927
switch (polled ) {
928
928
case 1 : {
929
929
/* Aborted, timed out. Note that we shouldn't reach here. */
930
- int xerrno = ETIMEDOUT ;
930
+ xerrno = ETIMEDOUT ;
931
931
932
932
(void ) pr_log_writefile (proxy_logfd , MOD_PROXY_VERSION ,
933
933
"error connecting to %s#%u: %s" , remote_ipstr , remote_port ,
@@ -942,7 +942,7 @@ conn_t *proxy_conn_get_server_conn(pool *p, struct proxy_session *proxy_sess,
942
942
943
943
case -1 : {
944
944
/* Error */
945
- int xerrno = nstrm -> strm_errno ;
945
+ xerrno = nstrm -> strm_errno ;
946
946
947
947
if (xerrno == 0 ) {
948
948
xerrno = errno ;
@@ -976,7 +976,7 @@ conn_t *proxy_conn_get_server_conn(pool *p, struct proxy_session *proxy_sess,
976
976
977
977
res = pr_inet_get_conn_info (server_conn , server_conn -> listen_fd );
978
978
if (res < 0 ) {
979
- int xerrno = errno ;
979
+ xerrno = errno ;
980
980
981
981
(void ) pr_log_writefile (proxy_logfd , MOD_PROXY_VERSION ,
982
982
"error obtaining local socket info on fd %d: %s" ,
@@ -1005,7 +1005,7 @@ conn_t *proxy_conn_get_server_conn(pool *p, struct proxy_session *proxy_sess,
1005
1005
ctrl_conn = proxy_inet_openrw (p , server_conn , NULL , PR_NETIO_STRM_CTRL , -1 ,
1006
1006
-1 , -1 , FALSE);
1007
1007
if (ctrl_conn == NULL ) {
1008
- int xerrno = errno ;
1008
+ xerrno = errno ;
1009
1009
1010
1010
(void ) pr_log_writefile (proxy_logfd , MOD_PROXY_VERSION ,
1011
1011
"unable to open control connection to %s#%u: %s" , remote_ipstr ,
0 commit comments