Skip to content

Commit

Permalink
Send correct packet size in case of PAA. Some cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
p-pautov committed Apr 17, 2018
1 parent bbee19c commit 8fc0ea7
Showing 1 changed file with 15 additions and 21 deletions.
36 changes: 15 additions & 21 deletions libfreerdp/core/gateway/rdg.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@ static BOOL rdg_send_tunnel_request(rdpRdg* rdg)
{
wStream* s;
BOOL status;
UINT32 packetSize = 16;
UINT16 fieldsPresent = 0;
WCHAR* PAACookie = NULL;
UINT16 PAACookieLen = 0;

Expand All @@ -175,39 +177,31 @@ static BOOL rdg_send_tunnel_request(rdpRdg* rdg)
if (!PAACookie)
return FALSE;

s = Stream_New(NULL, 16 + 2 + 2 * PAACookieLen);

if (!s)
{
free(PAACookie);
return FALSE;
}
packetSize += 2 + PAACookieLen * sizeof(WCHAR);
fieldsPresent = HTTP_TUNNEL_PACKET_FIELD_PAA_COOKIE;
}
else
{
s = Stream_New(NULL, 16);

if (!s)
return FALSE;
s = Stream_New(NULL, packetSize);

if (!s)
{
free(PAACookie);
return FALSE;
}

Stream_Write_UINT16(s, PKT_TYPE_TUNNEL_CREATE); /* Type (2 bytes) */
Stream_Write_UINT16(s, 0); /* Reserved (2 bytes) */
Stream_Write_UINT32(s, 16); /* PacketLength (4 bytes) */
Stream_Write_UINT32(s, packetSize); /* PacketLength (4 bytes) */

Stream_Write_UINT32(s, HTTP_CAPABILITY_TYPE_QUAR_SOH); /* CapabilityFlags (4 bytes) */
Stream_Write_UINT16(s, fieldsPresent); /* FieldsPresent (2 bytes) */
Stream_Write_UINT16(s, 0); /* Reserved (2 bytes), must be 0 */

if (rdg->extAuth == HTTP_EXTENDED_AUTH_PAA)
if (PAACookie)
{
Stream_Write_UINT16(s, 1); /* FieldsPresent (2 bytes) */
Stream_Write_UINT16(s, 0); /* Reserved (2 bytes), must be 0 */
Stream_Write_UINT16(s, PAACookieLen * 2); /* PAA cookie string length */
Stream_Write_UTF16_String(s, PAACookie, PAACookieLen);
}
else
{
Stream_Write_UINT16(s, 0); /* FieldsPresent (2 bytes) */
Stream_Write_UINT16(s, 0); /* Reserved (2 bytes), must be 0 */
}

Stream_SealLength(s);
status = rdg_write_packet(rdg, s);
Expand Down

0 comments on commit 8fc0ea7

Please sign in to comment.