OSDN Git Service

Bluetooth: Check descriptors size in BluetoothHidDeviceAppSdpSettings
authorJakub Pawlowski <jpawlowski@google.com>
Thu, 29 Nov 2018 17:54:21 +0000 (18:54 +0100)
committerJP Sugarbroad <jpsugar@google.com>
Thu, 10 Jan 2019 22:42:07 +0000 (14:42 -0800)
Bug: 119819889
Test: compilation
Change-Id: If51d0e2af74d99758f79a603d40cc2f5c84e4dde
Merged-In: If51d0e2af74d99758f79a603d40cc2f5c84e4dde
(cherry picked from commit f843ccbf9e3791b426af78389e276c46dbec75e1)

core/java/android/bluetooth/BluetoothHidDeviceAppSdpSettings.java

index f9a2245..5061fa0 100644 (file)
@@ -18,12 +18,15 @@ package android.bluetooth;
 
 import android.os.Parcel;
 import android.os.Parcelable;
+import android.util.EventLog;
 
 import java.util.Random;
 
 /** @hide */
 public final class BluetoothHidDeviceAppSdpSettings implements Parcelable {
 
+    private static final int MAX_DESCRIPTOR_SIZE = 2048;
+
     final public String name;
     final public String description;
     final public String provider;
@@ -36,6 +39,12 @@ public final class BluetoothHidDeviceAppSdpSettings implements Parcelable {
         this.description = description;
         this.provider = provider;
         this.subclass = subclass;
+
+        if (descriptors == null || descriptors.length > MAX_DESCRIPTOR_SIZE) {
+            EventLog.writeEvent(0x534e4554, "119819889", -1, "");
+            throw new IllegalArgumentException("descriptors must be not null and shorter than "
+                    + MAX_DESCRIPTOR_SIZE);
+        }
         this.descriptors = descriptors.clone();
     }