tpkt_ensure_stream_consumed now more verbose.

tpkt_ensure_stream_consumed now writes the function it was called
from to the log. This should help identify areas the check failed.
This commit is contained in:
Armin Novak 2020-03-05 11:16:56 +01:00 committed by akallabeth
parent 5facf708dc
commit 8e55c44088
2 changed files with 7 additions and 4 deletions

View File

@ -129,13 +129,14 @@ BOOL tpkt_read_header(wStream* s, UINT16* length)
return TRUE;
}
BOOL tpkt_ensure_stream_consumed(wStream* s, UINT16 length)
BOOL tpkt_ensure_stream_consumed_(wStream* s, UINT16 length, const char* fkt)
{
size_t rem = Stream_GetRemainingLength(s);
if (rem > 0)
{
WLog_ERR(TAG, "Received invalid TPKT header length %" PRIu16 ", %" PRIdz " bytes too long!",
length, rem);
WLog_ERR(TAG,
"[%s] Received invalid TPKT header length %" PRIu16 ", %" PRIdz " bytes too long!",
fkt, length, rem);
return FALSE;
}
return TRUE;

View File

@ -31,6 +31,8 @@
FREERDP_LOCAL BOOL tpkt_verify_header(wStream* s);
FREERDP_LOCAL BOOL tpkt_read_header(wStream* s, UINT16* length);
FREERDP_LOCAL void tpkt_write_header(wStream* s, UINT16 length);
FREERDP_LOCAL BOOL tpkt_ensure_stream_consumed(wStream* s, UINT16 length);
#define tpkt_ensure_stream_consumed(s, length) \
tpkt_ensure_stream_consumed_((s), (length), __FUNCTION__)
FREERDP_LOCAL BOOL tpkt_ensure_stream_consumed_(wStream* s, UINT16 length, const char* fkt);
#endif /* FREERDP_LIB_CORE_TPKT_H */