[stream] use const correct Stream_Pointer access
This commit is contained in:
parent
2de7399e52
commit
970f0c54e8
@ -343,7 +343,7 @@ UINT cliprdr_read_format_data_response(wStream* s, CLIPRDR_FORMAT_DATA_RESPONSE*
|
||||
return ERROR_INVALID_DATA;
|
||||
|
||||
if (response->common.dataLen)
|
||||
response->requestedFormatData = Stream_Pointer(s);
|
||||
response->requestedFormatData = Stream_ConstPointer(s);
|
||||
|
||||
return CHANNEL_RC_OK;
|
||||
}
|
||||
@ -379,7 +379,7 @@ UINT cliprdr_read_file_contents_response(wStream* s, CLIPRDR_FILE_CONTENTS_RESPO
|
||||
return ERROR_INVALID_DATA;
|
||||
|
||||
Stream_Read_UINT32(s, response->streamId); /* streamId (4 bytes) */
|
||||
response->requestedData = Stream_Pointer(s); /* requestedFileContentsData */
|
||||
response->requestedData = Stream_ConstPointer(s); /* requestedFileContentsData */
|
||||
|
||||
WINPR_ASSERT(response->common.dataLen >= 4);
|
||||
response->cbRequested = response->common.dataLen - 4;
|
||||
@ -389,23 +389,22 @@ UINT cliprdr_read_file_contents_response(wStream* s, CLIPRDR_FILE_CONTENTS_RESPO
|
||||
UINT cliprdr_read_format_list(wStream* s, CLIPRDR_FORMAT_LIST* formatList, BOOL useLongFormatNames)
|
||||
{
|
||||
UINT32 index;
|
||||
BOOL asciiNames;
|
||||
int formatNameLength;
|
||||
char* szFormatName;
|
||||
WCHAR* wszFormatName;
|
||||
const char* szFormatName = NULL;
|
||||
const WCHAR* wszFormatName = NULL;
|
||||
wStream sub1buffer = { 0 };
|
||||
wStream* sub1;
|
||||
CLIPRDR_FORMAT* formats = NULL;
|
||||
UINT error = ERROR_INTERNAL_ERROR;
|
||||
|
||||
asciiNames = (formatList->common.msgFlags & CB_ASCII_NAMES) ? TRUE : FALSE;
|
||||
const BOOL asciiNames = (formatList->common.msgFlags & CB_ASCII_NAMES) ? TRUE : FALSE;
|
||||
|
||||
index = 0;
|
||||
/* empty format list */
|
||||
formatList->formats = NULL;
|
||||
formatList->numFormats = 0;
|
||||
|
||||
sub1 = Stream_StaticInit(&sub1buffer, Stream_Pointer(s), formatList->common.dataLen);
|
||||
wStream* sub1 =
|
||||
Stream_StaticConstInit(&sub1buffer, Stream_ConstPointer(s), formatList->common.dataLen);
|
||||
if (!Stream_SafeSeek(s, formatList->common.dataLen))
|
||||
return ERROR_INVALID_DATA;
|
||||
|
||||
@ -448,8 +447,8 @@ UINT cliprdr_read_format_list(wStream* s, CLIPRDR_FORMAT_LIST* formatList, BOOL
|
||||
* These are 16 unicode charaters - *without* terminating null !
|
||||
*/
|
||||
|
||||
szFormatName = (char*)Stream_Pointer(sub1);
|
||||
wszFormatName = (WCHAR*)Stream_Pointer(sub1);
|
||||
szFormatName = Stream_ConstPointer(sub1);
|
||||
wszFormatName = Stream_ConstPointer(sub1);
|
||||
if (!Stream_SafeSeek(sub1, 32))
|
||||
goto error_out;
|
||||
|
||||
@ -494,7 +493,7 @@ UINT cliprdr_read_format_list(wStream* s, CLIPRDR_FORMAT_LIST* formatList, BOOL
|
||||
if (!Stream_SafeSeek(sub1, 4)) /* formatId (4 bytes) */
|
||||
goto error_out;
|
||||
|
||||
wszFormatName = (WCHAR*)Stream_Pointer(sub1);
|
||||
wszFormatName = Stream_ConstPointer(sub1);
|
||||
rest = Stream_GetRemainingLength(sub1);
|
||||
formatNameLength = _wcsnlen(wszFormatName, rest / sizeof(WCHAR));
|
||||
|
||||
@ -524,7 +523,7 @@ UINT cliprdr_read_format_list(wStream* s, CLIPRDR_FORMAT_LIST* formatList, BOOL
|
||||
free(format->formatName);
|
||||
format->formatName = NULL;
|
||||
|
||||
wszFormatName = (WCHAR*)Stream_Pointer(sub2);
|
||||
wszFormatName = Stream_ConstPointer(sub2);
|
||||
rest = Stream_GetRemainingLength(sub2);
|
||||
formatNameLength = _wcsnlen(wszFormatName, rest / sizeof(WCHAR));
|
||||
if (!Stream_SafeSeek(sub2, (formatNameLength + 1) * sizeof(WCHAR)))
|
||||
|
@ -596,7 +596,6 @@ static UINT cliprdr_server_receive_temporary_directory(CliprdrServerContext* con
|
||||
const CLIPRDR_HEADER* header)
|
||||
{
|
||||
size_t length;
|
||||
const WCHAR* wszTempDir;
|
||||
CLIPRDR_TEMP_DIRECTORY tempDirectory = { 0 };
|
||||
CliprdrServerPrivate* cliprdr;
|
||||
UINT error = CHANNEL_RC_OK;
|
||||
@ -611,7 +610,7 @@ static UINT cliprdr_server_receive_temporary_directory(CliprdrServerContext* con
|
||||
ARRAYSIZE(cliprdr->temporaryDirectory) * sizeof(WCHAR)))
|
||||
return CHANNEL_RC_NO_MEMORY;
|
||||
|
||||
wszTempDir = (WCHAR*)Stream_Pointer(s);
|
||||
const WCHAR* wszTempDir = Stream_ConstPointer(s);
|
||||
|
||||
if (wszTempDir[ARRAYSIZE(cliprdr->temporaryDirectory) - 1] != 0)
|
||||
{
|
||||
@ -1102,7 +1101,7 @@ static UINT cliprdr_server_read(CliprdrServerContext* context)
|
||||
if (status == WAIT_TIMEOUT)
|
||||
return CHANNEL_RC_OK;
|
||||
|
||||
if (!WTSVirtualChannelRead(cliprdr->ChannelHandle, 0, (PCHAR)Stream_Pointer(s), BytesToRead,
|
||||
if (!WTSVirtualChannelRead(cliprdr->ChannelHandle, 0, Stream_Pointer(s), BytesToRead,
|
||||
&BytesReturned))
|
||||
{
|
||||
WLog_ERR(TAG, "WTSVirtualChannelRead failed!");
|
||||
@ -1145,8 +1144,8 @@ static UINT cliprdr_server_read(CliprdrServerContext* context)
|
||||
if (status == WAIT_TIMEOUT)
|
||||
return CHANNEL_RC_OK;
|
||||
|
||||
if (!WTSVirtualChannelRead(cliprdr->ChannelHandle, 0, (PCHAR)Stream_Pointer(s),
|
||||
BytesToRead, &BytesReturned))
|
||||
if (!WTSVirtualChannelRead(cliprdr->ChannelHandle, 0, Stream_Pointer(s), BytesToRead,
|
||||
&BytesReturned))
|
||||
{
|
||||
WLog_ERR(TAG, "WTSVirtualChannelRead failed!");
|
||||
return ERROR_INTERNAL_ERROR;
|
||||
@ -1185,8 +1184,8 @@ static UINT cliprdr_server_read(CliprdrServerContext* context)
|
||||
BytesReturned = 0;
|
||||
BytesToRead = 4;
|
||||
|
||||
if (!WTSVirtualChannelRead(cliprdr->ChannelHandle, 0, (PCHAR)Stream_Pointer(s),
|
||||
BytesToRead, &BytesReturned))
|
||||
if (!WTSVirtualChannelRead(cliprdr->ChannelHandle, 0, Stream_Pointer(s), BytesToRead,
|
||||
&BytesReturned))
|
||||
{
|
||||
WLog_ERR(TAG, "WTSVirtualChannelRead failed!");
|
||||
return ERROR_INTERNAL_ERROR;
|
||||
|
@ -1146,13 +1146,9 @@ static UINT32 drdynvc_read_variable_uint(wStream* s, int cbLen)
|
||||
*/
|
||||
static UINT drdynvc_process_create_request(drdynvcPlugin* drdynvc, int Sp, int cbChId, wStream* s)
|
||||
{
|
||||
size_t pos;
|
||||
UINT status;
|
||||
UINT32 ChannelId;
|
||||
wStream* data_out;
|
||||
UINT channel_status;
|
||||
char* name;
|
||||
size_t length;
|
||||
DVCMAN* dvcman;
|
||||
DVCMAN_CHANNEL* channel;
|
||||
UINT32 retStatus;
|
||||
@ -1185,10 +1181,10 @@ static UINT drdynvc_process_create_request(drdynvcPlugin* drdynvc, int Sp, int c
|
||||
if (!Stream_CheckAndLogRequiredLength(TAG, s, drdynvc_cblen_to_bytes(cbChId)))
|
||||
return ERROR_INVALID_DATA;
|
||||
|
||||
ChannelId = drdynvc_read_variable_uint(s, cbChId);
|
||||
pos = Stream_GetPosition(s);
|
||||
name = (char*)Stream_Pointer(s);
|
||||
length = Stream_GetRemainingLength(s);
|
||||
const UINT32 ChannelId = drdynvc_read_variable_uint(s, cbChId);
|
||||
const size_t pos = Stream_GetPosition(s);
|
||||
const char* name = Stream_ConstPointer(s);
|
||||
const size_t length = Stream_GetRemainingLength(s);
|
||||
|
||||
if (strnlen(name, length) >= length)
|
||||
return ERROR_INVALID_DATA;
|
||||
|
@ -465,7 +465,7 @@ BOOL drive_file_read(DRIVE_FILE* file, BYTE* buffer, UINT32* Length)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL drive_file_write(DRIVE_FILE* file, BYTE* buffer, UINT32 Length)
|
||||
BOOL drive_file_write(DRIVE_FILE* file, const BYTE* buffer, UINT32 Length)
|
||||
{
|
||||
DWORD written;
|
||||
|
||||
@ -823,7 +823,7 @@ BOOL drive_file_set_information(DRIVE_FILE* file, UINT32 FsInformationClass, UIN
|
||||
if (!Stream_CheckAndLogRequiredLength(TAG, input, FileNameLength))
|
||||
return FALSE;
|
||||
|
||||
fullpath = drive_file_combine_fullpath(file->basepath, (WCHAR*)Stream_Pointer(input),
|
||||
fullpath = drive_file_combine_fullpath(file->basepath, Stream_ConstPointer(input),
|
||||
FileNameLength / sizeof(WCHAR));
|
||||
|
||||
if (!fullpath)
|
||||
|
@ -57,7 +57,7 @@ BOOL drive_file_free(DRIVE_FILE* file);
|
||||
BOOL drive_file_open(DRIVE_FILE* file);
|
||||
BOOL drive_file_seek(DRIVE_FILE* file, UINT64 Offset);
|
||||
BOOL drive_file_read(DRIVE_FILE* file, BYTE* buffer, UINT32* Length);
|
||||
BOOL drive_file_write(DRIVE_FILE* file, BYTE* buffer, UINT32 Length);
|
||||
BOOL drive_file_write(DRIVE_FILE* file, const BYTE* buffer, UINT32 Length);
|
||||
BOOL drive_file_query_information(DRIVE_FILE* file, UINT32 FsInformationClass, wStream* output);
|
||||
BOOL drive_file_set_information(DRIVE_FILE* file, UINT32 FsInformationClass, UINT32 Length,
|
||||
wStream* input);
|
||||
|
@ -178,7 +178,7 @@ static UINT drive_process_irp_create(DRIVE_DEVICE* drive, IRP* irp)
|
||||
if (!Stream_CheckAndLogRequiredLength(TAG, irp->input, PathLength))
|
||||
return ERROR_INVALID_DATA;
|
||||
|
||||
path = (const WCHAR*)Stream_Pointer(irp->input);
|
||||
path = Stream_ConstPointer(irp->input);
|
||||
FileId = irp->devman->id_sequence++;
|
||||
file = drive_file_new(drive->path, path, PathLength / sizeof(WCHAR), FileId, DesiredAccess,
|
||||
CreateDisposition, CreateOptions, FileAttributes, SharedAccess);
|
||||
@ -300,7 +300,7 @@ static UINT drive_process_irp_read(DRIVE_DEVICE* drive, IRP* irp)
|
||||
Stream_Write_UINT32(irp->output, 0);
|
||||
else
|
||||
{
|
||||
BYTE* buffer = Stream_Pointer(irp->output) + sizeof(UINT32);
|
||||
BYTE* buffer = Stream_PointerAs(irp->output, BYTE) + sizeof(UINT32);
|
||||
|
||||
if (!drive_file_read(file, buffer, &Length))
|
||||
{
|
||||
@ -327,7 +327,6 @@ static UINT drive_process_irp_write(DRIVE_DEVICE* drive, IRP* irp)
|
||||
DRIVE_FILE* file;
|
||||
UINT32 Length;
|
||||
UINT64 Offset;
|
||||
void* ptr;
|
||||
|
||||
if (!drive || !irp || !irp->input || !irp->output || !irp->Complete)
|
||||
return ERROR_INVALID_PARAMETER;
|
||||
@ -338,7 +337,7 @@ static UINT drive_process_irp_write(DRIVE_DEVICE* drive, IRP* irp)
|
||||
Stream_Read_UINT32(irp->input, Length);
|
||||
Stream_Read_UINT64(irp->input, Offset);
|
||||
Stream_Seek(irp->input, 20); /* Padding */
|
||||
ptr = Stream_Pointer(irp->input);
|
||||
const void* ptr = Stream_ConstPointer(irp->input);
|
||||
if (!Stream_SafeSeek(irp->input, Length))
|
||||
return ERROR_INVALID_DATA;
|
||||
file = drive_get_file_by_id(drive, irp->FileId);
|
||||
@ -611,7 +610,7 @@ static UINT drive_process_irp_query_directory(DRIVE_DEVICE* drive, IRP* irp)
|
||||
Stream_Read_UINT8(irp->input, InitialQuery);
|
||||
Stream_Read_UINT32(irp->input, PathLength);
|
||||
Stream_Seek(irp->input, 23); /* Padding */
|
||||
path = (WCHAR*)Stream_Pointer(irp->input);
|
||||
path = Stream_ConstPointer(irp->input);
|
||||
if (!Stream_CheckAndLogRequiredLength(TAG, irp->input, PathLength))
|
||||
return ERROR_INVALID_DATA;
|
||||
|
||||
|
@ -47,7 +47,7 @@ typedef struct
|
||||
static UINT echo_on_data_received(IWTSVirtualChannelCallback* pChannelCallback, wStream* data)
|
||||
{
|
||||
GENERIC_CHANNEL_CALLBACK* callback = (GENERIC_CHANNEL_CALLBACK*)pChannelCallback;
|
||||
BYTE* pBuffer = Stream_Pointer(data);
|
||||
const BYTE* pBuffer = Stream_ConstPointer(data);
|
||||
UINT32 cbSize = Stream_GetRemainingLength(data);
|
||||
|
||||
/* echo back what we have received. ECHO does not have any message IDs. */
|
||||
|
@ -77,7 +77,6 @@ typedef struct
|
||||
static UINT parallel_process_irp_create(PARALLEL_DEVICE* parallel, IRP* irp)
|
||||
{
|
||||
char* path = NULL;
|
||||
WCHAR* ptr;
|
||||
UINT32 PathLength;
|
||||
if (!Stream_SafeSeek(irp->input, 28))
|
||||
return ERROR_INVALID_DATA;
|
||||
@ -88,7 +87,7 @@ static UINT parallel_process_irp_create(PARALLEL_DEVICE* parallel, IRP* irp)
|
||||
Stream_Read_UINT32(irp->input, PathLength);
|
||||
if (PathLength < sizeof(WCHAR))
|
||||
return ERROR_INVALID_DATA;
|
||||
ptr = (WCHAR*)Stream_Pointer(irp->input);
|
||||
const WCHAR* ptr = Stream_ConstPointer(irp->input);
|
||||
if (!Stream_SafeSeek(irp->input, PathLength))
|
||||
return ERROR_INVALID_DATA;
|
||||
path = ConvertWCharNToUtf8Alloc(ptr, PathLength / sizeof(WCHAR), NULL);
|
||||
@ -201,7 +200,7 @@ static UINT parallel_process_irp_write(PARALLEL_DEVICE* parallel, IRP* irp)
|
||||
UINT32 Length;
|
||||
UINT64 Offset;
|
||||
ssize_t status;
|
||||
void* ptr;
|
||||
|
||||
if (!Stream_CheckAndLogRequiredLength(TAG, irp->input, 12))
|
||||
return ERROR_INVALID_DATA;
|
||||
|
||||
@ -209,7 +208,7 @@ static UINT parallel_process_irp_write(PARALLEL_DEVICE* parallel, IRP* irp)
|
||||
Stream_Read_UINT64(irp->input, Offset);
|
||||
if (!Stream_SafeSeek(irp->input, 20)) /* Padding */
|
||||
return ERROR_INVALID_DATA;
|
||||
ptr = Stream_Pointer(irp->input);
|
||||
const void* ptr = Stream_ConstPointer(irp->input);
|
||||
if (!Stream_SafeSeek(irp->input, Length))
|
||||
return ERROR_INVALID_DATA;
|
||||
len = Length;
|
||||
|
@ -497,7 +497,6 @@ static UINT printer_process_irp_write(PRINTER_DEVICE* printer_dev, IRP* irp)
|
||||
UINT64 Offset;
|
||||
rdpPrintJob* printjob = NULL;
|
||||
UINT error = CHANNEL_RC_OK;
|
||||
void* ptr;
|
||||
|
||||
WINPR_ASSERT(printer_dev);
|
||||
WINPR_ASSERT(irp);
|
||||
@ -507,7 +506,7 @@ static UINT printer_process_irp_write(PRINTER_DEVICE* printer_dev, IRP* irp)
|
||||
Stream_Read_UINT32(irp->input, Length);
|
||||
Stream_Read_UINT64(irp->input, Offset);
|
||||
Stream_Seek(irp->input, 20); /* Padding */
|
||||
ptr = Stream_Pointer(irp->input);
|
||||
const void* ptr = Stream_ConstPointer(irp->input);
|
||||
if (!Stream_SafeSeek(irp->input, Length))
|
||||
return ERROR_INVALID_DATA;
|
||||
if (printer_dev->printer)
|
||||
@ -724,25 +723,25 @@ static UINT printer_custom_component(DEVICE* device, UINT16 component, UINT16 pa
|
||||
if (!Stream_CheckAndLogRequiredLength(TAG, s, PnPNameLen))
|
||||
return ERROR_INVALID_DATA;
|
||||
|
||||
PnPName = (const WCHAR*)Stream_Pointer(s);
|
||||
PnPName = Stream_ConstPointer(s);
|
||||
Stream_Seek(s, PnPNameLen);
|
||||
|
||||
if (!Stream_CheckAndLogRequiredLength(TAG, s, DriverNameLen))
|
||||
return ERROR_INVALID_DATA;
|
||||
|
||||
DriverName = (const WCHAR*)Stream_Pointer(s);
|
||||
DriverName = Stream_ConstPointer(s);
|
||||
Stream_Seek(s, DriverNameLen);
|
||||
|
||||
if (!Stream_CheckAndLogRequiredLength(TAG, s, PrintNameLen))
|
||||
return ERROR_INVALID_DATA;
|
||||
|
||||
PrinterName = (const WCHAR*)Stream_Pointer(s);
|
||||
PrinterName = Stream_ConstPointer(s);
|
||||
Stream_Seek(s, PrintNameLen);
|
||||
|
||||
if (!Stream_CheckAndLogRequiredLength(TAG, s, CacheFieldsLen))
|
||||
return ERROR_INVALID_DATA;
|
||||
|
||||
CachedPrinterConfigData = Stream_Pointer(s);
|
||||
CachedPrinterConfigData = Stream_ConstPointer(s);
|
||||
Stream_Seek(s, CacheFieldsLen);
|
||||
|
||||
if (!printer_save_to_config(settings, PortDosName, sizeof(PortDosName), PnPName,
|
||||
@ -768,13 +767,13 @@ static UINT printer_custom_component(DEVICE* device, UINT16 component, UINT16 pa
|
||||
if (!Stream_CheckAndLogRequiredLength(TAG, s, PrinterNameLen))
|
||||
return ERROR_INVALID_DATA;
|
||||
|
||||
PrinterName = (const WCHAR*)Stream_Pointer(s);
|
||||
PrinterName = Stream_ConstPointer(s);
|
||||
Stream_Seek(s, PrinterNameLen);
|
||||
|
||||
if (!Stream_CheckAndLogRequiredLength(TAG, s, ConfigDataLen))
|
||||
return ERROR_INVALID_DATA;
|
||||
|
||||
ConfigData = Stream_Pointer(s);
|
||||
ConfigData = Stream_ConstPointer(s);
|
||||
Stream_Seek(s, ConfigDataLen);
|
||||
|
||||
if (!printer_update_to_config(settings, PrinterName, PrinterNameLen, ConfigData,
|
||||
@ -796,7 +795,7 @@ static UINT printer_custom_component(DEVICE* device, UINT16 component, UINT16 pa
|
||||
if (!Stream_CheckAndLogRequiredLength(TAG, s, PrinterNameLen))
|
||||
return ERROR_INVALID_DATA;
|
||||
|
||||
PrinterName = (const WCHAR*)Stream_Pointer(s);
|
||||
PrinterName = Stream_ConstPointer(s);
|
||||
Stream_Seek(s, PrinterNameLen);
|
||||
printer_remove_config(settings, PrinterName, PrinterNameLen);
|
||||
}
|
||||
@ -817,13 +816,13 @@ static UINT printer_custom_component(DEVICE* device, UINT16 component, UINT16 pa
|
||||
if (!Stream_CheckAndLogRequiredLength(TAG, s, OldPrinterNameLen))
|
||||
return ERROR_INVALID_DATA;
|
||||
|
||||
OldPrinterName = (const WCHAR*)Stream_Pointer(s);
|
||||
OldPrinterName = Stream_ConstPointer(s);
|
||||
Stream_Seek(s, OldPrinterNameLen);
|
||||
|
||||
if (!Stream_CheckAndLogRequiredLength(TAG, s, NewPrinterNameLen))
|
||||
return ERROR_INVALID_DATA;
|
||||
|
||||
NewPrinterName = (const WCHAR*)Stream_Pointer(s);
|
||||
NewPrinterName = Stream_ConstPointer(s);
|
||||
Stream_Seek(s, NewPrinterNameLen);
|
||||
|
||||
if (!printer_move_config(settings, OldPrinterName, OldPrinterNameLen,
|
||||
|
@ -1582,8 +1582,8 @@ UINT rail_server_handle_messages(RailServerContext* context)
|
||||
return CHANNEL_RC_NO_MEMORY;
|
||||
}
|
||||
|
||||
if (!WTSVirtualChannelRead(priv->rail_channel, 0, (PCHAR)Stream_Pointer(s),
|
||||
RAIL_PDU_HEADER_LENGTH, &bytesReturned))
|
||||
if (!WTSVirtualChannelRead(priv->rail_channel, 0, Stream_Pointer(s), RAIL_PDU_HEADER_LENGTH,
|
||||
&bytesReturned))
|
||||
{
|
||||
if (GetLastError() == ERROR_NO_DATA)
|
||||
return ERROR_NO_DATA;
|
||||
@ -1607,7 +1607,7 @@ UINT rail_server_handle_messages(RailServerContext* context)
|
||||
}
|
||||
|
||||
/* Read body */
|
||||
if (!WTSVirtualChannelRead(priv->rail_channel, 0, (PCHAR)Stream_Pointer(s),
|
||||
if (!WTSVirtualChannelRead(priv->rail_channel, 0, Stream_Pointer(s),
|
||||
orderLength - RAIL_PDU_HEADER_LENGTH, &bytesReturned))
|
||||
{
|
||||
if (GetLastError() == ERROR_NO_DATA)
|
||||
|
@ -1335,7 +1335,7 @@ static BOOL device_announce(ULONG_PTR key, void* element, void* data)
|
||||
|
||||
Stream_Write_UINT32(arg->s, device->type); /* deviceType */
|
||||
Stream_Write_UINT32(arg->s, device->id); /* deviceID */
|
||||
strncpy((char*)Stream_Pointer(arg->s), device->name, 8);
|
||||
strncpy(Stream_Pointer(arg->s), device->name, 8);
|
||||
|
||||
for (i = 0; i < 8; i++)
|
||||
{
|
||||
|
@ -154,7 +154,7 @@ static UINT32 g_ClientId = 0;
|
||||
static const WCHAR* rdpdr_read_ustring(wLog* log, wStream* s, size_t bytelen)
|
||||
{
|
||||
const size_t charlen = (bytelen + 1) / sizeof(WCHAR);
|
||||
const WCHAR* str = (const WCHAR*)Stream_Pointer(s);
|
||||
const WCHAR* str = Stream_ConstPointer(s);
|
||||
if (!Stream_CheckAndLogRequiredLengthWLog(log, s, bytelen))
|
||||
return NULL;
|
||||
if (_wcsnlen(str, charlen) == charlen)
|
||||
@ -358,9 +358,8 @@ static UINT rdpdr_server_receive_client_name_request(RdpdrServerContext* context
|
||||
return ERROR_INVALID_DATA;
|
||||
|
||||
/* ComputerName must be null terminated, check if it really is */
|
||||
|
||||
if (Stream_Pointer(s)[ComputerNameLen - 1] ||
|
||||
(UnicodeFlag && Stream_Pointer(s)[ComputerNameLen - 2]))
|
||||
const char* computerName = Stream_ConstPointer(s);
|
||||
if (computerName[ComputerNameLen - 1] || (UnicodeFlag && computerName[ComputerNameLen - 2]))
|
||||
{
|
||||
WLog_Print(context->priv->log, WLOG_ERROR, "computer name must be null terminated");
|
||||
return ERROR_INVALID_DATA;
|
||||
@ -384,7 +383,7 @@ static UINT rdpdr_server_receive_client_name_request(RdpdrServerContext* context
|
||||
}
|
||||
else
|
||||
{
|
||||
const char* name = (const char*)Stream_Pointer(s);
|
||||
const char* name = Stream_ConstPointer(s);
|
||||
context->priv->ClientComputerName = _strdup(name);
|
||||
Stream_Seek(s, ComputerNameLen);
|
||||
|
||||
@ -531,7 +530,7 @@ static UINT rdpdr_server_write_general_capability_set(RdpdrServerContext* contex
|
||||
if (error != CHANNEL_RC_OK)
|
||||
return error;
|
||||
|
||||
const BYTE* data = Stream_Pointer(s);
|
||||
const BYTE* data = Stream_ConstPointer(s);
|
||||
const size_t start = Stream_GetPosition(s);
|
||||
Stream_Write_UINT32(s, 0); /* osType (4 bytes), ignored on receipt */
|
||||
Stream_Write_UINT32(s, 0); /* osVersion (4 bytes), unused and must be set to zero */
|
||||
@ -823,7 +822,7 @@ static UINT rdpdr_server_receive_core_capability_response(RdpdrServerContext* co
|
||||
}
|
||||
|
||||
status = IFCALLRESULT(CHANNEL_RC_OK, context->ReceiveCaps, context, &capabilityHeader,
|
||||
Stream_GetRemainingLength(s), Stream_Pointer(s));
|
||||
Stream_GetRemainingLength(s), Stream_ConstPointer(s));
|
||||
if (status != CHANNEL_RC_OK)
|
||||
return status;
|
||||
|
||||
@ -1250,7 +1249,7 @@ static UINT rdpdr_server_receive_io_write_request(RdpdrServerContext* context, w
|
||||
Stream_Read_UINT64(s, Offset);
|
||||
Stream_Seek(s, 20); /* Padding */
|
||||
|
||||
data = Stream_Pointer(s);
|
||||
data = Stream_ConstPointer(s);
|
||||
if (!Stream_CheckAndLogRequiredLengthWLog(context->priv->log, s, Length))
|
||||
return ERROR_INVALID_DATA;
|
||||
Stream_Seek(s, Length);
|
||||
@ -1282,7 +1281,7 @@ static UINT rdpdr_server_receive_io_device_control_request(RdpdrServerContext* c
|
||||
Stream_Read_UINT32(s, IoControlCode);
|
||||
Stream_Seek(s, 20); /* Padding */
|
||||
|
||||
InputBuffer = Stream_Pointer(s);
|
||||
InputBuffer = Stream_ConstPointer(s);
|
||||
if (!Stream_CheckAndLogRequiredLengthWLog(context->priv->log, s, InputBufferLength))
|
||||
return ERROR_INVALID_DATA;
|
||||
Stream_Seek(s, InputBufferLength);
|
||||
@ -1311,7 +1310,7 @@ static UINT rdpdr_server_receive_io_query_volume_information_request(RdpdrServer
|
||||
Stream_Read_UINT32(s, Length);
|
||||
Stream_Seek(s, 24); /* Padding */
|
||||
|
||||
QueryVolumeBuffer = Stream_Pointer(s);
|
||||
QueryVolumeBuffer = Stream_ConstPointer(s);
|
||||
if (!Stream_CheckAndLogRequiredLengthWLog(context->priv->log, s, Length))
|
||||
return ERROR_INVALID_DATA;
|
||||
Stream_Seek(s, Length);
|
||||
@ -1343,7 +1342,7 @@ static UINT rdpdr_server_receive_io_set_volume_information_request(RdpdrServerCo
|
||||
Stream_Read_UINT32(s, Length);
|
||||
Stream_Seek(s, 24); /* Padding */
|
||||
|
||||
SetVolumeBuffer = Stream_Pointer(s);
|
||||
SetVolumeBuffer = Stream_ConstPointer(s);
|
||||
if (!Stream_CheckAndLogRequiredLengthWLog(context->priv->log, s, Length))
|
||||
return ERROR_INVALID_DATA;
|
||||
Stream_Seek(s, Length);
|
||||
@ -1374,7 +1373,7 @@ static UINT rdpdr_server_receive_io_query_information_request(RdpdrServerContext
|
||||
Stream_Read_UINT32(s, Length);
|
||||
Stream_Seek(s, 24); /* Padding */
|
||||
|
||||
QueryBuffer = Stream_Pointer(s);
|
||||
QueryBuffer = Stream_ConstPointer(s);
|
||||
if (!Stream_CheckAndLogRequiredLengthWLog(context->priv->log, s, Length))
|
||||
return ERROR_INVALID_DATA;
|
||||
Stream_Seek(s, Length);
|
||||
@ -1405,7 +1404,7 @@ static UINT rdpdr_server_receive_io_set_information_request(RdpdrServerContext*
|
||||
Stream_Read_UINT32(s, Length);
|
||||
Stream_Seek(s, 24); /* Padding */
|
||||
|
||||
SetBuffer = Stream_Pointer(s);
|
||||
SetBuffer = Stream_ConstPointer(s);
|
||||
if (!Stream_CheckAndLogRequiredLengthWLog(context->priv->log, s, Length))
|
||||
return ERROR_INVALID_DATA;
|
||||
Stream_Seek(s, Length);
|
||||
@ -1721,7 +1720,7 @@ static UINT rdpdr_server_receive_prn_cache_add_printer(RdpdrServerContext* conte
|
||||
if (!PrinterName && (PrinterNameLen > 0))
|
||||
return ERROR_INVALID_DATA;
|
||||
|
||||
config = Stream_Pointer(s);
|
||||
config = Stream_ConstPointer(s);
|
||||
if (!Stream_CheckAndLogRequiredLengthWLog(context->priv->log, s, CachedFieldsLen))
|
||||
return ERROR_INVALID_DATA;
|
||||
Stream_Seek(s, CachedFieldsLen);
|
||||
@ -1751,7 +1750,7 @@ static UINT rdpdr_server_receive_prn_cache_update_printer(RdpdrServerContext* co
|
||||
if (!PrinterName && (PrinterNameLen > 0))
|
||||
return ERROR_INVALID_DATA;
|
||||
|
||||
config = Stream_Pointer(s);
|
||||
config = Stream_ConstPointer(s);
|
||||
if (!Stream_CheckAndLogRequiredLengthWLog(context->priv->log, s, CachedFieldsLen))
|
||||
return ERROR_INVALID_DATA;
|
||||
Stream_Seek(s, CachedFieldsLen);
|
||||
@ -3008,7 +3007,7 @@ static UINT rdpdr_server_drive_read_file_callback(RdpdrServerContext* context, w
|
||||
|
||||
if (length > 0)
|
||||
{
|
||||
buffer = (char*)Stream_Pointer(s);
|
||||
buffer = Stream_Pointer(s);
|
||||
Stream_Seek(s, length);
|
||||
}
|
||||
|
||||
|
@ -164,10 +164,10 @@ static UINT enumerator_server_recv_device_added_notification(CamDevEnumServerCon
|
||||
if (!Stream_CheckAndLogRequiredLength(TAG, s, 4))
|
||||
return ERROR_NO_DATA;
|
||||
|
||||
pdu.DeviceName = (WCHAR*)Stream_Pointer(s);
|
||||
pdu.DeviceName = Stream_Pointer(s);
|
||||
|
||||
remaining_length = Stream_GetRemainingLength(s);
|
||||
channel_name_start = (WCHAR*)Stream_Pointer(s);
|
||||
channel_name_start = Stream_Pointer(s);
|
||||
|
||||
/* Search for null terminator of DeviceName */
|
||||
size_t i = 0;
|
||||
@ -230,10 +230,10 @@ static UINT enumerator_server_recv_device_removed_notification(CamDevEnumServerC
|
||||
if (!Stream_CheckAndLogRequiredLength(TAG, s, 2))
|
||||
return ERROR_NO_DATA;
|
||||
|
||||
pdu.VirtualChannelName = (char*)Stream_Pointer(s);
|
||||
pdu.VirtualChannelName = Stream_Pointer(s);
|
||||
|
||||
remaining_length = Stream_GetRemainingLength(s);
|
||||
char* tmp = (char*)(Stream_Pointer(s) + 1);
|
||||
char* tmp = pdu.VirtualChannelName + 1;
|
||||
|
||||
for (size_t i = 1; i < remaining_length; ++i, ++tmp)
|
||||
{
|
||||
|
@ -495,8 +495,8 @@ UINT rdpei_server_handle_messages(RdpeiServerContext* context)
|
||||
wStream* s = priv->inputStream;
|
||||
UINT error = CHANNEL_RC_OK;
|
||||
|
||||
if (!WTSVirtualChannelRead(priv->channelHandle, 0, (PCHAR)Stream_Pointer(s),
|
||||
priv->expectedBytes, &bytesReturned))
|
||||
if (!WTSVirtualChannelRead(priv->channelHandle, 0, Stream_Pointer(s), priv->expectedBytes,
|
||||
&bytesReturned))
|
||||
{
|
||||
if (GetLastError() == ERROR_NO_DATA)
|
||||
return ERROR_READ_FAULT;
|
||||
|
@ -2081,7 +2081,7 @@ static UINT rdpgfx_on_data_received(IWTSVirtualChannelCallback* pChannelCallback
|
||||
UINT error = CHANNEL_RC_OK;
|
||||
|
||||
WINPR_ASSERT(gfx);
|
||||
status = zgfx_decompress(gfx->zgfx, Stream_Pointer(data),
|
||||
status = zgfx_decompress(gfx->zgfx, Stream_ConstPointer(data),
|
||||
(UINT32)Stream_GetRemainingLength(data), &pDstData, &DstSize, 0);
|
||||
|
||||
if (status < 0)
|
||||
|
@ -598,7 +598,6 @@ static BOOL rdpsnd_detect_overrun(rdpsndPlugin* rdpsnd, const AUDIO_FORMAT* form
|
||||
|
||||
static UINT rdpsnd_treat_wave(rdpsndPlugin* rdpsnd, wStream* s, size_t size)
|
||||
{
|
||||
BYTE* data;
|
||||
AUDIO_FORMAT* format;
|
||||
UINT64 end;
|
||||
UINT64 diffMS, ts;
|
||||
@ -620,7 +619,7 @@ static UINT rdpsnd_treat_wave(rdpsndPlugin* rdpsnd, wStream* s, size_t size)
|
||||
if (error)
|
||||
return error;
|
||||
|
||||
data = Stream_Pointer(s);
|
||||
const BYTE* data = Stream_ConstPointer(s);
|
||||
format = &rdpsnd->ClientFormats[rdpsnd->wCurrentFormatNo];
|
||||
WLog_Print(rdpsnd->log, WLOG_DEBUG,
|
||||
"%s Wave: cBlockNo: %" PRIu8 " wTimeStamp: %" PRIu16 ", size: %" PRIdz,
|
||||
|
@ -556,7 +556,7 @@ static UINT rdpsnd_server_send_wave_pdu(RdpsndServerContext* context, UINT16 wTi
|
||||
Stream_Write_UINT32(s, 0); /* bPad */
|
||||
Stream_SetPosition(s, start);
|
||||
|
||||
if (!WTSVirtualChannelWrite(context->priv->ChannelHandle, (PCHAR)Stream_Pointer(s), end - start,
|
||||
if (!WTSVirtualChannelWrite(context->priv->ChannelHandle, Stream_Pointer(s), end - start,
|
||||
&written))
|
||||
{
|
||||
WLog_ERR(TAG, "WTSVirtualChannelWrite failed!");
|
||||
@ -1144,8 +1144,8 @@ UINT rdpsnd_server_handle_messages(RdpsndServerContext* context)
|
||||
priv = context->priv;
|
||||
s = priv->input_stream;
|
||||
|
||||
if (!WTSVirtualChannelRead(priv->ChannelHandle, 0, (PCHAR)Stream_Pointer(s),
|
||||
priv->expectedBytes, &bytesReturned))
|
||||
if (!WTSVirtualChannelRead(priv->ChannelHandle, 0, Stream_Pointer(s), priv->expectedBytes,
|
||||
&bytesReturned))
|
||||
{
|
||||
if (GetLastError() == ERROR_NO_DATA)
|
||||
return ERROR_NO_DATA;
|
||||
|
@ -690,7 +690,7 @@ static UINT remdesk_process_receive(remdeskPlugin* remdesk, wStream* s)
|
||||
|
||||
#if 0
|
||||
WLog_DBG(TAG, "RemdeskReceive: %"PRIuz"", Stream_GetRemainingLength(s));
|
||||
winpr_HexDump(Stream_Pointer(s), Stream_GetRemainingLength(s));
|
||||
winpr_HexDump(Stream_ConstPointer(s), Stream_GetRemainingLength(s));
|
||||
#endif
|
||||
|
||||
if ((status = remdesk_read_channel_header(s, &header)))
|
||||
|
@ -257,17 +257,13 @@ static UINT remdesk_recv_ctl_version_info_pdu(RemdeskServerContext* context, wSt
|
||||
static UINT remdesk_recv_ctl_remote_control_desktop_pdu(RemdeskServerContext* context, wStream* s,
|
||||
REMDESK_CHANNEL_HEADER* header)
|
||||
{
|
||||
SSIZE_T cchStringW;
|
||||
WCHAR* pStringW;
|
||||
UINT32 msgLength;
|
||||
SSIZE_T cchStringW = 0;
|
||||
SSIZE_T cbRaConnectionStringW = 0;
|
||||
WCHAR* raConnectionStringW = NULL;
|
||||
REMDESK_CTL_REMOTE_CONTROL_DESKTOP_PDU pdu;
|
||||
UINT error;
|
||||
msgLength = header->DataLength - 4;
|
||||
pStringW = (WCHAR*)Stream_Pointer(s);
|
||||
raConnectionStringW = pStringW;
|
||||
cchStringW = 0;
|
||||
REMDESK_CTL_REMOTE_CONTROL_DESKTOP_PDU pdu = { 0 };
|
||||
UINT error = 0;
|
||||
UINT32 msgLength = header->DataLength - 4;
|
||||
const WCHAR* pStringW = Stream_ConstPointer(s);
|
||||
const WCHAR* raConnectionStringW = pStringW;
|
||||
|
||||
while ((msgLength > 0) && pStringW[cchStringW])
|
||||
{
|
||||
@ -302,18 +298,15 @@ static UINT remdesk_recv_ctl_remote_control_desktop_pdu(RemdeskServerContext* co
|
||||
static UINT remdesk_recv_ctl_authenticate_pdu(RemdeskServerContext* context, wStream* s,
|
||||
REMDESK_CHANNEL_HEADER* header)
|
||||
{
|
||||
int cchStringW;
|
||||
WCHAR* pStringW;
|
||||
UINT32 msgLength;
|
||||
int cchStringW = 0;
|
||||
UINT32 msgLength = 0;
|
||||
int cbExpertBlobW = 0;
|
||||
WCHAR* expertBlobW = NULL;
|
||||
const WCHAR* expertBlobW = NULL;
|
||||
int cbRaConnectionStringW = 0;
|
||||
WCHAR* raConnectionStringW = NULL;
|
||||
REMDESK_CTL_AUTHENTICATE_PDU pdu;
|
||||
REMDESK_CTL_AUTHENTICATE_PDU pdu = { 0 };
|
||||
msgLength = header->DataLength - 4;
|
||||
pStringW = (WCHAR*)Stream_Pointer(s);
|
||||
raConnectionStringW = pStringW;
|
||||
cchStringW = 0;
|
||||
const WCHAR* pStringW = Stream_ConstPointer(s);
|
||||
const WCHAR* raConnectionStringW = pStringW;
|
||||
|
||||
while ((msgLength > 0) && pStringW[cchStringW])
|
||||
{
|
||||
@ -368,14 +361,13 @@ static UINT remdesk_recv_ctl_verify_password_pdu(RemdeskServerContext* context,
|
||||
REMDESK_CHANNEL_HEADER* header)
|
||||
{
|
||||
SSIZE_T cbExpertBlobW = 0;
|
||||
WCHAR* expertBlobW = NULL;
|
||||
REMDESK_CTL_VERIFY_PASSWORD_PDU pdu;
|
||||
UINT error;
|
||||
|
||||
if (!Stream_CheckAndLogRequiredLength(TAG, s, 8))
|
||||
return ERROR_INVALID_DATA;
|
||||
|
||||
expertBlobW = (WCHAR*)Stream_Pointer(s);
|
||||
const WCHAR* expertBlobW = Stream_ConstPointer(s);
|
||||
cbExpertBlobW = header->DataLength - 4;
|
||||
|
||||
pdu.expertBlob = ConvertWCharNToUtf8Alloc(expertBlobW, cbExpertBlobW / sizeof(WCHAR), NULL);
|
||||
@ -489,7 +481,7 @@ static UINT remdesk_server_receive_pdu(RemdeskServerContext* context, wStream* s
|
||||
REMDESK_CHANNEL_HEADER header;
|
||||
#if 0
|
||||
WLog_INFO(TAG, "RemdeskReceive: %"PRIuz"", Stream_GetRemainingLength(s));
|
||||
winpr_HexDump(Stream_Pointer(s), Stream_GetRemainingLength(s));
|
||||
winpr_HexDump(WCHAR* expertBlobW = NULL;(s), Stream_GetRemainingLength(s));
|
||||
#endif
|
||||
|
||||
if ((error = remdesk_read_channel_header(s, &header)))
|
||||
|
@ -294,7 +294,6 @@ static UINT serial_process_irp_write(SERIAL_DEVICE* serial, IRP* irp)
|
||||
{
|
||||
UINT32 Length;
|
||||
UINT64 Offset;
|
||||
void* ptr;
|
||||
DWORD nbWritten = 0;
|
||||
|
||||
if (!Stream_CheckAndLogRequiredLength(TAG, irp->input, 32))
|
||||
@ -314,7 +313,7 @@ static UINT serial_process_irp_write(SERIAL_DEVICE* serial, IRP* irp)
|
||||
WLog_Print(serial->log, WLOG_DEBUG, "writing %" PRIu32 " bytes to %s", Length,
|
||||
serial->device.name);
|
||||
|
||||
ptr = Stream_Pointer(irp->input);
|
||||
const void* ptr = Stream_ConstPointer(irp->input);
|
||||
if (!Stream_SafeSeek(irp->input, Length))
|
||||
return ERROR_INVALID_DATA;
|
||||
/* FIXME: CommWriteFile to be replaced by WriteFile */
|
||||
|
@ -383,16 +383,16 @@ static UINT wlf_cliprdr_send_client_capabilities(wfClipboard* clipboard)
|
||||
{
|
||||
WINPR_ASSERT(clipboard);
|
||||
|
||||
const CLIPRDR_GENERAL_CAPABILITY_SET generalCapabilitySet = {
|
||||
CLIPRDR_GENERAL_CAPABILITY_SET generalCapabilitySet = {
|
||||
.capabilitySetType = CB_CAPSTYPE_GENERAL,
|
||||
.capabilitySetLength = 12,
|
||||
.version = CB_CAPS_VERSION_2,
|
||||
.generalFlags =
|
||||
CB_USE_LONG_FORMAT_NAMES | cliprdr_file_context_current_flags(clipboard->file)
|
||||
};
|
||||
const CLIPRDR_CAPABILITIES capabilities = {
|
||||
.cCapabilitiesSets = 1, .capabilitySets = (CLIPRDR_CAPABILITY_SET*)&(generalCapabilitySet)
|
||||
};
|
||||
CLIPRDR_CAPABILITIES capabilities = { .cCapabilitiesSets = 1,
|
||||
.capabilitySets =
|
||||
(CLIPRDR_CAPABILITY_SET*)&(generalCapabilitySet) };
|
||||
|
||||
WINPR_ASSERT(clipboard);
|
||||
WINPR_ASSERT(clipboard->context);
|
||||
|
@ -443,9 +443,9 @@ void xf_SetWindowDecorations(xfContext* xfc, Window window, BOOL show)
|
||||
void xf_SetWindowUnlisted(xfContext* xfc, Window window)
|
||||
{
|
||||
WINPR_ASSERT(xfc);
|
||||
const Atom window_state[] = { xfc->_NET_WM_STATE_SKIP_PAGER, xfc->_NET_WM_STATE_SKIP_TASKBAR };
|
||||
Atom window_state[] = { xfc->_NET_WM_STATE_SKIP_PAGER, xfc->_NET_WM_STATE_SKIP_TASKBAR };
|
||||
LogTagAndXChangeProperty(TAG, xfc->display, window, xfc->_NET_WM_STATE, XA_ATOM, 32,
|
||||
PropModeReplace, (BYTE*)&window_state, 2);
|
||||
PropModeReplace, (BYTE*)window_state, 2);
|
||||
}
|
||||
|
||||
static void xf_SetWindowPID(xfContext* xfc, Window window, pid_t pid)
|
||||
|
@ -94,7 +94,7 @@ static int BIO_get_line(BIO* bio, char* buf, int size)
|
||||
}
|
||||
#endif
|
||||
|
||||
static const char* auth_server = "login.microsoftonline.com";
|
||||
static char* auth_server = "login.microsoftonline.com";
|
||||
|
||||
static const char nonce_http_request[] = ""
|
||||
"POST /common/oauth2/token HTTP/1.1\r\n"
|
||||
|
@ -897,7 +897,7 @@ BOOL rdp_server_establish_keys(rdpRdp* rdp, wStream* s)
|
||||
if (!Stream_CheckAndLogRequiredLength(TAG, s, rand_len))
|
||||
return FALSE;
|
||||
|
||||
const BYTE* crypt_random = Stream_Pointer(s);
|
||||
const BYTE* crypt_random = Stream_ConstPointer(s);
|
||||
if (!Stream_SafeSeek(s, rand_len))
|
||||
goto end;
|
||||
if (!rdp_update_client_random(rdp->settings, crypt_random, rand_len))
|
||||
|
@ -981,7 +981,7 @@ BOOL fastpath_send_multiple_input_pdu(rdpFastPath* fastpath, wStream* s, size_t
|
||||
goto fail;
|
||||
|
||||
int sec_bytes = fastpath_get_sec_bytes(fastpath->rdp);
|
||||
BYTE* fpInputEvents = Stream_Pointer(s) + sec_bytes;
|
||||
BYTE* fpInputEvents = Stream_PointerAs(s, BYTE) + sec_bytes;
|
||||
UINT16 fpInputEvents_length = length - 3 - sec_bytes;
|
||||
|
||||
WINPR_ASSERT(rdp->settings);
|
||||
@ -1232,7 +1232,7 @@ BOOL fastpath_send_update_pdu(rdpFastPath* fastpath, BYTE updateCode, wStream* s
|
||||
if (!security_lock(rdp))
|
||||
return FALSE;
|
||||
UINT32 dataSize = fpUpdateHeaderSize + DstSize + pad;
|
||||
BYTE* data = Stream_Pointer(fs) - dataSize;
|
||||
BYTE* data = Stream_PointerAs(fs, BYTE) - dataSize;
|
||||
|
||||
if (rdp->settings->EncryptionMethods == ENCRYPTION_METHOD_FIPS)
|
||||
{
|
||||
|
@ -312,7 +312,6 @@ static const char* capabilities_enum_to_string(UINT32 capabilities)
|
||||
|
||||
static BOOL rdg_read_http_unicode_string(wStream* s, const WCHAR** string, UINT16* lengthInBytes)
|
||||
{
|
||||
WCHAR* str;
|
||||
UINT16 strLenBytes;
|
||||
size_t rem = Stream_GetRemainingLength(s);
|
||||
|
||||
@ -325,7 +324,7 @@ static BOOL rdg_read_http_unicode_string(wStream* s, const WCHAR** string, UINT1
|
||||
Stream_Read_UINT16(s, strLenBytes);
|
||||
|
||||
/* Remember position of our string */
|
||||
str = (WCHAR*)Stream_Pointer(s);
|
||||
const WCHAR* str = Stream_ConstPointer(s);
|
||||
|
||||
/* seek past the string - if this fails something is wrong */
|
||||
if (!Stream_SafeSeek(s, strLenBytes))
|
||||
|
@ -320,7 +320,7 @@ fail:
|
||||
BOOL rpc_recv_bind_ack_pdu(rdpRpc* rpc, wStream* s)
|
||||
{
|
||||
BOOL rc = FALSE;
|
||||
BYTE* auth_data;
|
||||
const BYTE* auth_data;
|
||||
size_t pos, end;
|
||||
rpcconn_hdr_t header = { 0 };
|
||||
SecBuffer buffer = { 0 };
|
||||
@ -343,7 +343,7 @@ BOOL rpc_recv_bind_ack_pdu(rdpRpc* rpc, wStream* s)
|
||||
* rts_read_pdu_header did already do consistency checks */
|
||||
end = Stream_GetPosition(s);
|
||||
Stream_SetPosition(s, pos + header.common.frag_length - header.common.auth_length);
|
||||
auth_data = Stream_Pointer(s);
|
||||
auth_data = Stream_ConstPointer(s);
|
||||
Stream_SetPosition(s, end);
|
||||
|
||||
buffer.cbBuffer = header.common.auth_length;
|
||||
|
@ -417,7 +417,7 @@ static int rpc_client_recv_fragment(rdpRpc* rpc, wStream* fragment)
|
||||
goto fail;
|
||||
|
||||
Stream_SetPosition(fragment, StubOffset);
|
||||
Stream_Write(pdu->s, Stream_Pointer(fragment), StubLength);
|
||||
Stream_Write(pdu->s, Stream_ConstPointer(fragment), StubLength);
|
||||
rpc->StubFragCount++;
|
||||
|
||||
if (response->alloc_hint == StubLength)
|
||||
@ -439,7 +439,7 @@ static int rpc_client_recv_fragment(rdpRpc* rpc, wStream* fragment)
|
||||
if (Stream_Length(fragment) < StubOffset + StubLength)
|
||||
goto fail;
|
||||
Stream_SetPosition(fragment, StubOffset);
|
||||
rpc_client_receive_pipe_write(rpc->client, Stream_Pointer(fragment),
|
||||
rpc_client_receive_pipe_write(rpc->client, Stream_ConstPointer(fragment),
|
||||
(size_t)StubLength);
|
||||
rpc->StubFragCount++;
|
||||
|
||||
|
@ -446,8 +446,6 @@ static BOOL rts_read_supported_versions(wStream* s, p_rt_versions_supported_t* v
|
||||
|
||||
static BOOL rts_read_port_any(wStream* s, port_any_t* port)
|
||||
{
|
||||
const void* ptr;
|
||||
|
||||
WINPR_ASSERT(s);
|
||||
WINPR_ASSERT(port);
|
||||
|
||||
@ -458,7 +456,7 @@ static BOOL rts_read_port_any(wStream* s, port_any_t* port)
|
||||
if (port->length == 0)
|
||||
return TRUE;
|
||||
|
||||
ptr = Stream_Pointer(s);
|
||||
const void* ptr = Stream_ConstPointer(s);
|
||||
if (!Stream_SafeSeek(s, port->length))
|
||||
return FALSE;
|
||||
port->port_spec = sdup(ptr, port->length);
|
||||
|
@ -1205,7 +1205,7 @@ static BOOL TsProxyCreateTunnelReadResponse(rdpTsg* tsg, RPC_PDU* pdu,
|
||||
goto fail;
|
||||
}
|
||||
|
||||
packetStringMessage.msgBuffer = (WCHAR*)Stream_Pointer(pdu->s);
|
||||
packetStringMessage.msgBuffer = Stream_Pointer(pdu->s);
|
||||
if (!Stream_CheckAndLogRequiredLength(TAG, pdu->s, packetStringMessage.msgBytes))
|
||||
goto fail;
|
||||
|
||||
@ -1593,7 +1593,7 @@ static BOOL TsProxyReadPacketSTringMessage(rdpTsg* tsg, wStream* s, TSG_PACKET_S
|
||||
if (!Stream_CheckAndLogRequiredLength(TAG, s, msg->msgBytes))
|
||||
return FALSE;
|
||||
|
||||
msg->msgBuffer = (WCHAR*)Stream_Pointer(s);
|
||||
msg->msgBuffer = Stream_Pointer(s);
|
||||
Stream_Seek(s, msg->msgBytes);
|
||||
|
||||
return TRUE;
|
||||
|
@ -108,7 +108,7 @@ static BOOL rdp_read_info_null_string(const char* what, UINT32 flags, wStream* s
|
||||
}
|
||||
else
|
||||
{
|
||||
const char* domain = (const char*)Stream_Pointer(s);
|
||||
const char* domain = Stream_ConstPointer(s);
|
||||
if (!Stream_SafeSeek(s, cbLen))
|
||||
{
|
||||
WLog_ERR(TAG, "protocol error: no data to read for %s [expected %" PRIuz "]", what,
|
||||
@ -1068,7 +1068,7 @@ static BOOL rdp_info_read_string(const char* what, wStream* s, size_t size, size
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
const WCHAR* str = Stream_Pointer(s);
|
||||
const WCHAR* str = Stream_ConstPointer(s);
|
||||
if (str[size / sizeof(WCHAR) - 1])
|
||||
{
|
||||
WLog_ERR(TAG, "protocol error: %s must be null terminated", what);
|
||||
@ -1200,7 +1200,7 @@ static BOOL rdp_recv_logon_info_v2(rdpRdp* rdp, wStream* s, logon_info* info)
|
||||
if (rem > 0)
|
||||
{
|
||||
BOOL warn = FALSE;
|
||||
const char* str = Stream_Pointer(s);
|
||||
const char* str = Stream_ConstPointer(s);
|
||||
for (size_t x = 0; x < rem; x++)
|
||||
{
|
||||
if (str[x] != '\0')
|
||||
|
@ -68,7 +68,7 @@ state_run_t multitransport_recv_request(rdpMultitransport* multi, wStream* s)
|
||||
Stream_Read_UINT32(s, requestId); /* requestId (4 bytes) */
|
||||
Stream_Read_UINT16(s, requestedProto); /* requestedProtocol (2 bytes) */
|
||||
Stream_Seek(s, 2); /* reserved (2 bytes) */
|
||||
cookie = Stream_Pointer(s);
|
||||
cookie = Stream_ConstPointer(s);
|
||||
Stream_Seek(s, RDPUDP_COOKIE_LEN); /* securityCookie (16 bytes) */
|
||||
|
||||
WINPR_ASSERT(multi->MtRequest);
|
||||
|
@ -882,25 +882,24 @@ static BOOL nego_read_request_token_or_cookie(rdpNego* nego, wStream* s)
|
||||
* string terminated by a 0x0D0A two-byte sequence:
|
||||
* Cookie:[space]mstshash=[ANSISTRING][\x0D\x0A]
|
||||
*/
|
||||
BYTE* str = NULL;
|
||||
UINT16 crlf = 0;
|
||||
size_t pos, len;
|
||||
size_t len;
|
||||
BOOL result = FALSE;
|
||||
BOOL isToken = FALSE;
|
||||
size_t remain = Stream_GetRemainingLength(s);
|
||||
|
||||
WINPR_ASSERT(nego);
|
||||
|
||||
str = Stream_Pointer(s);
|
||||
pos = Stream_GetPosition(s);
|
||||
const char* str = Stream_ConstPointer(s);
|
||||
const size_t pos = Stream_GetPosition(s);
|
||||
|
||||
/* minimum length for token is 15 */
|
||||
if (remain < 15)
|
||||
return TRUE;
|
||||
|
||||
if (memcmp(Stream_Pointer(s), "Cookie: mstshash=", 17) != 0)
|
||||
if (memcmp(Stream_ConstPointer(s), "Cookie: mstshash=", 17) != 0)
|
||||
{
|
||||
if (memcmp(Stream_Pointer(s), "Cookie: msts=", 13) != 0)
|
||||
if (memcmp(Stream_ConstPointer(s), "Cookie: msts=", 13) != 0)
|
||||
{
|
||||
/* remaining bytes are neither a token nor a cookie */
|
||||
return TRUE;
|
||||
@ -932,12 +931,12 @@ static BOOL nego_read_request_token_or_cookie(rdpNego* nego, wStream* s)
|
||||
len = Stream_GetPosition(s) - pos;
|
||||
Stream_Write_UINT16(s, 0);
|
||||
|
||||
if (strnlen((char*)str, len) == len)
|
||||
if (strnlen(str, len) == len)
|
||||
{
|
||||
if (isToken)
|
||||
result = nego_set_routing_token(nego, str, len);
|
||||
else
|
||||
result = nego_set_cookie(nego, (char*)str);
|
||||
result = nego_set_cookie(nego, str);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1752,7 +1752,7 @@ static BOOL update_read_glyph_index_order(wStream* s, const ORDER_INFO* orderInf
|
||||
if (!Stream_CheckAndLogRequiredLength(TAG, s, glyph_index->cbData))
|
||||
return FALSE;
|
||||
|
||||
CopyMemory(glyph_index->data, Stream_Pointer(s), glyph_index->cbData);
|
||||
CopyMemory(glyph_index->data, Stream_ConstPointer(s), glyph_index->cbData);
|
||||
Stream_Seek(s, glyph_index->cbData);
|
||||
}
|
||||
|
||||
@ -1849,7 +1849,7 @@ static BOOL update_read_fast_index_order(wStream* s, const ORDER_INFO* orderInfo
|
||||
if (!Stream_CheckAndLogRequiredLength(TAG, s, fast_index->cbData))
|
||||
return FALSE;
|
||||
|
||||
CopyMemory(fast_index->data, Stream_Pointer(s), fast_index->cbData);
|
||||
CopyMemory(fast_index->data, Stream_ConstPointer(s), fast_index->cbData);
|
||||
Stream_Seek(s, fast_index->cbData);
|
||||
}
|
||||
|
||||
@ -1889,7 +1889,7 @@ static BOOL update_read_fast_glyph_order(wStream* s, const ORDER_INFO* orderInfo
|
||||
|
||||
Stream_Read_UINT8(s, fastGlyph->cbData);
|
||||
|
||||
src = Stream_Pointer(s);
|
||||
src = Stream_ConstPointer(s);
|
||||
if (!Stream_SafeSeek(s, fastGlyph->cbData) || (fastGlyph->cbData == 0))
|
||||
return FALSE;
|
||||
|
||||
@ -2727,7 +2727,7 @@ static BOOL update_decompress_brush(wStream* s, BYTE* output, size_t outSize, BY
|
||||
size_t x, k;
|
||||
INT8 y;
|
||||
BYTE byte = 0;
|
||||
const BYTE* palette = Stream_Pointer(s) + 16;
|
||||
const BYTE* palette = Stream_PointerAs(s, const BYTE) + 16;
|
||||
const size_t bytesPerPixel = ((bpp + 1) / 8);
|
||||
|
||||
if (!Stream_CheckAndLogRequiredLengthOfSize(TAG, s, 4ULL + bytesPerPixel, 4ULL))
|
||||
|
@ -648,7 +648,6 @@ BOOL rdp_write_header(rdpRdp* rdp, wStream* s, UINT16 length, UINT16 channelId)
|
||||
static BOOL rdp_security_stream_out(rdpRdp* rdp, wStream* s, int length, UINT32 sec_flags,
|
||||
UINT32* pad)
|
||||
{
|
||||
BYTE* data;
|
||||
BOOL status;
|
||||
WINPR_ASSERT(rdp);
|
||||
sec_flags |= rdp->sec_flags;
|
||||
@ -667,7 +666,7 @@ static BOOL rdp_security_stream_out(rdpRdp* rdp, wStream* s, int length, UINT32
|
||||
|
||||
if (rdp->settings->EncryptionMethods == ENCRYPTION_METHOD_FIPS)
|
||||
{
|
||||
data = Stream_Pointer(s) + 12;
|
||||
BYTE* data = Stream_PointerAs(s, BYTE) + 12;
|
||||
length = length - (data - Stream_Buffer(s));
|
||||
Stream_Write_UINT16(s, 0x10); /* length */
|
||||
Stream_Write_UINT8(s, 0x1); /* TSFIPS_VERSION 1*/
|
||||
@ -693,7 +692,7 @@ static BOOL rdp_security_stream_out(rdpRdp* rdp, wStream* s, int length, UINT32
|
||||
}
|
||||
else
|
||||
{
|
||||
data = Stream_Pointer(s) + 8;
|
||||
const BYTE* data = Stream_PointerAs(s, const BYTE) + 8;
|
||||
length = length - (data - Stream_Buffer(s));
|
||||
|
||||
if (!Stream_CheckAndLogRequiredCapacityWLog(rdp->log, s, 8))
|
||||
@ -702,7 +701,8 @@ static BOOL rdp_security_stream_out(rdpRdp* rdp, wStream* s, int length, UINT32
|
||||
status = security_salted_mac_signature(rdp, data, length, TRUE,
|
||||
Stream_Pointer(s), 8);
|
||||
else
|
||||
status = security_mac_signature(rdp, data, length, Stream_Pointer(s), 8);
|
||||
status =
|
||||
security_mac_signature(rdp, data, length, Stream_PointerAs(s, BYTE), 8);
|
||||
|
||||
if (!status)
|
||||
goto unlock;
|
||||
@ -1054,7 +1054,7 @@ state_run_t rdp_recv_data_pdu(rdpRdp* rdp, wStream* s)
|
||||
return STATE_RUN_FAILED;
|
||||
}
|
||||
|
||||
if (bulk_decompress(rdp->bulk, Stream_Pointer(s), SrcSize, &pDstData, &DstSize,
|
||||
if (bulk_decompress(rdp->bulk, Stream_ConstPointer(s), SrcSize, &pDstData, &DstSize,
|
||||
compressedType))
|
||||
{
|
||||
cs = transport_take_from_pool(rdp->transport, DstSize);
|
||||
@ -1398,7 +1398,7 @@ BOOL rdp_decrypt(rdpRdp* rdp, wStream* s, UINT16* pLength, UINT16 securityFlags)
|
||||
Stream_Read_UINT16(s, len); /* 0x10 */
|
||||
Stream_Read_UINT8(s, version); /* 0x1 */
|
||||
Stream_Read_UINT8(s, pad);
|
||||
sig = Stream_Pointer(s);
|
||||
sig = Stream_ConstPointer(s);
|
||||
Stream_Seek(s, 8); /* signature */
|
||||
length -= 12;
|
||||
padLength = length - pad;
|
||||
@ -1412,7 +1412,7 @@ BOOL rdp_decrypt(rdpRdp* rdp, wStream* s, UINT16* pLength, UINT16 securityFlags)
|
||||
if (!security_fips_decrypt(Stream_Pointer(s), length, rdp))
|
||||
goto unlock;
|
||||
|
||||
if (!security_fips_check_signature(Stream_Pointer(s), length - pad, sig, 8, rdp))
|
||||
if (!security_fips_check_signature(Stream_ConstPointer(s), length - pad, sig, 8, rdp))
|
||||
goto unlock;
|
||||
|
||||
Stream_SetLength(s, Stream_Length(s) - pad);
|
||||
@ -1432,14 +1432,15 @@ BOOL rdp_decrypt(rdpRdp* rdp, wStream* s, UINT16* pLength, UINT16 securityFlags)
|
||||
goto unlock;
|
||||
}
|
||||
|
||||
if (!security_decrypt(Stream_Pointer(s), length, rdp))
|
||||
if (!security_decrypt(Stream_PointerAs(s, BYTE), length, rdp))
|
||||
goto unlock;
|
||||
|
||||
if (securityFlags & SEC_SECURE_CHECKSUM)
|
||||
status = security_salted_mac_signature(rdp, Stream_Pointer(s), length, FALSE, cmac,
|
||||
status = security_salted_mac_signature(rdp, Stream_ConstPointer(s), length, FALSE, cmac,
|
||||
sizeof(cmac));
|
||||
else
|
||||
status = security_mac_signature(rdp, Stream_Pointer(s), length, cmac, sizeof(cmac));
|
||||
status =
|
||||
security_mac_signature(rdp, Stream_ConstPointer(s), length, cmac, sizeof(cmac));
|
||||
|
||||
if (!status)
|
||||
goto unlock;
|
||||
|
@ -362,7 +362,7 @@ static BOOL rdstls_read_data(wLog* log, wStream* s, UINT16* pLength, const BYTE*
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
*pData = Stream_Pointer(s);
|
||||
*pData = Stream_ConstPointer(s);
|
||||
*pLength = length;
|
||||
return Stream_SafeSeek(s, length);
|
||||
}
|
||||
|
@ -155,7 +155,7 @@ static BOOL rdp_redirection_get_data(wStream* s, UINT32* pLength, const BYTE** p
|
||||
if (!Stream_CheckAndLogRequiredLength(TAG, s, *pLength))
|
||||
return FALSE;
|
||||
|
||||
*pData = Stream_Pointer(s);
|
||||
*pData = Stream_ConstPointer(s);
|
||||
Stream_Seek(s, *pLength);
|
||||
return TRUE;
|
||||
}
|
||||
@ -314,7 +314,7 @@ static BOOL rdp_target_cert_get_element(wStream* s, UINT32* pType, UINT32* pEnco
|
||||
if (!Stream_CheckAndLogRequiredLength(TAG, s, elementSize))
|
||||
return FALSE;
|
||||
|
||||
*ptr = Stream_Pointer(s);
|
||||
*ptr = Stream_ConstPointer(s);
|
||||
*pLength = elementSize;
|
||||
Stream_Seek(s, elementSize);
|
||||
|
||||
|
@ -225,7 +225,7 @@ static BOOL wts_read_drdynvc_data_first(rdpPeerChannel* channel, wStream* s, int
|
||||
if (!Stream_EnsureRemainingCapacity(channel->receiveData, channel->dvc_total_length))
|
||||
return FALSE;
|
||||
|
||||
Stream_Write(channel->receiveData, Stream_Pointer(s), length);
|
||||
Stream_Write(channel->receiveData, Stream_ConstPointer(s), length);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -244,7 +244,7 @@ static BOOL wts_read_drdynvc_data(rdpPeerChannel* channel, wStream* s, UINT32 le
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
Stream_Write(channel->receiveData, Stream_Pointer(s), length);
|
||||
Stream_Write(channel->receiveData, Stream_ConstPointer(s), length);
|
||||
|
||||
if (Stream_GetPosition(channel->receiveData) >= channel->dvc_total_length)
|
||||
{
|
||||
@ -257,7 +257,7 @@ static BOOL wts_read_drdynvc_data(rdpPeerChannel* channel, wStream* s, UINT32 le
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = wts_queue_receive_data(channel, Stream_Pointer(s), length);
|
||||
ret = wts_queue_receive_data(channel, Stream_ConstPointer(s), length);
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
@ -100,7 +100,7 @@ static
|
||||
r = fread(Stream_Pointer(s), 1, size, fp);
|
||||
if (r != size)
|
||||
goto fail;
|
||||
if (crc32 != crc32b(Stream_Pointer(s), size))
|
||||
if (crc32 != crc32b(Stream_ConstPointer(s), size))
|
||||
goto fail;
|
||||
Stream_Seek(s, size);
|
||||
|
||||
|
@ -203,7 +203,7 @@ int update_recv_surfcmds(rdpUpdate* update, wStream* s)
|
||||
while (Stream_GetRemainingLength(s) >= 2)
|
||||
{
|
||||
const size_t start = Stream_GetPosition(s);
|
||||
const BYTE* mark = Stream_Pointer(s);
|
||||
const BYTE* mark = Stream_ConstPointer(s);
|
||||
|
||||
Stream_Read_UINT16(s, cmdType);
|
||||
|
||||
|
@ -1085,7 +1085,7 @@ static int transport_default_write(rdpTransport* transport, wStream* s)
|
||||
while (length > 0)
|
||||
{
|
||||
ERR_clear_error();
|
||||
status = BIO_write(transport->frontBio, Stream_Pointer(s), length);
|
||||
status = BIO_write(transport->frontBio, Stream_ConstPointer(s), length);
|
||||
|
||||
if (status <= 0)
|
||||
{
|
||||
|
@ -137,7 +137,7 @@ static BOOL update_read_bitmap_data(rdpUpdate* update, wStream* s, BITMAP_DATA*
|
||||
if (!bitmapData->bitmapDataStream)
|
||||
return FALSE;
|
||||
|
||||
memcpy(bitmapData->bitmapDataStream, Stream_Pointer(s), bitmapData->bitmapLength);
|
||||
memcpy(bitmapData->bitmapDataStream, Stream_ConstPointer(s), bitmapData->bitmapLength);
|
||||
Stream_Seek(s, bitmapData->bitmapLength);
|
||||
}
|
||||
|
||||
|
@ -458,7 +458,7 @@ BOOL ber_read_unicode_octet_string(wStream* s, LPWSTR* str)
|
||||
if (!ret)
|
||||
return FALSE;
|
||||
|
||||
memcpy(ret, Stream_Pointer(s), length);
|
||||
memcpy(ret, Stream_ConstPointer(s), length);
|
||||
ret[length / 2] = 0;
|
||||
Stream_Seek(s, length);
|
||||
*str = ret;
|
||||
|
@ -724,7 +724,6 @@ static BOOL certificate_read_server_proprietary_certificate(rdpCertificate* cert
|
||||
UINT16 wPublicKeyBlobLen = 0;
|
||||
UINT16 wSignatureBlobType = 0;
|
||||
UINT16 wSignatureBlobLen = 0;
|
||||
BYTE* sigdata = NULL;
|
||||
size_t sigdatalen = 0;
|
||||
|
||||
WINPR_ASSERT(certificate);
|
||||
@ -732,7 +731,7 @@ static BOOL certificate_read_server_proprietary_certificate(rdpCertificate* cert
|
||||
return FALSE;
|
||||
|
||||
/* -4, because we need to include dwVersion */
|
||||
sigdata = Stream_Pointer(s) - 4;
|
||||
const BYTE* sigdata = Stream_PointerAs(s, const BYTE) - 4;
|
||||
Stream_Read_UINT32(s, dwSigAlgId);
|
||||
Stream_Read_UINT32(s, dwKeyAlgId);
|
||||
|
||||
@ -764,7 +763,7 @@ static BOOL certificate_read_server_proprietary_certificate(rdpCertificate* cert
|
||||
if (!Stream_CheckAndLogRequiredLength(TAG, s, 4))
|
||||
return FALSE;
|
||||
|
||||
sigdatalen = Stream_Pointer(s) - sigdata;
|
||||
sigdatalen = Stream_PointerAs(s, const BYTE) - sigdata;
|
||||
Stream_Read_UINT16(s, wSignatureBlobType);
|
||||
|
||||
if (wSignatureBlobType != BB_RSA_SIGNATURE_BLOB)
|
||||
@ -847,7 +846,7 @@ static BOOL cert_write_rsa_signature(wStream* s, const void* sigData, size_t sig
|
||||
static BOOL cert_write_server_certificate_v1(wStream* s, const rdpCertificate* certificate)
|
||||
{
|
||||
const size_t start = Stream_GetPosition(s);
|
||||
const BYTE* sigData = Stream_Pointer(s) - sizeof(UINT32);
|
||||
const BYTE* sigData = Stream_PointerAs(s, const BYTE) - sizeof(UINT32);
|
||||
|
||||
WINPR_ASSERT(start >= 4);
|
||||
if (!Stream_EnsureRemainingCapacity(s, 10))
|
||||
|
@ -494,8 +494,7 @@ static void per_write_string(wStream* s, BYTE* str, int length)
|
||||
|
||||
BOOL per_read_octet_string(wStream* s, const BYTE* oct_str, UINT16 length, UINT16 min)
|
||||
{
|
||||
UINT16 mlength;
|
||||
BYTE* a_oct_str;
|
||||
UINT16 mlength = 0;
|
||||
|
||||
if (!per_read_length(s, &mlength))
|
||||
return FALSE;
|
||||
@ -509,7 +508,7 @@ BOOL per_read_octet_string(wStream* s, const BYTE* oct_str, UINT16 length, UINT1
|
||||
if (!Stream_CheckAndLogRequiredLength(TAG, s, length))
|
||||
return FALSE;
|
||||
|
||||
a_oct_str = Stream_Pointer(s);
|
||||
const BYTE* a_oct_str = Stream_ConstPointer(s);
|
||||
Stream_Seek(s, length);
|
||||
|
||||
return per_check_oid_and_log_mismatch(a_oct_str, oct_str, length);
|
||||
|
@ -770,11 +770,11 @@ WINPR_MD_TYPE x509_utils_get_signature_alg(const X509* xcert)
|
||||
|
||||
char* x509_utils_get_common_name(const X509* xcert, size_t* plength)
|
||||
{
|
||||
const X509_NAME* subject_name = X509_get_subject_name(xcert);
|
||||
X509_NAME* subject_name = X509_get_subject_name(xcert);
|
||||
if (subject_name == NULL)
|
||||
return NULL;
|
||||
|
||||
const int index = X509_NAME_get_index_by_NID((X509_NAME*)subject_name, NID_commonName, -1);
|
||||
const int index = X509_NAME_get_index_by_NID(subject_name, NID_commonName, -1);
|
||||
if (index < 0)
|
||||
return NULL;
|
||||
|
||||
|
@ -323,8 +323,8 @@ static void rdpdr_dump_packet(wLog* log, DWORD lvl, wStream* s, const char* cust
|
||||
if (unicodeFlag == 0)
|
||||
Stream_Read(s, name, MIN(sizeof(name), computerNameLen));
|
||||
else
|
||||
ConvertWCharNToUtf8((const WCHAR*)Stream_Pointer(s),
|
||||
computerNameLen / sizeof(WCHAR), name, sizeof(name));
|
||||
ConvertWCharNToUtf8(Stream_ConstPointer(s), computerNameLen / sizeof(WCHAR),
|
||||
name, sizeof(name));
|
||||
}
|
||||
WLog_Print(log, lvl,
|
||||
"%s [%s | %s] [ucs:%" PRIu32 "|cp:%" PRIu32 "][len:0x%08" PRIx32
|
||||
|
@ -809,7 +809,7 @@ LONG smartcard_irp_device_control_decode(wStream* s, UINT32 CompletionId, UINT32
|
||||
scard_get_ioctl_string(ioControlCode, TRUE),
|
||||
scard_get_ioctl_string(ioControlCode, FALSE), ioControlCode,
|
||||
Stream_GetPosition(s), Stream_Length(s), difference);
|
||||
winpr_HexDump(TAG, WLOG_WARN, Stream_Pointer(s), difference);
|
||||
winpr_HexDump(TAG, WLOG_WARN, Stream_ConstPointer(s), difference);
|
||||
}
|
||||
|
||||
if (Stream_GetPosition(s) > Stream_Length(s))
|
||||
|
@ -335,12 +335,11 @@ static PfChannelResult DynvcTrackerPeekFn(ChannelStateTracker* tracker, BOOL fir
|
||||
|
||||
if (isBackData)
|
||||
{
|
||||
proxyChannelDataEventInfo dev;
|
||||
size_t len;
|
||||
const char* name = (const char*)Stream_Pointer(s);
|
||||
size_t nameLen = Stream_GetRemainingLength(s);
|
||||
proxyChannelDataEventInfo dev = { 0 };
|
||||
const char* name = Stream_ConstPointer(s);
|
||||
const size_t nameLen = Stream_GetRemainingLength(s);
|
||||
|
||||
len = strnlen(name, nameLen);
|
||||
const size_t len = strnlen(name, nameLen);
|
||||
if ((len == 0) || (len == nameLen))
|
||||
return PF_CHANNEL_RESULT_ERROR;
|
||||
|
||||
@ -488,7 +487,7 @@ static PfChannelResult DynvcTrackerPeekFn(ChannelStateTracker* tracker, BOOL fir
|
||||
return PF_CHANNEL_RESULT_ERROR;
|
||||
}
|
||||
|
||||
Stream_Write(trackerState->currentPacket, Stream_Pointer(s), extraSize);
|
||||
Stream_Write(trackerState->currentPacket, Stream_ConstPointer(s), extraSize);
|
||||
}
|
||||
WLog_DBG(TAG,
|
||||
"DynvcTracker(%s [%s]): %s frags=%" PRIu32 " received=%" PRIu32 "(%" PRIu32 ")",
|
||||
|
@ -1553,7 +1553,7 @@ static BOOL filter_smartcard_device_list_remove(pf_channel_server_context* rdpdr
|
||||
return TRUE;
|
||||
|
||||
/* Remove this device from the list */
|
||||
memmove(dst, Stream_Pointer(s), (count - x - 1) * sizeof(UINT32));
|
||||
memmove(dst, Stream_ConstPointer(s), (count - x - 1) * sizeof(UINT32));
|
||||
|
||||
count--;
|
||||
Stream_SetPosition(s, pos);
|
||||
@ -1610,7 +1610,7 @@ static BOOL filter_smartcard_device_list_announce(pf_channel_server_context* rdp
|
||||
|
||||
WLog_INFO(TAG, "Filtering smartcard device 0x%08" PRIx32 "", DeviceId);
|
||||
|
||||
memmove(dst, Stream_Pointer(s), Stream_GetRemainingLength(s));
|
||||
memmove(dst, Stream_ConstPointer(s), Stream_GetRemainingLength(s));
|
||||
Stream_SetPosition(s, pos);
|
||||
Stream_Write_UINT32(s, count - 1);
|
||||
return FALSE;
|
||||
|
@ -821,7 +821,7 @@ static void* convert_filedescriptors_to_file_list(wClipboard* clipboard, UINT32
|
||||
if ((count < 1) || (count != nrDescriptors))
|
||||
return NULL;
|
||||
|
||||
descriptors = (const FILEDESCRIPTORW*)Stream_Pointer(s);
|
||||
descriptors = Stream_ConstPointer(s);
|
||||
|
||||
if (formatId != ClipboardGetFormatId(clipboard, mime_FileGroupDescriptorW))
|
||||
return NULL;
|
||||
|
@ -112,7 +112,7 @@ BOOL sspi_gss_unwrap_token(const SecBuffer* buf, WinPrAsn1_OID* oid, uint16_t* t
|
||||
if (tok_id)
|
||||
Stream_Read_INT16_BE(s, *tok_id);
|
||||
|
||||
token->data = (char*)Stream_Pointer(s);
|
||||
token->data = Stream_Pointer(s);
|
||||
token->length = (UINT)Stream_GetRemainingLength(s);
|
||||
|
||||
return TRUE;
|
||||
|
@ -1182,7 +1182,7 @@ size_t WinPrAsn1DecReadUtcTime(WinPrAsn1Decoder* dec, WinPrAsn1_UTCTIME* target)
|
||||
if (!Stream_CheckAndLogRequiredLength(TAG, &dec->source, len) || len < 12)
|
||||
return 0;
|
||||
|
||||
Stream_StaticConstInit(s, Stream_Pointer(&dec->source), len);
|
||||
Stream_StaticConstInit(s, Stream_ConstPointer(&dec->source), len);
|
||||
|
||||
v = read2digits(s);
|
||||
if (v <= 0)
|
||||
@ -1251,7 +1251,7 @@ static size_t readConstructed(WinPrAsn1Decoder* dec, wStream* s, WinPrAsn1_tag*
|
||||
return 0;
|
||||
|
||||
target->encoding = dec->encoding;
|
||||
Stream_StaticConstInit(&target->source, Stream_Pointer(s), len);
|
||||
Stream_StaticConstInit(&target->source, Stream_ConstPointer(s), len);
|
||||
Stream_Seek(s, len);
|
||||
return ret + len;
|
||||
}
|
||||
@ -1335,7 +1335,7 @@ size_t WinPrAsn1DecPeekContextualTag(WinPrAsn1Decoder* dec, WinPrAsn1_tagId* tag
|
||||
wStream staticS;
|
||||
WINPR_ASSERT(dec);
|
||||
|
||||
Stream_StaticConstInit(&staticS, Stream_Pointer(&dec->source),
|
||||
Stream_StaticConstInit(&staticS, Stream_ConstPointer(&dec->source),
|
||||
Stream_GetRemainingLength(&dec->source));
|
||||
return readContextualTag(dec, &staticS, tagId, ctxtDec);
|
||||
}
|
||||
@ -1476,7 +1476,7 @@ wStream WinPrAsn1DecGetStream(WinPrAsn1Decoder* dec)
|
||||
wStream s = { 0 };
|
||||
WINPR_ASSERT(dec);
|
||||
|
||||
Stream_StaticConstInit(&s, Stream_Pointer(&dec->source),
|
||||
Stream_StaticConstInit(&s, Stream_ConstPointer(&dec->source),
|
||||
Stream_GetRemainingLength(&dec->source));
|
||||
return s;
|
||||
}
|
||||
|
@ -10,15 +10,15 @@ static BOOL TestStream_Verify(wStream* s, size_t mincap, size_t len, size_t pos)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (Stream_Pointer(s) == NULL)
|
||||
if (Stream_ConstPointer(s) == NULL)
|
||||
{
|
||||
printf("stream pointer is null\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (Stream_Pointer(s) < Stream_Buffer(s))
|
||||
if (Stream_PointerAs(s, BYTE*) < Stream_Buffer(s))
|
||||
{
|
||||
printf("stream pointer (%p) or buffer (%p) is invalid\n", (void*)Stream_Pointer(s),
|
||||
printf("stream pointer (%p) or buffer (%p) is invalid\n", Stream_ConstPointer(s),
|
||||
(void*)Stream_Buffer(s));
|
||||
return FALSE;
|
||||
}
|
||||
@ -523,7 +523,7 @@ static BOOL TestStream_Zero(void)
|
||||
if (s->pointer != s->buffer + 5)
|
||||
goto out;
|
||||
|
||||
if (memcmp(Stream_Pointer(s), data + 5, sizeof(data) - 5) != 0)
|
||||
if (memcmp(Stream_ConstPointer(s), data + 5, sizeof(data) - 5) != 0)
|
||||
goto out;
|
||||
|
||||
Stream_SetPosition(s, 0);
|
||||
@ -571,7 +571,7 @@ static BOOL TestStream_Fill(void)
|
||||
if (s->pointer != s->buffer + sizeof(fill))
|
||||
goto out;
|
||||
|
||||
if (memcmp(Stream_Pointer(s), data + sizeof(fill), sizeof(data) - sizeof(fill)) != 0)
|
||||
if (memcmp(Stream_ConstPointer(s), data + sizeof(fill), sizeof(data) - sizeof(fill)) != 0)
|
||||
goto out;
|
||||
|
||||
Stream_SetPosition(s, 0);
|
||||
@ -579,7 +579,7 @@ static BOOL TestStream_Fill(void)
|
||||
if (s->pointer != s->buffer)
|
||||
goto out;
|
||||
|
||||
if (memcmp(Stream_Pointer(s), fill, sizeof(fill)) != 0)
|
||||
if (memcmp(Stream_ConstPointer(s), fill, sizeof(fill)) != 0)
|
||||
goto out;
|
||||
|
||||
rc = TRUE;
|
||||
|
Loading…
Reference in New Issue
Block a user