Merge pull request #1989 from bmiklautz/feat/fast-path

core: improve fast-path multifragment handling
This commit is contained in:
Hardening 2014-07-24 18:10:50 +02:00
commit fb4a64bc4a
3 changed files with 30 additions and 2 deletions

View File

@ -22,6 +22,7 @@
#endif
#include "capabilities.h"
#include "fastpath.h"
#include <winpr/crt.h>
#include <winpr/rpc.h>
@ -2287,6 +2288,17 @@ BOOL rdp_read_multifragment_update_capability_set(wStream* s, UINT16 length, rdp
if (settings->ServerMode)
{
/*
* Special case: The client announces multifragment update support but sets the maximum request size
* to something smaller than maximum size for *one* fast-path PDU.
* In this case behave like no multifragment updates were supported and make sure no
* fragmentation happens by setting FASTPATH_FRAGMENT_SAFE_SIZE.
*
* This behaviour was observed with some windows ce rdp clients.
*/
if (multifragMaxRequestSize < FASTPATH_MAX_PACKET_SIZE)
multifragMaxRequestSize = FASTPATH_FRAGMENT_SAFE_SIZE;
if (settings->RemoteFxCodec)
{
/**
@ -3669,7 +3681,8 @@ BOOL rdp_recv_confirm_active(rdpRdp* rdp, wStream* s)
if (!settings->ReceivedCapabilities[CAPSET_TYPE_MULTI_FRAGMENT_UPDATE])
{
/* client does not support multi fragment updates */
/* client does not support multi fragment updates - make sure packages are not fragmented */
settings->MultifragMaxRequestSize = FASTPATH_FRAGMENT_SAFE_SIZE;
}
if (!settings->ReceivedCapabilities[CAPSET_TYPE_LARGE_POINTER])

View File

@ -48,7 +48,6 @@
* two less significant bits of the first byte.
*/
#define FASTPATH_MAX_PACKET_SIZE 0x3FFF
#ifdef WITH_DEBUG_RDP
static const char* const FASTPATH_UPDATETYPE_STRINGS[] =

View File

@ -20,6 +20,22 @@
#ifndef __FASTPATH_H
#define __FASTPATH_H
/*
* Fast-Path has 15 bits available for length information which would lead to a
* maximal pdu size of 0x8000. However in practice only 14 bits are used
* this isn't documented anywhere but it looks like most implementations will
* fail if fast-path packages > 0x3FFF arrive.
*/
#define FASTPATH_MAX_PACKET_SIZE 0x3FFF
/*
* The following size guarantees that no fast-path PDU fragmentation occurs.
* It was calculated by subtracting 128 from FASTPATH_MAX_PACKET_SIZE.
* 128 was chosen because it includes all required and optional headers as well as
* possible paddings and some extra bytes for safety.
*/
#define FASTPATH_FRAGMENT_SAFE_SIZE 0x3F80
typedef struct rdp_fastpath rdpFastPath;
#include "rdp.h"