rdpdr: Fix length calculation for client name response
@@ -1089,9 +1089,9 @@ static UINT rdpdr_send_client_name_request(rdpdrPlugin* rdpdr)
if (!rdpdr->computerName[0])
gethostname(rdpdr->computerName, sizeof(rdpdr->computerName) - 1);
- computerNameLenW = ConvertToUnicode(CP_UTF8, 0, rdpdr->computerName, -1, &computerNameW, 0);
+ computerNameLenW = ConvertToUnicode(CP_UTF8, 0, rdpdr->computerName, -1, &computerNameW, 0) * 2;
WINPR_ASSERT(computerNameLenW >= 0);
- s = Stream_New(NULL, 16U + (size_t)computerNameLenW * 2U + 2U);
+ s = Stream_New(NULL, 16U + (size_t)computerNameLenW);
if (!s)
{
@@ -1104,10 +1104,9 @@ static UINT rdpdr_send_client_name_request(rdpdrPlugin* rdpdr)
Stream_Write_UINT16(s, PAKID_CORE_CLIENT_NAME); /* PacketId (2 bytes) */
Stream_Write_UINT32(s, 1); /* unicodeFlag, 0 for ASCII and 1 for Unicode */
Stream_Write_UINT32(s, 0); /* codePage, must be set to zero */
- Stream_Write_UINT32(s, (UINT32)computerNameLenW +
- 2U); /* computerNameLen, including null terminator */
+ Stream_Write_UINT32(s,
+ (UINT32)computerNameLenW); /* computerNameLen, including null terminator */
Stream_Write(s, computerNameW, (size_t)computerNameLenW);
- Stream_Write_UINT16(s, 0); /* null terminator */
free(computerNameW);
return rdpdr_send(rdpdr, s);
}
@@ -1254,7 +1253,7 @@ static UINT dummy_irp_response(rdpdrPlugin* rdpdr, wStream* s)
Stream_Write_UINT16(output, PAKID_CORE_DEVICE_IOCOMPLETION); /* PacketId (2 bytes) */
Stream_Write_UINT32(output, DeviceId); /* DeviceId (4 bytes) */
Stream_Write_UINT32(output, CompletionId); /* CompletionId (4 bytes) */
- Stream_Write_INT32(output, STATUS_UNSUCCESSFUL); /* IoStatus (4 bytes) */
+ Stream_Write_UINT32(output, (UINT32)STATUS_UNSUCCESSFUL); /* IoStatus (4 bytes) */
Stream_Zero(output, 256 - RDPDR_DEVICE_IO_RESPONSE_LENGTH);
// or usage
@@ -1857,7 +1856,6 @@ static VOID VCAPITYPE rdpdr_virtual_channel_init_event_ex(LPVOID lpUserParam, LP
/* rdpdr is always built-in */
#define VirtualChannelEntryEx rdpdr_VirtualChannelEntryEx
-extern BOOL VCAPITYPE VirtualChannelEntryEx(PCHANNEL_ENTRY_POINTS pEntryPoints, PVOID pInitHandle);
BOOL VCAPITYPE VirtualChannelEntryEx(PCHANNEL_ENTRY_POINTS pEntryPoints, PVOID pInitHandle)
{
UINT rc;
