Change in openvpn[master]: socks: factor out socks_proxy_recv_char()
A message that is not in the archive (sent off-list or not yet received): gerrit.1756814708000.I6e848df8104b6e3a6e2c3245ece91a20e473fb40@...2715...
Attention is currently required from: plaisthos.
Hello plaisthos,
I'd like you to do a code review.
Please visit
http://gerrit.openvpn.net/c/openvpn/+/1165?usp=email
to review the following change.
Change subject: socks: factor out socks_proxy_recv_char()
......................................................................
socks: factor out socks_proxy_recv_char()
This is basically identical code duplicated three
times.
---
M src/openvpn/socks.c
1 file changed, 51 insertions(+), 121 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/65/1165/1
src/openvpn/socks.c +51 -121
@@ -81,6 +81,54 @@ }static bool +socks_proxy_recv_char (char *c,const char *name,socket_descriptor_t sd, +struct event_timeout *server_poll_timeout, +volatile int *signal_received) +{ +fd_set reads; +FD_ZERO (&reads); +openvpn_fd_set (sd, &reads); + +struct timeval tv; + tv.tv_sec =get_server_poll_remaining_time (server_poll_timeout); + tv.tv_usec =0 ; + +const int status =select (sd +1 , &reads,NULL ,NULL , &tv); + +get_signal (signal_received); +if (*signal_received) + { +return false; + } + +/* timeout? */ +if (status ==0 ) + { +msg (D_LINK_ERRORS |M_ERRNO ,"%s: TCP port read timeout expired" , name); +return false; + } + +/* error */ +if (status <0 ) + { +msg (D_LINK_ERRORS |M_ERRNO ,"%s: TCP port read failed on select()" , name); +return false; + } + +/* read single char */ +const ssize_t size =recv (sd, c,1 ,MSG_NOSIGNAL ); + +/* error? */ +if (size !=1 ) + { +msg (D_LINK_ERRORS |M_ERRNO ,"%s: TCP port read failed on recv()" , name); +return false; + } + +return true; +} + +static bool socks_username_password_auth (struct socks_proxy_info *p,socket_descriptor_t sd,struct event_timeout *server_poll_timeout,volatile int *signal_received)
@@ -121,52 +169,12 @@while (len <2 ) { -int status; -ssize_t size; -fd_set reads; -struct timeval tv;char c; -FD_ZERO (&reads); -openvpn_fd_set (sd, &reads); - tv.tv_sec =get_server_poll_remaining_time (server_poll_timeout); - tv.tv_usec =0 ; - - status =select (sd +1 , &reads,NULL ,NULL , &tv); - -get_signal (signal_received); -if (*signal_received) +if (!socks_proxy_recv_char (&c, __func__, sd, server_poll_timeout, signal_received)) { goto cleanup; } - -/* timeout? */ -if (status ==0 ) - { -msg (D_LINK_ERRORS |M_ERRNO , -"socks_username_password_auth: TCP port read timeout expired" ); - goto cleanup; - } - -/* error */ -if (status <0 ) - { -msg (D_LINK_ERRORS |M_ERRNO , -"socks_username_password_auth: TCP port read failed on select()" ); - goto cleanup; - } - -/* read single char */ - size =recv (sd, &c,1 ,MSG_NOSIGNAL ); - -/* error? */ -if (size !=1 ) - { -msg (D_LINK_ERRORS |M_ERRNO , -"socks_username_password_auth: TCP port read failed on recv()" ); - goto cleanup; - } -/* store char in buffer */ buf[len++] = c; }
@@ -208,49 +216,12 @@while (len <2 ) { -int status; -ssize_t size; -fd_set reads; -struct timeval tv;char c; -FD_ZERO (&reads); -openvpn_fd_set (sd, &reads); - tv.tv_sec =get_server_poll_remaining_time (server_poll_timeout); - tv.tv_usec =0 ; - - status =select (sd +1 , &reads,NULL ,NULL , &tv); - -get_signal (signal_received); -if (*signal_received) +if (!socks_proxy_recv_char (&c, __func__, sd, server_poll_timeout, signal_received)) {return false; } - -/* timeout? */ -if (status ==0 ) - { -msg (D_LINK_ERRORS |M_ERRNO ,"socks_handshake: TCP port read timeout expired" ); -return false; - } - -/* error */ -if (status <0 ) - { -msg (D_LINK_ERRORS |M_ERRNO ,"socks_handshake: TCP port read failed on select()" ); -return false; - } - -/* read single char */ - size =recv (sd, &c,1 ,MSG_NOSIGNAL ); - -/* error? */ -if (size !=1 ) - { -msg (D_LINK_ERRORS |M_ERRNO ,"socks_handshake: TCP port read failed on recv()" ); -return false; - } -/* store char in buffer */ buf[len++] = c; }
@@ -317,54 +288,13 @@while (len <4 + alen +2 ) { -int status; -ssize_t size; -fd_set reads; -struct timeval tv;char c; -FD_ZERO (&reads); -openvpn_fd_set (sd, &reads); - tv.tv_sec =get_server_poll_remaining_time (server_poll_timeout); - tv.tv_usec =0 ; - - status =select (sd +1 , &reads,NULL ,NULL , &tv); - -get_signal (signal_received); -if (*signal_received) +if (!socks_proxy_recv_char (&c, __func__, sd, server_poll_timeout, signal_received)) {return false; } -/* timeout? */ -if (status ==0 ) - { -msg (D_LINK_ERRORS |M_ERRNO ,"recv_socks_reply: TCP port read timeout expired" ); -return false; - } - -/* error */ -if (status <0 ) - { -msg (D_LINK_ERRORS |M_ERRNO ,"recv_socks_reply: TCP port read failed on select()" ); -return false; - } - -/* read single char */ - size =recv (sd, &c,1 ,MSG_NOSIGNAL ); - -/* error? */ -if (size <0 ) - { -msg (D_LINK_ERRORS |M_ERRNO ,"recv_socks_reply: TCP port read failed on recv()" ); -return false; - } -else if (size ==0 ) - { -msg (D_LINK_ERRORS ,"ERROR: recv_socks_reply: empty response from socks server" ); -return false; - } -if (len ==3 ) { atyp = c;
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1165?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I6e848df8104b6e3a6e2c3245ece91a20e473fb40
Gerrit-Change-Number: 1165
Gerrit-PatchSet: 1
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-MessageType: newchange
Attention is currently required from: flichtenheld, plaisthos.
cron2 has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/1165?usp=email )
Change subject: socks: factor out socks_proxy_recv_char()
......................................................................
Patch Set 2: Code-Review+2
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1165?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I6e848df8104b6e3a6e2c3245ece91a20e473fb40
Gerrit-Change-Number: 1165
Gerrit-PatchSet: 2
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Tue, 23 Sep 2025 15:10:33 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
PATCH v2 1/1 socks: factor out socks_proxy_recv_char()
In reply to a message not in the archiveFrom: Frank Lichtenheld <[email protected]...>
This is basically identical code duplicated three
times.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1165
---
This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1165
This mail reflects revision 2 of this Change.
Acked-by according to Gerrit (reflected above):
Gert Doering <[email protected]...>
src/openvpn/socks.c +51 -121
@@ -81,6 +81,54 @@ }static bool +socks_proxy_recv_char (char *c,const char *name,socket_descriptor_t sd, +struct event_timeout *server_poll_timeout, +volatile int *signal_received) +{ +fd_set reads; +FD_ZERO (&reads); +openvpn_fd_set (sd, &reads); + +struct timeval tv; + tv.tv_sec =get_server_poll_remaining_time (server_poll_timeout); + tv.tv_usec =0 ; + +const int status =select (sd +1 , &reads,NULL ,NULL , &tv); + +get_signal (signal_received); +if (*signal_received) + { +return false; + } + +/* timeout? */ +if (status ==0 ) + { +msg (D_LINK_ERRORS |M_ERRNO ,"%s: TCP port read timeout expired" , name); +return false; + } + +/* error */ +if (status <0 ) + { +msg (D_LINK_ERRORS |M_ERRNO ,"%s: TCP port read failed on select()" , name); +return false; + } + +/* read single char */ +const ssize_t size =recv (sd, c,1 ,MSG_NOSIGNAL ); + +/* error? */ +if (size !=1 ) + { +msg (D_LINK_ERRORS |M_ERRNO ,"%s: TCP port read failed on recv()" , name); +return false; + } + +return true; +} + +static bool socks_username_password_auth (struct socks_proxy_info *p,socket_descriptor_t sd,struct event_timeout *server_poll_timeout,volatile int *signal_received)
@@ -121,52 +169,12 @@while (len <2 ) { -int status; -ssize_t size; -fd_set reads; -struct timeval tv;char c; -FD_ZERO (&reads); -openvpn_fd_set (sd, &reads); - tv.tv_sec =get_server_poll_remaining_time (server_poll_timeout); - tv.tv_usec =0 ; - - status =select (sd +1 , &reads,NULL ,NULL , &tv); - -get_signal (signal_received); -if (*signal_received) +if (!socks_proxy_recv_char (&c, __func__, sd, server_poll_timeout, signal_received)) { goto cleanup; } - -/* timeout? */ -if (status ==0 ) - { -msg (D_LINK_ERRORS |M_ERRNO , -"socks_username_password_auth: TCP port read timeout expired" ); - goto cleanup; - } - -/* error */ -if (status <0 ) - { -msg (D_LINK_ERRORS |M_ERRNO , -"socks_username_password_auth: TCP port read failed on select()" ); - goto cleanup; - } - -/* read single char */ - size =recv (sd, &c,1 ,MSG_NOSIGNAL ); - -/* error? */ -if (size !=1 ) - { -msg (D_LINK_ERRORS |M_ERRNO , -"socks_username_password_auth: TCP port read failed on recv()" ); - goto cleanup; - } -/* store char in buffer */ buf[len++] = c; }
@@ -208,49 +216,12 @@while (len <2 ) { -int status; -ssize_t size; -fd_set reads; -struct timeval tv;char c; -FD_ZERO (&reads); -openvpn_fd_set (sd, &reads); - tv.tv_sec =get_server_poll_remaining_time (server_poll_timeout); - tv.tv_usec =0 ; - - status =select (sd +1 , &reads,NULL ,NULL , &tv); - -get_signal (signal_received); -if (*signal_received) +if (!socks_proxy_recv_char (&c, __func__, sd, server_poll_timeout, signal_received)) {return false; } - -/* timeout? */ -if (status ==0 ) - { -msg (D_LINK_ERRORS |M_ERRNO ,"socks_handshake: TCP port read timeout expired" ); -return false; - } - -/* error */ -if (status <0 ) - { -msg (D_LINK_ERRORS |M_ERRNO ,"socks_handshake: TCP port read failed on select()" ); -return false; - } - -/* read single char */ - size =recv (sd, &c,1 ,MSG_NOSIGNAL ); - -/* error? */ -if (size !=1 ) - { -msg (D_LINK_ERRORS |M_ERRNO ,"socks_handshake: TCP port read failed on recv()" ); -return false; - } -/* store char in buffer */ buf[len++] = c; }
@@ -317,54 +288,13 @@while (len <4 + alen +2 ) { -int status; -ssize_t size; -fd_set reads; -struct timeval tv;char c; -FD_ZERO (&reads); -openvpn_fd_set (sd, &reads); - tv.tv_sec =get_server_poll_remaining_time (server_poll_timeout); - tv.tv_usec =0 ; - - status =select (sd +1 , &reads,NULL ,NULL , &tv); - -get_signal (signal_received); -if (*signal_received) +if (!socks_proxy_recv_char (&c, __func__, sd, server_poll_timeout, signal_received)) {return false; } -/* timeout? */ -if (status ==0 ) - { -msg (D_LINK_ERRORS |M_ERRNO ,"recv_socks_reply: TCP port read timeout expired" ); -return false; - } - -/* error */ -if (status <0 ) - { -msg (D_LINK_ERRORS |M_ERRNO ,"recv_socks_reply: TCP port read failed on select()" ); -return false; - } - -/* read single char */ - size =recv (sd, &c,1 ,MSG_NOSIGNAL ); - -/* error? */ -if (size <0 ) - { -msg (D_LINK_ERRORS |M_ERRNO ,"recv_socks_reply: TCP port read failed on recv()" ); -return false; - } -else if (size ==0 ) - { -msg (D_LINK_ERRORS ,"ERROR: recv_socks_reply: empty response from socks server" ); -return false; - } -if (len ==3 ) { atyp = c;
[Openvpn-devel] [PATCH applied] Re: socks: factor out socks_proxy_recv_char()
This is not truly part of the "trivial integer related fixes" series, more of the "ugh, how did we accept such horrible code, ever?" version...
I have stared-at-code a while, and then ran all the SOCKs test (admittedly only "successful", so not testing timeouts and the like) but since this is really 1:1 the same code (except for "return false" in the new function), I do not expect surprises there. Tests all pass ;-)
Your patch has been applied to the master branch.
commit 9178a8ce73e9c5dd259522aa5e100116b965725b
Author: Frank Lichtenheld Date: Tue Sep 23 17:10:44 2025 +0200
socks: factor out socks_proxy_recv_char()
Signed-off-by: Frank Lichtenheld <[email protected]...>
Acked-by: Gert Doering <[email protected]...>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1165
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg33171.html
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
cron2 has uploaded a new patch set (#3) to the change originally created by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1165?usp=email )
The following approvals got outdated and were removed:
Code-Review+2 by cron2
Change subject: socks: factor out socks_proxy_recv_char()
......................................................................
socks: factor out socks_proxy_recv_char()
This is basically identical code duplicated three
times.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1165
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg33171.html
---
M src/openvpn/socks.c
1 file changed, 51 insertions(+), 121 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/65/1165/3
src/openvpn/socks.c +51 -121
@@ -81,6 +81,54 @@ }static bool +socks_proxy_recv_char (char *c,const char *name,socket_descriptor_t sd, +struct event_timeout *server_poll_timeout, +volatile int *signal_received) +{ +fd_set reads; +FD_ZERO (&reads); +openvpn_fd_set (sd, &reads); + +struct timeval tv; + tv.tv_sec =get_server_poll_remaining_time (server_poll_timeout); + tv.tv_usec =0 ; + +const int status =select (sd +1 , &reads,NULL ,NULL , &tv); + +get_signal (signal_received); +if (*signal_received) + { +return false; + } + +/* timeout? */ +if (status ==0 ) + { +msg (D_LINK_ERRORS |M_ERRNO ,"%s: TCP port read timeout expired" , name); +return false; + } + +/* error */ +if (status <0 ) + { +msg (D_LINK_ERRORS |M_ERRNO ,"%s: TCP port read failed on select()" , name); +return false; + } + +/* read single char */ +const ssize_t size =recv (sd, c,1 ,MSG_NOSIGNAL ); + +/* error? */ +if (size !=1 ) + { +msg (D_LINK_ERRORS |M_ERRNO ,"%s: TCP port read failed on recv()" , name); +return false; + } + +return true; +} + +static bool socks_username_password_auth (struct socks_proxy_info *p,socket_descriptor_t sd,struct event_timeout *server_poll_timeout,volatile int *signal_received)
@@ -121,52 +169,12 @@while (len <2 ) { -int status; -ssize_t size; -fd_set reads; -struct timeval tv;char c; -FD_ZERO (&reads); -openvpn_fd_set (sd, &reads); - tv.tv_sec =get_server_poll_remaining_time (server_poll_timeout); - tv.tv_usec =0 ; - - status =select (sd +1 , &reads,NULL ,NULL , &tv); - -get_signal (signal_received); -if (*signal_received) +if (!socks_proxy_recv_char (&c, __func__, sd, server_poll_timeout, signal_received)) { goto cleanup; } - -/* timeout? */ -if (status ==0 ) - { -msg (D_LINK_ERRORS |M_ERRNO , -"socks_username_password_auth: TCP port read timeout expired" ); - goto cleanup; - } - -/* error */ -if (status <0 ) - { -msg (D_LINK_ERRORS |M_ERRNO , -"socks_username_password_auth: TCP port read failed on select()" ); - goto cleanup; - } - -/* read single char */ - size =recv (sd, &c,1 ,MSG_NOSIGNAL ); - -/* error? */ -if (size !=1 ) - { -msg (D_LINK_ERRORS |M_ERRNO , -"socks_username_password_auth: TCP port read failed on recv()" ); - goto cleanup; - } -/* store char in buffer */ buf[len++] = c; }
@@ -208,49 +216,12 @@while (len <2 ) { -int status; -ssize_t size; -fd_set reads; -struct timeval tv;char c; -FD_ZERO (&reads); -openvpn_fd_set (sd, &reads); - tv.tv_sec =get_server_poll_remaining_time (server_poll_timeout); - tv.tv_usec =0 ; - - status =select (sd +1 , &reads,NULL ,NULL , &tv); - -get_signal (signal_received); -if (*signal_received) +if (!socks_proxy_recv_char (&c, __func__, sd, server_poll_timeout, signal_received)) {return false; } - -/* timeout? */ -if (status ==0 ) - { -msg (D_LINK_ERRORS |M_ERRNO ,"socks_handshake: TCP port read timeout expired" ); -return false; - } - -/* error */ -if (status <0 ) - { -msg (D_LINK_ERRORS |M_ERRNO ,"socks_handshake: TCP port read failed on select()" ); -return false; - } - -/* read single char */ - size =recv (sd, &c,1 ,MSG_NOSIGNAL ); - -/* error? */ -if (size !=1 ) - { -msg (D_LINK_ERRORS |M_ERRNO ,"socks_handshake: TCP port read failed on recv()" ); -return false; - } -/* store char in buffer */ buf[len++] = c; }
@@ -317,54 +288,13 @@while (len <4 + alen +2 ) { -int status; -ssize_t size; -fd_set reads; -struct timeval tv;char c; -FD_ZERO (&reads); -openvpn_fd_set (sd, &reads); - tv.tv_sec =get_server_poll_remaining_time (server_poll_timeout); - tv.tv_usec =0 ; - - status =select (sd +1 , &reads,NULL ,NULL , &tv); - -get_signal (signal_received); -if (*signal_received) +if (!socks_proxy_recv_char (&c, __func__, sd, server_poll_timeout, signal_received)) {return false; } -/* timeout? */ -if (status ==0 ) - { -msg (D_LINK_ERRORS |M_ERRNO ,"recv_socks_reply: TCP port read timeout expired" ); -return false; - } - -/* error */ -if (status <0 ) - { -msg (D_LINK_ERRORS |M_ERRNO ,"recv_socks_reply: TCP port read failed on select()" ); -return false; - } - -/* read single char */ - size =recv (sd, &c,1 ,MSG_NOSIGNAL ); - -/* error? */ -if (size <0 ) - { -msg (D_LINK_ERRORS |M_ERRNO ,"recv_socks_reply: TCP port read failed on recv()" ); -return false; - } -else if (size ==0 ) - { -msg (D_LINK_ERRORS ,"ERROR: recv_socks_reply: empty response from socks server" ); -return false; - } -if (len ==3 ) { atyp = c;
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1165?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I6e848df8104b6e3a6e2c3245ece91a20e473fb40
Gerrit-Change-Number: 1165
Gerrit-PatchSet: 3
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-MessageType: newpatchset
cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/1165?usp=email )
Change subject: socks: factor out socks_proxy_recv_char()
......................................................................
socks: factor out socks_proxy_recv_char()
This is basically identical code duplicated three
times.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1165
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg33171.html
---
M src/openvpn/socks.c
1 file changed, 51 insertions(+), 121 deletions(-)
src/openvpn/socks.c +51 -121
@@ -81,6 +81,54 @@ }static bool +socks_proxy_recv_char (char *c,const char *name,socket_descriptor_t sd, +struct event_timeout *server_poll_timeout, +volatile int *signal_received) +{ +fd_set reads; +FD_ZERO (&reads); +openvpn_fd_set (sd, &reads); + +struct timeval tv; + tv.tv_sec =get_server_poll_remaining_time (server_poll_timeout); + tv.tv_usec =0 ; + +const int status =select (sd +1 , &reads,NULL ,NULL , &tv); + +get_signal (signal_received); +if (*signal_received) + { +return false; + } + +/* timeout? */ +if (status ==0 ) + { +msg (D_LINK_ERRORS |M_ERRNO ,"%s: TCP port read timeout expired" , name); +return false; + } + +/* error */ +if (status <0 ) + { +msg (D_LINK_ERRORS |M_ERRNO ,"%s: TCP port read failed on select()" , name); +return false; + } + +/* read single char */ +const ssize_t size =recv (sd, c,1 ,MSG_NOSIGNAL ); + +/* error? */ +if (size !=1 ) + { +msg (D_LINK_ERRORS |M_ERRNO ,"%s: TCP port read failed on recv()" , name); +return false; + } + +return true; +} + +static bool socks_username_password_auth (struct socks_proxy_info *p,socket_descriptor_t sd,struct event_timeout *server_poll_timeout,volatile int *signal_received)
@@ -121,52 +169,12 @@while (len <2 ) { -int status; -ssize_t size; -fd_set reads; -struct timeval tv;char c; -FD_ZERO (&reads); -openvpn_fd_set (sd, &reads); - tv.tv_sec =get_server_poll_remaining_time (server_poll_timeout); - tv.tv_usec =0 ; - - status =select (sd +1 , &reads,NULL ,NULL , &tv); - -get_signal (signal_received); -if (*signal_received) +if (!socks_proxy_recv_char (&c, __func__, sd, server_poll_timeout, signal_received)) { goto cleanup; } - -/* timeout? */ -if (status ==0 ) - { -msg (D_LINK_ERRORS |M_ERRNO , -"socks_username_password_auth: TCP port read timeout expired" ); - goto cleanup; - } - -/* error */ -if (status <0 ) - { -msg (D_LINK_ERRORS |M_ERRNO , -"socks_username_password_auth: TCP port read failed on select()" ); - goto cleanup; - } - -/* read single char */ - size =recv (sd, &c,1 ,MSG_NOSIGNAL ); - -/* error? */ -if (size !=1 ) - { -msg (D_LINK_ERRORS |M_ERRNO , -"socks_username_password_auth: TCP port read failed on recv()" ); - goto cleanup; - } -/* store char in buffer */ buf[len++] = c; }
@@ -208,49 +216,12 @@while (len <2 ) { -int status; -ssize_t size; -fd_set reads; -struct timeval tv;char c; -FD_ZERO (&reads); -openvpn_fd_set (sd, &reads); - tv.tv_sec =get_server_poll_remaining_time (server_poll_timeout); - tv.tv_usec =0 ; - - status =select (sd +1 , &reads,NULL ,NULL , &tv); - -get_signal (signal_received); -if (*signal_received) +if (!socks_proxy_recv_char (&c, __func__, sd, server_poll_timeout, signal_received)) {return false; } - -/* timeout? */ -if (status ==0 ) - { -msg (D_LINK_ERRORS |M_ERRNO ,"socks_handshake: TCP port read timeout expired" ); -return false; - } - -/* error */ -if (status <0 ) - { -msg (D_LINK_ERRORS |M_ERRNO ,"socks_handshake: TCP port read failed on select()" ); -return false; - } - -/* read single char */ - size =recv (sd, &c,1 ,MSG_NOSIGNAL ); - -/* error? */ -if (size !=1 ) - { -msg (D_LINK_ERRORS |M_ERRNO ,"socks_handshake: TCP port read failed on recv()" ); -return false; - } -/* store char in buffer */ buf[len++] = c; }
@@ -317,54 +288,13 @@while (len <4 + alen +2 ) { -int status; -ssize_t size; -fd_set reads; -struct timeval tv;char c; -FD_ZERO (&reads); -openvpn_fd_set (sd, &reads); - tv.tv_sec =get_server_poll_remaining_time (server_poll_timeout); - tv.tv_usec =0 ; - - status =select (sd +1 , &reads,NULL ,NULL , &tv); - -get_signal (signal_received); -if (*signal_received) +if (!socks_proxy_recv_char (&c, __func__, sd, server_poll_timeout, signal_received)) {return false; } -/* timeout? */ -if (status ==0 ) - { -msg (D_LINK_ERRORS |M_ERRNO ,"recv_socks_reply: TCP port read timeout expired" ); -return false; - } - -/* error */ -if (status <0 ) - { -msg (D_LINK_ERRORS |M_ERRNO ,"recv_socks_reply: TCP port read failed on select()" ); -return false; - } - -/* read single char */ - size =recv (sd, &c,1 ,MSG_NOSIGNAL ); - -/* error? */ -if (size <0 ) - { -msg (D_LINK_ERRORS |M_ERRNO ,"recv_socks_reply: TCP port read failed on recv()" ); -return false; - } -else if (size ==0 ) - { -msg (D_LINK_ERRORS ,"ERROR: recv_socks_reply: empty response from socks server" ); -return false; - } -if (len ==3 ) { atyp = c;
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1165?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I6e848df8104b6e3a6e2c3245ece91a20e473fb40
Gerrit-Change-Number: 1165
Gerrit-PatchSet: 3
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-MessageType: merged