From 50b0a158ce33c44ba4b45091912bde09c5e40e79 Mon Sep 17 00:00:00 2001 From: cathery Date: Thu, 12 Mar 2020 17:48:26 +0300 Subject: [PATCH] Clear the interfaces array before passing it to usbhs to avoid bad input --- source/Sysmodule/source/usb_module.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source/Sysmodule/source/usb_module.cpp b/source/Sysmodule/source/usb_module.cpp index d5134a0..010a5cd 100644 --- a/source/Sysmodule/source/usb_module.cpp +++ b/source/Sysmodule/source/usb_module.cpp @@ -8,6 +8,7 @@ #include "SwitchUSBDevice.h" #include "ControllerHelpers.h" #include "log.h" +#include namespace syscon::usb { @@ -120,6 +121,7 @@ namespace syscon::usb std::scoped_lock usbLock(usbMutex); eventClear(usbHsGetInterfaceStateChangeEvent()); + memset(interfaces, 0, sizeof(interfaces)); if (R_SUCCEEDED(usbHsQueryAcquiredInterfaces(interfaces, sizeof(interfaces), &total_entries))) { for (auto it = controllers::Get().begin(); it != controllers::Get().end(); ++it) @@ -161,6 +163,7 @@ namespace syscon::usb .bInterfaceProtocol = iprotocol, }; s32 out_entries = 0; + memset(interfaces, 0, sizeof(interfaces)); usbHsQueryAvailableInterfaces(&filter, interfaces, sizeof(interfaces), &out_entries); return out_entries; }