mirror of
https://github.com/morgan9e/FreeRDP
synced 2026-04-14 16:34:18 +09:00
@@ -206,6 +206,10 @@ static UINT audin_process_formats(AUDIN_PLUGIN* audin, AUDIN_CHANNEL_CALLBACK* c
|
||||
}
|
||||
|
||||
Stream_Seek_UINT32(s); /* cbSizeFormatsPacket */
|
||||
|
||||
audio_formats_free(callback->formats, callback->formats_count);
|
||||
callback->formats_count = 0;
|
||||
|
||||
callback->formats = audio_formats_new(NumFormats);
|
||||
|
||||
if (!callback->formats)
|
||||
|
||||
@@ -574,8 +574,10 @@ BOOL ndr_read_uconformant_array(NdrContext* context, wStream* s, const NdrArrayH
|
||||
WINPR_ASSERT(itemType);
|
||||
WINPR_ASSERT(vtarget);
|
||||
|
||||
UINT32 count = 0;
|
||||
if (itemType->itemSize == 0)
|
||||
return FALSE;
|
||||
|
||||
UINT32 count = 0;
|
||||
if (!ndr_read_uint32(context, s, &count))
|
||||
return FALSE;
|
||||
|
||||
@@ -910,6 +912,8 @@ BOOL ndr_read_pointedMessageEx(NdrContext* context, wStream* s, ndr_refid ptrId,
|
||||
if (!ret)
|
||||
{
|
||||
size_t itemCount = ndr_hintsCount(descr, hints);
|
||||
if (itemCount == 0)
|
||||
return FALSE;
|
||||
ret = calloc(itemCount, descr->itemSize);
|
||||
if (!ret)
|
||||
return FALSE;
|
||||
|
||||
@@ -454,14 +454,12 @@ static void func_select_all_interface_for_msconfig(IUDEVICE* pdev,
|
||||
MSUSB_CONFIG_DESCRIPTOR* MsConfig)
|
||||
{
|
||||
MSUSB_INTERFACE_DESCRIPTOR** MsInterfaces = MsConfig->MsInterfaces;
|
||||
BYTE InterfaceNumber = 0;
|
||||
BYTE AlternateSetting = 0;
|
||||
UINT32 NumInterfaces = MsConfig->NumInterfaces;
|
||||
|
||||
for (UINT32 inum = 0; inum < NumInterfaces; inum++)
|
||||
{
|
||||
InterfaceNumber = MsInterfaces[inum]->InterfaceNumber;
|
||||
AlternateSetting = MsInterfaces[inum]->AlternateSetting;
|
||||
const BYTE InterfaceNumber = MsInterfaces[inum]->InterfaceNumber;
|
||||
const BYTE AlternateSetting = MsInterfaces[inum]->AlternateSetting;
|
||||
pdev->select_interface(pdev, InterfaceNumber, AlternateSetting);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -582,25 +582,13 @@ static MSUSB_CONFIG_DESCRIPTOR*
|
||||
libusb_udev_complete_msconfig_setup(IUDEVICE* idev, MSUSB_CONFIG_DESCRIPTOR* MsConfig)
|
||||
{
|
||||
UDEVICE* pdev = (UDEVICE*)idev;
|
||||
MSUSB_INTERFACE_DESCRIPTOR** MsInterfaces = NULL;
|
||||
MSUSB_INTERFACE_DESCRIPTOR* MsInterface = NULL;
|
||||
MSUSB_PIPE_DESCRIPTOR** MsPipes = NULL;
|
||||
MSUSB_PIPE_DESCRIPTOR* MsPipe = NULL;
|
||||
MSUSB_PIPE_DESCRIPTOR** t_MsPipes = NULL;
|
||||
MSUSB_PIPE_DESCRIPTOR* t_MsPipe = NULL;
|
||||
LIBUSB_CONFIG_DESCRIPTOR* LibusbConfig = NULL;
|
||||
const LIBUSB_INTERFACE* LibusbInterface = NULL;
|
||||
const LIBUSB_INTERFACE_DESCRIPTOR* LibusbAltsetting = NULL;
|
||||
const LIBUSB_ENDPOINT_DESCEIPTOR* LibusbEndpoint = NULL;
|
||||
BYTE LibusbNumEndpoint = 0;
|
||||
URBDRC_PLUGIN* urbdrc = NULL;
|
||||
UINT32 MsOutSize = 0;
|
||||
|
||||
if (!pdev || !pdev->LibusbConfig || !pdev->urbdrc || !MsConfig)
|
||||
return NULL;
|
||||
|
||||
urbdrc = pdev->urbdrc;
|
||||
LibusbConfig = pdev->LibusbConfig;
|
||||
URBDRC_PLUGIN* urbdrc = pdev->urbdrc;
|
||||
LIBUSB_CONFIG_DESCRIPTOR* LibusbConfig = pdev->LibusbConfig;
|
||||
|
||||
if (LibusbConfig->bNumInterfaces != MsConfig->NumInterfaces)
|
||||
{
|
||||
@@ -608,28 +596,57 @@ libusb_udev_complete_msconfig_setup(IUDEVICE* idev, MSUSB_CONFIG_DESCRIPTOR* MsC
|
||||
"Select Configuration: Libusb NumberInterfaces(%" PRIu8 ") is different "
|
||||
"with MsConfig NumberInterfaces(%" PRIu32 ")",
|
||||
LibusbConfig->bNumInterfaces, MsConfig->NumInterfaces);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* replace MsPipes for libusb */
|
||||
MsInterfaces = MsConfig->MsInterfaces;
|
||||
MSUSB_INTERFACE_DESCRIPTOR** MsInterfaces = MsConfig->MsInterfaces;
|
||||
|
||||
for (UINT32 inum = 0; inum < MsConfig->NumInterfaces; inum++)
|
||||
{
|
||||
MsInterface = MsInterfaces[inum];
|
||||
MSUSB_INTERFACE_DESCRIPTOR* MsInterface = MsInterfaces[inum];
|
||||
if (MsInterface->InterfaceNumber >= MsConfig->NumInterfaces)
|
||||
{
|
||||
WLog_Print(urbdrc->log, WLOG_ERROR,
|
||||
"MSUSB_CONFIG_DESCRIPTOR::NumInterfaces (%" PRIu32
|
||||
" <= MSUSB_INTERFACE_DESCRIPTOR::InterfaceNumber( %" PRIu8 ")",
|
||||
MsConfig->NumInterfaces, MsInterface->InterfaceNumber);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const LIBUSB_INTERFACE* LibusbInterface =
|
||||
&LibusbConfig->interface[MsInterface->InterfaceNumber];
|
||||
if (MsInterface->AlternateSetting >= LibusbInterface->num_altsetting)
|
||||
{
|
||||
WLog_Print(urbdrc->log, WLOG_ERROR,
|
||||
"LIBUSB_INTERFACE::num_altsetting (%" PRId32
|
||||
" <= MSUSB_INTERFACE_DESCRIPTOR::AlternateSetting( %" PRIu8 ")",
|
||||
LibusbInterface->num_altsetting, MsInterface->AlternateSetting);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
for (UINT32 inum = 0; inum < MsConfig->NumInterfaces; inum++)
|
||||
{
|
||||
MSUSB_INTERFACE_DESCRIPTOR* MsInterface = MsInterfaces[inum];
|
||||
|
||||
/* get libusb's number of endpoints */
|
||||
LibusbInterface = &LibusbConfig->interface[MsInterface->InterfaceNumber];
|
||||
LibusbAltsetting = &LibusbInterface->altsetting[MsInterface->AlternateSetting];
|
||||
LibusbNumEndpoint = LibusbAltsetting->bNumEndpoints;
|
||||
t_MsPipes =
|
||||
const LIBUSB_INTERFACE* LibusbInterface =
|
||||
&LibusbConfig->interface[MsInterface->InterfaceNumber];
|
||||
const LIBUSB_INTERFACE_DESCRIPTOR* LibusbAltsetting =
|
||||
&LibusbInterface->altsetting[MsInterface->AlternateSetting];
|
||||
const BYTE LibusbNumEndpoint = LibusbAltsetting->bNumEndpoints;
|
||||
MSUSB_PIPE_DESCRIPTOR** t_MsPipes =
|
||||
(MSUSB_PIPE_DESCRIPTOR**)calloc(LibusbNumEndpoint, sizeof(MSUSB_PIPE_DESCRIPTOR*));
|
||||
|
||||
for (UINT32 pnum = 0; pnum < LibusbNumEndpoint; pnum++)
|
||||
{
|
||||
t_MsPipe = (MSUSB_PIPE_DESCRIPTOR*)calloc(1, sizeof(MSUSB_PIPE_DESCRIPTOR));
|
||||
MSUSB_PIPE_DESCRIPTOR* t_MsPipe =
|
||||
(MSUSB_PIPE_DESCRIPTOR*)calloc(1, sizeof(MSUSB_PIPE_DESCRIPTOR));
|
||||
|
||||
if (pnum < MsInterface->NumberOfPipes && MsInterface->MsPipes)
|
||||
{
|
||||
MsPipe = MsInterface->MsPipes[pnum];
|
||||
MSUSB_PIPE_DESCRIPTOR* MsPipe = MsInterface->MsPipes[pnum];
|
||||
t_MsPipe->MaximumPacketSize = MsPipe->MaximumPacketSize;
|
||||
t_MsPipe->MaximumTransferSize = MsPipe->MaximumTransferSize;
|
||||
t_MsPipe->PipeFlags = MsPipe->PipeFlags;
|
||||
@@ -668,10 +685,12 @@ libusb_udev_complete_msconfig_setup(IUDEVICE* idev, MSUSB_CONFIG_DESCRIPTOR* MsC
|
||||
for (UINT32 inum = 0; inum < MsConfig->NumInterfaces; inum++)
|
||||
{
|
||||
MsOutSize += 16;
|
||||
MsInterface = MsInterfaces[inum];
|
||||
MSUSB_INTERFACE_DESCRIPTOR* MsInterface = MsInterfaces[inum];
|
||||
/* get libusb's interface */
|
||||
LibusbInterface = &LibusbConfig->interface[MsInterface->InterfaceNumber];
|
||||
LibusbAltsetting = &LibusbInterface->altsetting[MsInterface->AlternateSetting];
|
||||
const LIBUSB_INTERFACE* LibusbInterface =
|
||||
&LibusbConfig->interface[MsInterface->InterfaceNumber];
|
||||
const LIBUSB_INTERFACE_DESCRIPTOR* LibusbAltsetting =
|
||||
&LibusbInterface->altsetting[MsInterface->AlternateSetting];
|
||||
/* InterfaceHandle: 4 bytes
|
||||
* ---------------------------------------------------------------
|
||||
* ||<<< 1 byte >>>|<<< 1 byte >>>|<<< 1 byte >>>|<<< 1 byte >>>||
|
||||
@@ -688,15 +707,16 @@ libusb_udev_complete_msconfig_setup(IUDEVICE* idev, MSUSB_CONFIG_DESCRIPTOR* MsC
|
||||
MsInterface->bInterfaceSubClass = LibusbAltsetting->bInterfaceSubClass;
|
||||
MsInterface->bInterfaceProtocol = LibusbAltsetting->bInterfaceProtocol;
|
||||
MsInterface->InitCompleted = 1;
|
||||
MsPipes = MsInterface->MsPipes;
|
||||
LibusbNumEndpoint = LibusbAltsetting->bNumEndpoints;
|
||||
MSUSB_PIPE_DESCRIPTOR** MsPipes = MsInterface->MsPipes;
|
||||
const BYTE LibusbNumEndpoint = LibusbAltsetting->bNumEndpoints;
|
||||
|
||||
for (UINT32 pnum = 0; pnum < LibusbNumEndpoint; pnum++)
|
||||
{
|
||||
MsOutSize += 20;
|
||||
MsPipe = MsPipes[pnum];
|
||||
|
||||
MSUSB_PIPE_DESCRIPTOR* MsPipe = MsPipes[pnum];
|
||||
/* get libusb's endpoint */
|
||||
LibusbEndpoint = &LibusbAltsetting->endpoint[pnum];
|
||||
const LIBUSB_ENDPOINT_DESCEIPTOR* LibusbEndpoint = &LibusbAltsetting->endpoint[pnum];
|
||||
/* PipeHandle: 4 bytes
|
||||
* ---------------------------------------------------------------
|
||||
* ||<<< 1 byte >>>|<<< 1 byte >>>|<<<<<<<<<< 2 byte >>>>>>>>>>>||
|
||||
|
||||
@@ -134,6 +134,8 @@ BOOL msusb_msinterface_replace(MSUSB_CONFIG_DESCRIPTOR* MsConfig, BYTE Interface
|
||||
{
|
||||
if (!MsConfig || !MsConfig->MsInterfaces)
|
||||
return FALSE;
|
||||
if (MsConfig->NumInterfaces <= InterfaceNumber)
|
||||
return FALSE;
|
||||
|
||||
msusb_msinterface_free(MsConfig->MsInterfaces[InterfaceNumber]);
|
||||
MsConfig->MsInterfaces[InterfaceNumber] = NewMsInterface;
|
||||
@@ -142,12 +144,10 @@ BOOL msusb_msinterface_replace(MSUSB_CONFIG_DESCRIPTOR* MsConfig, BYTE Interface
|
||||
|
||||
MSUSB_INTERFACE_DESCRIPTOR* msusb_msinterface_read(wStream* s)
|
||||
{
|
||||
MSUSB_INTERFACE_DESCRIPTOR* MsInterface = NULL;
|
||||
|
||||
if (!Stream_CheckAndLogRequiredCapacity(TAG, (s), 12))
|
||||
return NULL;
|
||||
|
||||
MsInterface = msusb_msinterface_new();
|
||||
MSUSB_INTERFACE_DESCRIPTOR* MsInterface = msusb_msinterface_new();
|
||||
|
||||
if (!MsInterface)
|
||||
return NULL;
|
||||
|
||||
@@ -32,6 +32,7 @@ if(ENABLE_WARNING_ERROR)
|
||||
endif()
|
||||
|
||||
list(APPEND COMMON_COMPILER_FLAGS -fno-omit-frame-pointer -Wredundant-decls)
|
||||
list(APPEND COMMON_COMPILER_FLAGS -fsigned-char)
|
||||
|
||||
include(ExportAllSymbols)
|
||||
include(CompilerSanitizerOptions)
|
||||
|
||||
@@ -400,7 +400,8 @@ static inline char* base64_encode(const BYTE* WINPR_RESTRICT alphabet,
|
||||
|
||||
static inline int base64_decode_char(const signed char* WINPR_RESTRICT alphabet, char c)
|
||||
{
|
||||
if (c <= '\0')
|
||||
/* ensure char is signed for this check */
|
||||
if ((int)c <= '\0')
|
||||
return -1;
|
||||
|
||||
return alphabet[(size_t)c];
|
||||
|
||||
Reference in New Issue
Block a user