mirror of https://github.com/FreeRDP/FreeRDP
Use Stream_CheckAndLogRequiredLength, fix WLog TAG
* Log stream length requirement violations * Use proper defines for WLog tags
This commit is contained in:
parent
43eccb6247
commit
dacebc62a3
|
@ -157,7 +157,7 @@ static UINT rdpsnd_server_recv_quality_mode(RdpsndServerContext* context, wStrea
|
|||
{
|
||||
WINPR_ASSERT(context);
|
||||
|
||||
if (Stream_GetRemainingLength(s) < 4)
|
||||
if (!Stream_CheckAndLogRequiredLength(TAG, s, 4))
|
||||
{
|
||||
WLog_ERR(TAG, "not enough data in stream!");
|
||||
return ERROR_INVALID_DATA;
|
||||
|
|
|
@ -125,11 +125,8 @@ static UINT telemetry_server_recv_rdp_telemetry_pdu(TelemetryServerContext* cont
|
|||
TELEMETRY_RDP_TELEMETRY_PDU pdu;
|
||||
UINT error = CHANNEL_RC_OK;
|
||||
|
||||
if (Stream_GetRemainingLength(s) < 16)
|
||||
{
|
||||
WLog_ERR(TAG, "telemetry_server_recv_rdp_telemetry_pdu: Not enough data!");
|
||||
if (!Stream_CheckAndLogRequiredLength(TAG, s, 16))
|
||||
return ERROR_NO_DATA;
|
||||
}
|
||||
|
||||
Stream_Read_UINT32(s, pdu.PromptForCredentialsMillis);
|
||||
Stream_Read_UINT32(s, pdu.PromptForCredentialsDoneMillis);
|
||||
|
|
|
@ -78,7 +78,7 @@ UINT tsmf_ifman_exchange_capability_request(TSMF_IFMAN* ifman)
|
|||
if (!Stream_EnsureRemainingCapacity(ifman->output, ifman->input_size + 4))
|
||||
return ERROR_OUTOFMEMORY;
|
||||
|
||||
if (Stream_GetRemainingLength(ifman->input) < ifman->input_size)
|
||||
if (!Stream_CheckAndLogRequiredLength(TAG, ifman->input, ifman->input_size))
|
||||
return ERROR_INVALID_DATA;
|
||||
|
||||
pos = Stream_GetPosition(ifman->output);
|
||||
|
|
|
@ -26,7 +26,8 @@
|
|||
#include "../codec/ncrush.h"
|
||||
#include "../codec/xcrush.h"
|
||||
|
||||
#define TAG "com.freerdp.core"
|
||||
#include <freerdp/log.h>
|
||||
#define TAG FREERDP_TAG("core")
|
||||
|
||||
//#define WITH_BULK_DEBUG 1
|
||||
|
||||
|
|
|
@ -1577,7 +1577,7 @@ BOOL WINAPI FreeRDP_WTSVirtualChannelWrite(HANDLE hChannelHandle, PCHAR Buffer,
|
|||
Stream_Seek_UINT8(s);
|
||||
cbChId = wts_write_variable_uint(s, channel->channelId);
|
||||
|
||||
if (first && (Length > (UINT32)Stream_GetRemainingLength(s)))
|
||||
if (first && (Length > Stream_GetRemainingLength(s)))
|
||||
{
|
||||
cbLen = wts_write_variable_uint(s, Length);
|
||||
buffer[0] = (DATA_FIRST_PDU << 4) | (cbLen << 2) | cbChId;
|
||||
|
|
|
@ -23,7 +23,8 @@
|
|||
#include <winpr/wlog.h>
|
||||
#include <winpr/crt.h>
|
||||
|
||||
#define TAG "winpr.asn1"
|
||||
#include "../../log.h"
|
||||
#define TAG WINPR_TAG("asn1")
|
||||
|
||||
typedef struct
|
||||
{
|
||||
|
@ -892,7 +893,7 @@ static size_t readLen(wStream* s, size_t* len, BOOL derCheck)
|
|||
size_t retLen;
|
||||
size_t ret = 0;
|
||||
|
||||
if (Stream_GetRemainingLength(s) < 1)
|
||||
if (!Stream_CheckAndLogRequiredLength(TAG, s, 1))
|
||||
return 0;
|
||||
|
||||
Stream_Read_UINT8(s, retLen);
|
||||
|
@ -902,7 +903,7 @@ static size_t readLen(wStream* s, size_t* len, BOOL derCheck)
|
|||
BYTE tmp;
|
||||
size_t nBytes = (retLen & 0x7f);
|
||||
|
||||
if (Stream_GetRemainingLength(s) < nBytes)
|
||||
if (!Stream_CheckAndLogRequiredLength(TAG, s, nBytes))
|
||||
return 0;
|
||||
|
||||
ret += nBytes;
|
||||
|
@ -928,7 +929,7 @@ static size_t readTagAndLen(WinPrAsn1Decoder* dec, wStream* s, WinPrAsn1_tag* ta
|
|||
{
|
||||
size_t lenBytes;
|
||||
|
||||
if (Stream_GetRemainingLength(s) < 1)
|
||||
if (!Stream_CheckAndLogRequiredLength(TAG, s, 1))
|
||||
return FALSE;
|
||||
|
||||
Stream_Read(s, tag, 1);
|
||||
|
@ -973,7 +974,7 @@ size_t WinPrAsn1DecReadTagLenValue(WinPrAsn1Decoder* dec, WinPrAsn1_tag* tag, si
|
|||
if (!ret)
|
||||
return 0;
|
||||
|
||||
if (Stream_GetRemainingLength(&dec->source) < *len)
|
||||
if (!Stream_CheckAndLogRequiredLength(TAG, &dec->source, *len))
|
||||
return 0;
|
||||
|
||||
value->encoding = dec->encoding;
|
||||
|
@ -995,7 +996,7 @@ size_t WinPrAsn1DecReadBoolean(WinPrAsn1Decoder* dec, WinPrAsn1_BOOL* target)
|
|||
ret = readTagAndLen(dec, &dec->source, &tag, &len);
|
||||
if (!ret || tag != ER_TAG_BOOLEAN)
|
||||
return 0;
|
||||
if (Stream_GetRemainingLength(&dec->source) < len || len != 1)
|
||||
if (!Stream_CheckAndLogRequiredLength(TAG, &dec->source, len) || len != 1)
|
||||
return 0;
|
||||
|
||||
Stream_Read_UINT8(&dec->source, v);
|
||||
|
@ -1017,7 +1018,7 @@ static size_t WinPrAsn1DecReadIntegerLike(WinPrAsn1Decoder* dec, WinPrAsn1_tag e
|
|||
ret = readTagAndLen(dec, &dec->source, &tag, &len);
|
||||
if (!ret || tag != expectedTag)
|
||||
return 0;
|
||||
if (Stream_GetRemainingLength(&dec->source) < len || len > 4)
|
||||
if (!Stream_CheckAndLogRequiredLength(TAG, &dec->source, len) || len > 4)
|
||||
return 0;
|
||||
|
||||
ret += len;
|
||||
|
@ -1054,7 +1055,7 @@ static size_t WinPrAsn1DecReadMemoryChunkLike(WinPrAsn1Decoder* dec, WinPrAsn1_t
|
|||
ret = readTagAndLen(dec, &dec->source, &tag, &len);
|
||||
if (!ret || tag != expectedTag)
|
||||
return 0;
|
||||
if (Stream_GetRemainingLength(&dec->source) < len)
|
||||
if (!Stream_CheckAndLogRequiredLength(TAG, &dec->source, len))
|
||||
return 0;
|
||||
|
||||
ret += len;
|
||||
|
@ -1102,7 +1103,7 @@ size_t WinPrAsn1DecReadIA5String(WinPrAsn1Decoder* dec, WinPrAsn1_IA5STRING* tar
|
|||
ret = readTagAndLen(dec, &dec->source, &tag, &len);
|
||||
if (!ret || tag != ER_TAG_IA5STRING)
|
||||
return 0;
|
||||
if (Stream_GetRemainingLength(&dec->source) < len)
|
||||
if (!Stream_CheckAndLogRequiredLength(TAG, &dec->source, len))
|
||||
return 0;
|
||||
|
||||
ret += len;
|
||||
|
@ -1129,7 +1130,7 @@ size_t WinPrAsn1DecReadGeneralString(WinPrAsn1Decoder* dec, WinPrAsn1_STRING* ta
|
|||
ret = readTagAndLen(dec, &dec->source, &tag, &len);
|
||||
if (!ret || tag != ER_TAG_GENERAL_STRING)
|
||||
return 0;
|
||||
if (Stream_GetRemainingLength(&dec->source) < len)
|
||||
if (!Stream_CheckAndLogRequiredLength(TAG, &dec->source, len))
|
||||
return 0;
|
||||
|
||||
ret += len;
|
||||
|
@ -1177,7 +1178,7 @@ size_t WinPrAsn1DecReadUtcTime(WinPrAsn1Decoder* dec, WinPrAsn1_UTCTIME* target)
|
|||
ret = readTagAndLen(dec, &dec->source, &tag, &len);
|
||||
if (!ret || tag != ER_TAG_UTCTIME)
|
||||
return 0;
|
||||
if (Stream_GetRemainingLength(&dec->source) < len || len < 12)
|
||||
if (!Stream_CheckAndLogRequiredLength(TAG, &dec->source, len) || len < 12)
|
||||
return 0;
|
||||
|
||||
Stream_StaticConstInit(s, Stream_Pointer(&dec->source), len);
|
||||
|
@ -1245,7 +1246,7 @@ static size_t readConstructed(WinPrAsn1Decoder* dec, wStream* s, WinPrAsn1_tag*
|
|||
size_t ret;
|
||||
|
||||
ret = readTagAndLen(dec, s, tag, &len);
|
||||
if (!ret || Stream_GetRemainingLength(s) < len)
|
||||
if (!ret || !Stream_CheckAndLogRequiredLength(TAG, s, len))
|
||||
return 0;
|
||||
|
||||
target->encoding = dec->encoding;
|
||||
|
|
Loading…
Reference in New Issue