mirror of
https://github.com/cathery/sys-con.git
synced 2025-01-16 16:22:02 +00:00
Clear the interfaces array before passing it to usbhs to avoid bad input
This commit is contained in:
parent
2042d65935
commit
50b0a158ce
@ -8,6 +8,7 @@
|
|||||||
#include "SwitchUSBDevice.h"
|
#include "SwitchUSBDevice.h"
|
||||||
#include "ControllerHelpers.h"
|
#include "ControllerHelpers.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
namespace syscon::usb
|
namespace syscon::usb
|
||||||
{
|
{
|
||||||
@ -120,6 +121,7 @@ namespace syscon::usb
|
|||||||
|
|
||||||
std::scoped_lock usbLock(usbMutex);
|
std::scoped_lock usbLock(usbMutex);
|
||||||
eventClear(usbHsGetInterfaceStateChangeEvent());
|
eventClear(usbHsGetInterfaceStateChangeEvent());
|
||||||
|
memset(interfaces, 0, sizeof(interfaces));
|
||||||
if (R_SUCCEEDED(usbHsQueryAcquiredInterfaces(interfaces, sizeof(interfaces), &total_entries)))
|
if (R_SUCCEEDED(usbHsQueryAcquiredInterfaces(interfaces, sizeof(interfaces), &total_entries)))
|
||||||
{
|
{
|
||||||
for (auto it = controllers::Get().begin(); it != controllers::Get().end(); ++it)
|
for (auto it = controllers::Get().begin(); it != controllers::Get().end(); ++it)
|
||||||
@ -161,6 +163,7 @@ namespace syscon::usb
|
|||||||
.bInterfaceProtocol = iprotocol,
|
.bInterfaceProtocol = iprotocol,
|
||||||
};
|
};
|
||||||
s32 out_entries = 0;
|
s32 out_entries = 0;
|
||||||
|
memset(interfaces, 0, sizeof(interfaces));
|
||||||
usbHsQueryAvailableInterfaces(&filter, interfaces, sizeof(interfaces), &out_entries);
|
usbHsQueryAvailableInterfaces(&filter, interfaces, sizeof(interfaces), &out_entries);
|
||||||
return out_entries;
|
return out_entries;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user