TSG_PACKET_VERSIONCAPS packetVersionCaps;
};
+static BOOL tsg_stream_align(wStream* s)
+{
+ size_t pos;
+ size_t offset = 0;
+
+ if (!s)
+ return FALSE;
+
+ pos = Stream_GetPosition(s);
+
+ if ((pos % 4) != 0)
+ offset = 4 - pos % 4;
+
+ return Stream_SafeSeek(s, offset);
+}
+
static BIO_METHOD* BIO_s_tsg(void);
/**
* RPC Functions: http://msdn.microsoft.com/en-us/library/windows/desktop/aa378623/
goto fail;
/* 4-byte alignment */
- {
- UINT32 offset = Stream_GetPosition(pdu->s);
-
- if (!Stream_SafeSeek(pdu->s, rpc_offset_align(&offset, 4)))
- goto fail;
- }
+ if (!tsg_stream_align(pdu->s))
+ goto fail;
}
else
{
Stream_Read_UINT16(pdu->s, versionCaps->minorVersion); /* MinorVersion (2 bytes) */
Stream_Read_UINT16(pdu->s,
versionCaps->quarantineCapabilities); /* QuarantineCapabilities (2 bytes) */
- /* 4-byte alignment */
- {
- size_t loffset = Stream_GetPosition(pdu->s);
- UINT32 offset = (UINT32) loffset;
- if (loffset > UINT32_MAX)
- goto fail;
+ /* 4-byte alignment */
+ if (!tsg_stream_align(pdu->s))
+ goto fail;
- if (!Stream_SafeSeek(pdu->s, rpc_offset_align(&offset, 4)))
- goto fail;
- }
tsgCaps = (PTSG_PACKET_CAPABILITIES) calloc(1, sizeof(TSG_PACKET_CAPABILITIES));
if (!tsgCaps)
case TSG_ASYNC_MESSAGE_REAUTH:
{
- size_t loffset = Stream_GetPosition(pdu->s);
- UINT32 offset = (UINT32)loffset;
-
- if (loffset > UINT32_MAX)
- goto fail;
-
- if (!Stream_SafeSeek(pdu->s, rpc_offset_align(&offset, 8) ||
- (Stream_GetRemainingLength(pdu->s) < 8)))
+ if (!tsg_stream_align(pdu->s))
goto fail;
Stream_Seek_UINT64(pdu->s); /* TunnelContext (8 bytes) */
goto fail;
}
- {
- UINT32 offset = Stream_GetPosition(pdu->s);
-
- if (!Stream_SafeSeek(pdu->s, rpc_offset_align(&offset, 4)))
- goto fail;
- }
+ if (!tsg_stream_align(pdu->s))
+ goto fail;
/* TunnelContext (20 bytes) */
if (Stream_GetRemainingLength(pdu->s) < 24)
goto fail;
/* 4-byte alignment */
- {
- UINT32 offset = Stream_GetPosition(pdu->s);
-
- if (!Stream_SafeSeek(pdu->s, rpc_offset_align(&offset, 4)))
- goto fail;
- }
+ if (!tsg_stream_align(pdu->s))
+ goto fail;
}
else
{
Stream_Read_UINT16(pdu->s, versionCaps->majorVersion); /* MinorVersion (2 bytes) */
Stream_Read_UINT16(pdu->s,
versionCaps->quarantineCapabilities); /* QuarantineCapabilities (2 bytes) */
- /* 4-byte alignment */
- {
- UINT32 offset = Stream_GetPosition(pdu->s);
- if (!Stream_SafeSeek(pdu->s, rpc_offset_align(&offset, 4)))
- goto fail;
- }
+ /* 4-byte alignment */
+ if (!tsg_stream_align(pdu->s))
+ goto fail;
if (Stream_GetRemainingLength(pdu->s) < 36)
goto fail;
count = _wcslen(tsg->MachineName) + 1;
rpc = tsg->rpc;
WLog_DBG(TAG, "TsProxyAuthorizeTunnelWriteRequest");
- s = Stream_New(NULL, 1024);
+ s = Stream_New(NULL, 1024 + count * 2);
if (!s)
return FALSE;
BOOL tsg_check_event_handles(rdpTsg* tsg)
{
- if (!rpc_client_in_channel_recv(tsg->rpc))
+ if (rpc_client_in_channel_recv(tsg->rpc) < 0)
return FALSE;
- if (!rpc_client_out_channel_recv(tsg->rpc))
+ if (rpc_client_out_channel_recv(tsg->rpc) < 0)
return FALSE;
return TRUE;