mirror of
https://github.com/morgan9e/FreeRDP
synced 2026-04-15 00:44:19 +09:00
Merge pull request #12376 from akallabeth/gw-fix
Gateway & platform fixes
This commit is contained in:
@@ -691,7 +691,10 @@ static SSIZE_T rpc_client_default_out_channel_recv(rdpRpc* rpc)
|
|||||||
Stream_SetPosition(fragment, 0);
|
Stream_SetPosition(fragment, 0);
|
||||||
|
|
||||||
/* Ignore errors, the PDU might not be complete. */
|
/* Ignore errors, the PDU might not be complete. */
|
||||||
(void)rts_read_common_pdu_header(fragment, &header, TRUE);
|
const rts_pdu_status_t rc = rts_read_common_pdu_header(fragment, &header, TRUE);
|
||||||
|
if (rc == RTS_PDU_FAIL)
|
||||||
|
return -1;
|
||||||
|
|
||||||
Stream_SetPosition(fragment, pos);
|
Stream_SetPosition(fragment, pos);
|
||||||
|
|
||||||
if (header.frag_length > rpc->max_recv_frag)
|
if (header.frag_length > rpc->max_recv_frag)
|
||||||
@@ -978,19 +981,19 @@ static void rpc_array_client_call_free(void* call)
|
|||||||
|
|
||||||
int rpc_in_channel_send_pdu(RpcInChannel* inChannel, const BYTE* buffer, size_t length)
|
int rpc_in_channel_send_pdu(RpcInChannel* inChannel, const BYTE* buffer, size_t length)
|
||||||
{
|
{
|
||||||
SSIZE_T status = 0;
|
|
||||||
RpcClientCall* clientCall = NULL;
|
RpcClientCall* clientCall = NULL;
|
||||||
wStream s;
|
wStream s = Stream_Init();
|
||||||
rpcconn_common_hdr_t header = WINPR_C_ARRAY_INIT;
|
rpcconn_common_hdr_t header = WINPR_C_ARRAY_INIT;
|
||||||
|
|
||||||
status = rpc_channel_write(&inChannel->common, buffer, length);
|
SSIZE_T status = rpc_channel_write(&inChannel->common, buffer, length);
|
||||||
|
|
||||||
if (status <= 0)
|
if (status <= 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
Stream_StaticConstInit(&s, buffer, length);
|
Stream_StaticConstInit(&s, buffer, length);
|
||||||
if (!rts_read_common_pdu_header(&s, &header, FALSE))
|
const rts_pdu_status_t rc = rts_read_common_pdu_header(&s, &header, FALSE);
|
||||||
return -1;
|
if (rc != RTS_PDU_VALID)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
clientCall = rpc_client_call_find_by_id(inChannel->common.client, header.call_id);
|
clientCall = rpc_client_call_find_by_id(inChannel->common.client, header.call_id);
|
||||||
if (!clientCall)
|
if (!clientCall)
|
||||||
|
|||||||
@@ -221,7 +221,8 @@ static BOOL rts_write_common_pdu_header(wStream* s, const rpcconn_common_hdr_t*
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL rts_read_common_pdu_header(wStream* s, rpcconn_common_hdr_t* header, BOOL ignoreErrors)
|
rts_pdu_status_t rts_read_common_pdu_header(wStream* s, rpcconn_common_hdr_t* header,
|
||||||
|
BOOL ignoreErrors)
|
||||||
{
|
{
|
||||||
WINPR_ASSERT(s);
|
WINPR_ASSERT(s);
|
||||||
WINPR_ASSERT(header);
|
WINPR_ASSERT(header);
|
||||||
@@ -229,13 +230,13 @@ BOOL rts_read_common_pdu_header(wStream* s, rpcconn_common_hdr_t* header, BOOL i
|
|||||||
if (!ignoreErrors)
|
if (!ignoreErrors)
|
||||||
{
|
{
|
||||||
if (!Stream_CheckAndLogRequiredLength(TAG, s, sizeof(rpcconn_common_hdr_t)))
|
if (!Stream_CheckAndLogRequiredLength(TAG, s, sizeof(rpcconn_common_hdr_t)))
|
||||||
return FALSE;
|
return RTS_PDU_INCOMPLETE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const size_t sz = Stream_GetRemainingLength(s);
|
const size_t sz = Stream_GetRemainingLength(s);
|
||||||
if (sz < sizeof(rpcconn_common_hdr_t))
|
if (sz < sizeof(rpcconn_common_hdr_t))
|
||||||
return FALSE;
|
return RTS_PDU_INCOMPLETE;
|
||||||
}
|
}
|
||||||
|
|
||||||
Stream_Read_UINT8(s, header->rpc_vers);
|
Stream_Read_UINT8(s, header->rpc_vers);
|
||||||
@@ -252,22 +253,22 @@ BOOL rts_read_common_pdu_header(wStream* s, rpcconn_common_hdr_t* header, BOOL i
|
|||||||
if (!ignoreErrors)
|
if (!ignoreErrors)
|
||||||
WLog_WARN(TAG, "Invalid header->frag_length of %" PRIu16 ", expected %" PRIuz,
|
WLog_WARN(TAG, "Invalid header->frag_length of %" PRIu16 ", expected %" PRIuz,
|
||||||
header->frag_length, sizeof(rpcconn_common_hdr_t));
|
header->frag_length, sizeof(rpcconn_common_hdr_t));
|
||||||
return FALSE;
|
return RTS_PDU_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ignoreErrors)
|
if (!ignoreErrors)
|
||||||
{
|
{
|
||||||
if (!Stream_CheckAndLogRequiredLength(TAG, s,
|
if (!Stream_CheckAndLogRequiredLength(TAG, s,
|
||||||
header->frag_length - sizeof(rpcconn_common_hdr_t)))
|
header->frag_length - sizeof(rpcconn_common_hdr_t)))
|
||||||
return FALSE;
|
return RTS_PDU_INCOMPLETE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const size_t sz2 = Stream_GetRemainingLength(s);
|
const size_t sz2 = Stream_GetRemainingLength(s);
|
||||||
if (sz2 < header->frag_length - sizeof(rpcconn_common_hdr_t))
|
if (sz2 < header->frag_length - sizeof(rpcconn_common_hdr_t))
|
||||||
return FALSE;
|
return RTS_PDU_INCOMPLETE;
|
||||||
}
|
}
|
||||||
return TRUE;
|
return RTS_PDU_VALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
static BOOL rts_read_auth_verifier_no_checks(wStream* s, auth_verifier_co_t* auth,
|
static BOOL rts_read_auth_verifier_no_checks(wStream* s, auth_verifier_co_t* auth,
|
||||||
@@ -1189,7 +1190,8 @@ BOOL rts_read_pdu_header_ex(wStream* s, rpcconn_hdr_t* header, BOOL silent)
|
|||||||
WINPR_ASSERT(s);
|
WINPR_ASSERT(s);
|
||||||
WINPR_ASSERT(header);
|
WINPR_ASSERT(header);
|
||||||
|
|
||||||
if (!rts_read_common_pdu_header(s, &header->common, silent))
|
const rts_pdu_status_t status = rts_read_common_pdu_header(s, &header->common, silent);
|
||||||
|
if (status != RTS_PDU_VALID)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
WLog_DBG(TAG, "Reading PDU type %s", rts_pdu_ptype_to_string(header->common.ptype));
|
WLog_DBG(TAG, "Reading PDU type %s", rts_pdu_ptype_to_string(header->common.ptype));
|
||||||
|
|||||||
@@ -93,9 +93,16 @@ FREERDP_LOCAL BOOL rts_read_pdu_header_ex(wStream* s, rpcconn_hdr_t* header, BOO
|
|||||||
|
|
||||||
FREERDP_LOCAL void rts_free_pdu_header(rpcconn_hdr_t* header, BOOL allocated);
|
FREERDP_LOCAL void rts_free_pdu_header(rpcconn_hdr_t* header, BOOL allocated);
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
RTS_PDU_FAIL = -1,
|
||||||
|
RTS_PDU_INCOMPLETE = 0,
|
||||||
|
RTS_PDU_VALID = 1
|
||||||
|
} rts_pdu_status_t;
|
||||||
|
|
||||||
WINPR_ATTR_NODISCARD
|
WINPR_ATTR_NODISCARD
|
||||||
FREERDP_LOCAL BOOL rts_read_common_pdu_header(wStream* s, rpcconn_common_hdr_t* header,
|
FREERDP_LOCAL rts_pdu_status_t rts_read_common_pdu_header(wStream* s, rpcconn_common_hdr_t* header,
|
||||||
BOOL ignoreErrors);
|
BOOL ignoreErrors);
|
||||||
|
|
||||||
WINPR_ATTR_NODISCARD
|
WINPR_ATTR_NODISCARD
|
||||||
FREERDP_LOCAL BOOL rts_command_length(UINT32 CommandType, wStream* s, size_t* length, BOOL silent);
|
FREERDP_LOCAL BOOL rts_command_length(UINT32 CommandType, wStream* s, size_t* length, BOOL silent);
|
||||||
|
|||||||
@@ -626,7 +626,11 @@ WINPR_PRAGMA_DIAG_POP
|
|||||||
#define WINPR_ATTR_MALLOC(deallocator, ptrindex) \
|
#define WINPR_ATTR_MALLOC(deallocator, ptrindex) \
|
||||||
__attribute__((malloc, warn_unused_result)) /** @since version 3.3.0 */
|
__attribute__((malloc, warn_unused_result)) /** @since version 3.3.0 */
|
||||||
#endif
|
#endif
|
||||||
#elif defined(__GNUC__) && (__GNUC__ > 10)
|
#elif defined(__GNUC__)
|
||||||
|
#if (__GNUC__ <= 10)
|
||||||
|
#define WINPR_ATTR_MALLOC(deallocator, ptrindex) \
|
||||||
|
__attribute__((malloc, warn_unused_result)) /** @since version 3.3.0 */
|
||||||
|
#else
|
||||||
#if defined(__cplusplus) && (__cplusplus >= 201703L)
|
#if defined(__cplusplus) && (__cplusplus >= 201703L)
|
||||||
#define WINPR_ATTR_MALLOC(deallocator, ptrindex) \
|
#define WINPR_ATTR_MALLOC(deallocator, ptrindex) \
|
||||||
[[gnu::malloc(deallocator, ptrindex), nodiscard]] /** @since version 3.3.0 */
|
[[gnu::malloc(deallocator, ptrindex), nodiscard]] /** @since version 3.3.0 */
|
||||||
@@ -637,6 +641,7 @@ WINPR_PRAGMA_DIAG_POP
|
|||||||
#define WINPR_ATTR_MALLOC(deallocator, ptrindex) \
|
#define WINPR_ATTR_MALLOC(deallocator, ptrindex) \
|
||||||
__attribute__((malloc(deallocator, ptrindex), warn_unused_result)) /** @since version 3.3.0 */
|
__attribute__((malloc(deallocator, ptrindex), warn_unused_result)) /** @since version 3.3.0 */
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
#elif defined(_MSC_VER)
|
#elif defined(_MSC_VER)
|
||||||
#define WINPR_ATTR_MALLOC(deallocator, ptrindex) __declspec(restrict) /** @since version 3.3.0 */
|
#define WINPR_ATTR_MALLOC(deallocator, ptrindex) __declspec(restrict) /** @since version 3.3.0 */
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user