OSDN Git Service

SerialManager: Only allow opening files that are whitelisted serial port devices
authorMike Lockwood <lockwood@google.com>
Wed, 31 Oct 2012 19:41:14 +0000 (12:41 -0700)
committerMike Lockwood <lockwood@google.com>
Wed, 31 Oct 2012 19:41:14 +0000 (12:41 -0700)
Bug: 7367956

Change-Id: I82fd8d2694dda89332497d9eded5445a0262e12b
Signed-off-by: Mike Lockwood <lockwood@google.com>
services/java/com/android/server/SerialService.java

index 5d2b2a0..1abe458 100644 (file)
@@ -51,7 +51,12 @@ public class SerialService extends ISerialManager.Stub {
 
     public ParcelFileDescriptor openSerialPort(String path) {
         mContext.enforceCallingOrSelfPermission(android.Manifest.permission.SERIAL_PORT, null);
-        return native_open(path);
+        for (int i = 0; i < mSerialPorts.length; i++) {
+            if (mSerialPorts[i].equals(path)) {
+                return native_open(path);
+            }
+        }
+        throw new IllegalArgumentException("Invalid serial port " + path);
     }
 
     private native ParcelFileDescriptor native_open(String path);