diff --git a/libfreerdp/core/gateway/rdg.c b/libfreerdp/core/gateway/rdg.c index 905217de6..68762e54b 100755 --- a/libfreerdp/core/gateway/rdg.c +++ b/libfreerdp/core/gateway/rdg.c @@ -1146,7 +1146,7 @@ static int rdg_bio_gets(BIO* bio, char* str, int size) static long rdg_bio_ctrl(BIO* bio, int cmd, long arg1, void* arg2) { - int status = 0; + int status = -1; rdpRdg* rdg = (rdpRdg*) BIO_get_data(bio); rdpTls* tlsOut = rdg->tlsOut; rdpTls* tlsIn = rdg->tlsIn; @@ -1157,14 +1157,6 @@ static long rdg_bio_ctrl(BIO* bio, int cmd, long arg1, void* arg2) (void)BIO_flush(tlsIn->bio); status = 1; } - else if (cmd == BIO_C_GET_EVENT) - { - if (arg2) - { - BIO_get_event(rdg->tlsOut->bio, arg2); - status = 1; - } - } else if (cmd == BIO_C_SET_NONBLOCK) { status = 1; @@ -1203,6 +1195,18 @@ static long rdg_bio_ctrl(BIO* bio, int cmd, long arg1, void* arg2) else status = 1; } + else if (cmd == BIO_C_GET_EVENT || cmd == BIO_C_GET_FD) + { + /* + * A note about BIO_C_GET_FD: + * Even if two FDs are part of RDG, only one FD can be returned here. + * + * In FreeRDP, BIO FDs are only used for polling, so it is safe to use the outgoing FD only + * + * See issue #3602 + */ + status = BIO_ctrl(tlsOut->bio, cmd, arg1, arg2); + } return status; } diff --git a/libfreerdp/core/gateway/tsg.c b/libfreerdp/core/gateway/tsg.c index ca6f7f3ce..737256070 100644 --- a/libfreerdp/core/gateway/tsg.c +++ b/libfreerdp/core/gateway/tsg.c @@ -1920,7 +1920,7 @@ static int transport_bio_tsg_gets(BIO* bio, char* str, int size) static long transport_bio_tsg_ctrl(BIO* bio, int cmd, long arg1, void* arg2) { - int status = 0; + int status = -1; rdpTsg* tsg = (rdpTsg*) BIO_get_data(bio); RpcVirtualConnection* connection = tsg->rpc->VirtualConnection; RpcInChannel* inChannel = connection->DefaultInChannel; diff --git a/libfreerdp/crypto/tls.c b/libfreerdp/crypto/tls.c index 4da3df6a4..24235d4ce 100644 --- a/libfreerdp/crypto/tls.c +++ b/libfreerdp/crypto/tls.c @@ -737,7 +737,7 @@ static int tls_do_handshake(rdpTls* tls, BOOL clientMode) do { - status = poll(&pollfds, 1, 10 * 1000); + status = poll(&pollfds, 1, 10); } while ((status < 0) && (errno == EINTR));