From a63449e56a571faff76fd4c86d427d2b3b7e0089 Mon Sep 17 00:00:00 2001 From: b30052170 Date: Fri, 1 Nov 2024 17:34:01 +0800 Subject: [PATCH] =?UTF-8?q?usb=20interface=20=E6=96=B9=E6=B3=95=E6=95=B4?= =?UTF-8?q?=E6=94=B9=20Signed-off-by:baozewei@huawei.com?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: b30052170 --- ohos-usb-manager.patch | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/ohos-usb-manager.patch b/ohos-usb-manager.patch index db72cb40..7d18cd33 100644 --- a/ohos-usb-manager.patch +++ b/ohos-usb-manager.patch @@ -1,9 +1,9 @@ diff --git a/backend/usb_manager.cxx b/backend/usb_manager.cxx new file mode 100644 -index 0000000..2604e10 +index 0000000..f903774 --- /dev/null +++ b/backend/usb_manager.cxx -@@ -0,0 +1,663 @@ +@@ -0,0 +1,669 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); @@ -448,11 +448,17 @@ index 0000000..2604e10 + if (usbIfaces[usbIfacesIndex].GetId() == ifaceIndex) { + ohusb_interface_descriptor *altsetting; + altsetting = (ohusb_interface_descriptor *) -+ realloc(usbInterface->altsetting, sizeof(*altsetting) * (size_t)(usbInterface->num_altsetting +1)); ++ calloc((size_t)(usbInterface->num_altsetting + 1), sizeof(*altsetting)); + if (altsetting == nullptr) { + fprintf(stderr, "DEBUG: ParseInterface altsetting is nullptr\n"); + return OHUSB_ERROR_NO_MEM; + } ++ if (usbInterface->num_altsetting != 0 && ++ memcpy_s(altsetting, sizeof(*altsetting) * (size_t)(usbInterface->num_altsetting), ++ usbInterface->altsetting, sizeof(*altsetting) * (size_t)(usbInterface->num_altsetting)) != 0) { ++ fprintf(stderr, "DEBUG: ParseInterface memcpy_s fail.\n"); ++ return OHUSB_ERROR_NO_MEM; ++ } + usbInterface->altsetting = altsetting; + if (ParseInterfaceDescriptor(usbIfaces[usbIfacesIndex], altsetting + (usbInterface->num_altsetting)) + != OHUSB_SUCCESS) {