From 4739189cfc8b60934f14b734f76a61abfad797fb Mon Sep 17 00:00:00 2001 From: Christian Plattner Date: Tue, 24 Apr 2018 16:35:04 +0200 Subject: [PATCH] Implement BIO_ctrl more correctly for RDG See #3602 This change is discussed in https://github.com/FreeRDP/FreeRDP/pull/4576#pullrequestreview-113381733 --- libfreerdp/core/gateway/rdg.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/libfreerdp/core/gateway/rdg.c b/libfreerdp/core/gateway/rdg.c index c7b2e5b57..5ed72f5f4 100644 --- a/libfreerdp/core/gateway/rdg.c +++ b/libfreerdp/core/gateway/rdg.c @@ -1526,7 +1526,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; @@ -1537,14 +1537,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; @@ -1583,9 +1575,10 @@ static long rdg_bio_ctrl(BIO* bio, int cmd, long arg1, void* arg2) else status = 1; } - else if (cmd == BIO_C_GET_FD) + 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