Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 302019d9 authored by Raj Mojumder's avatar Raj Mojumder Committed by Android (Google) Code Review
Browse files

Merge "Add timeout to usb_device_get_string_ucs2 invocation to prevent...

Merge "Add timeout to usb_device_get_string_ucs2 invocation to prevent potential unbounded stuck state."
parents 7bd671e1 a8c9d5dc
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@
#include <usbhost/usbhost.h>

#define MAX_DESCRIPTORS_LENGTH 4096
static const int USB_CONTROL_TRANSFER_TIMEOUT_MS = 200;

// com.android.server.usb.descriptors
extern "C" {
@@ -85,7 +86,8 @@ jstring JNICALL Java_com_android_server_usb_descriptors_UsbDescriptorParser_getD
    jbyte* byteBuffer = NULL;
    size_t numUSC2Bytes = 0;
    int retVal =
            usb_device_get_string_ucs2(device, stringId, 0 /*timeout*/,
            usb_device_get_string_ucs2(device, stringId,
                                       USB_CONTROL_TRANSFER_TIMEOUT_MS,
                                       (void**)&byteBuffer, &numUSC2Bytes);

    jstring j_str = NULL;