[core,gateway] respect abortEvent
in RDG read functions check for rdpContext::abortEvent and terminate blocking functions if set.
This commit is contained in:
parent
64b42be79e
commit
67eb2fce54
@ -357,7 +357,13 @@ static int rdg_socket_read(BIO* bio, BYTE* pBuffer, size_t size,
|
||||
}
|
||||
}
|
||||
|
||||
static BOOL rdg_read_all(rdpTls* tls, BYTE* buffer, size_t size,
|
||||
static BOOL rdg_shall_abort(rdpRdg* rdg)
|
||||
{
|
||||
WINPR_ASSERT(rdg);
|
||||
return freerdp_shall_disconnect_context(rdg->context);
|
||||
}
|
||||
|
||||
static BOOL rdg_read_all(rdpContext* context, rdpTls* tls, BYTE* buffer, size_t size,
|
||||
rdg_http_encoding_context* transferEncoding)
|
||||
{
|
||||
size_t readCount = 0;
|
||||
@ -365,6 +371,9 @@ static BOOL rdg_read_all(rdpTls* tls, BYTE* buffer, size_t size,
|
||||
|
||||
while (readCount < size)
|
||||
{
|
||||
if (freerdp_shall_disconnect_context(context))
|
||||
return FALSE;
|
||||
|
||||
int status = rdg_socket_read(tls->bio, pBuffer, size - readCount, transferEncoding);
|
||||
if (status <= 0)
|
||||
{
|
||||
@ -391,7 +400,7 @@ static wStream* rdg_receive_packet(rdpRdg* rdg)
|
||||
if (!s)
|
||||
return NULL;
|
||||
|
||||
if (!rdg_read_all(rdg->tlsOut, Stream_Buffer(s), header, &rdg->transferEncoding))
|
||||
if (!rdg_read_all(rdg->context, rdg->tlsOut, Stream_Buffer(s), header, &rdg->transferEncoding))
|
||||
{
|
||||
Stream_Free(s, TRUE);
|
||||
return NULL;
|
||||
@ -407,8 +416,8 @@ static wStream* rdg_receive_packet(rdpRdg* rdg)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!rdg_read_all(rdg->tlsOut, Stream_Buffer(s) + header, (int)packetLength - (int)header,
|
||||
&rdg->transferEncoding))
|
||||
if (!rdg_read_all(rdg->context, rdg->tlsOut, Stream_Buffer(s) + header,
|
||||
(int)packetLength - (int)header, &rdg->transferEncoding))
|
||||
{
|
||||
Stream_Free(s, TRUE);
|
||||
return NULL;
|
||||
@ -741,7 +750,7 @@ static BOOL rdg_recv_auth_token(wLog* log, rdpCredsspAuth* auth, HttpResponse* r
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static BOOL rdg_skip_seed_payload(rdpTls* tls, SSIZE_T lastResponseLength,
|
||||
static BOOL rdg_skip_seed_payload(rdpContext* context, rdpTls* tls, SSIZE_T lastResponseLength,
|
||||
rdg_http_encoding_context* transferEncoding)
|
||||
{
|
||||
BYTE seed_payload[10] = { 0 };
|
||||
@ -752,7 +761,7 @@ static BOOL rdg_skip_seed_payload(rdpTls* tls, SSIZE_T lastResponseLength,
|
||||
*/
|
||||
if (lastResponseLength < (SSIZE_T)size)
|
||||
{
|
||||
if (!rdg_read_all(tls, seed_payload, size - lastResponseLength, transferEncoding))
|
||||
if (!rdg_read_all(context, tls, seed_payload, size - lastResponseLength, transferEncoding))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
@ -1487,7 +1496,7 @@ static BOOL rdg_establish_data_connection(rdpRdg* rdg, rdpTls* tls, const char*
|
||||
rdg->transferEncoding.context.chunked.headerFooterPos = 0;
|
||||
rdg->transferEncoding.context.chunked.state = ChunkStateLenghHeader;
|
||||
}
|
||||
if (!rdg_skip_seed_payload(tls, bodyLength, &rdg->transferEncoding))
|
||||
if (!rdg_skip_seed_payload(rdg->context, tls, bodyLength, &rdg->transferEncoding))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
@ -1840,6 +1849,11 @@ static BOOL rdg_process_control_packet(rdpRdg* rdg, int type, size_t packetLengt
|
||||
|
||||
while (readCount < payloadSize)
|
||||
{
|
||||
if (rdg_shall_abort(rdg))
|
||||
{
|
||||
Stream_Free(s, TRUE);
|
||||
return FALSE;
|
||||
}
|
||||
status = rdg_socket_read(rdg->tlsOut->bio, Stream_Pointer(s), payloadSize - readCount,
|
||||
&rdg->transferEncoding);
|
||||
|
||||
@ -1913,6 +1927,9 @@ static int rdg_read_data_packet(rdpRdg* rdg, BYTE* buffer, int size)
|
||||
|
||||
while (readCount < sizeof(RdgPacketHeader))
|
||||
{
|
||||
if (rdg_shall_abort(rdg))
|
||||
return -1;
|
||||
|
||||
status = rdg_socket_read(rdg->tlsOut->bio, (BYTE*)(&header) + readCount,
|
||||
(int)sizeof(RdgPacketHeader) - (int)readCount,
|
||||
&rdg->transferEncoding);
|
||||
@ -1949,6 +1966,8 @@ static int rdg_read_data_packet(rdpRdg* rdg, BYTE* buffer, int size)
|
||||
|
||||
while (readCount < 2)
|
||||
{
|
||||
if (rdg_shall_abort(rdg))
|
||||
return -1;
|
||||
status =
|
||||
rdg_socket_read(rdg->tlsOut->bio, (BYTE*)(&rdg->packetRemainingCount) + readCount,
|
||||
2 - (int)readCount, &rdg->transferEncoding);
|
||||
|
Loading…
Reference in New Issue
Block a user