OSDN Git Service

Fixed NullPointerException in IpSecService-Netd binder layer
authorManoj Boopathi Raj <manojboopathi@google.com>
Thu, 26 Oct 2017 18:49:02 +0000 (11:49 -0700)
committermanojboopathi <manojboopathi@google.com>
Thu, 26 Oct 2017 20:10:22 +0000 (13:10 -0700)
Replaced null with empty byte array in createTransportModeTransform
for null auth.getKey, crypt.getKey() and authCrypt.getKey()

Test: Ran CTS test
Bug: 68052730
Change-Id: I5110b1297b4bfbb5766e8ecfd3d64f8110b52945

services/core/java/com/android/server/IpSecService.java
tests/net/java/com/android/server/IpSecServiceParameterizedTest.java

index a139ac4..1154fbe 100644 (file)
@@ -944,13 +944,13 @@ public class IpSecService extends IIpSecService.Stub {
                                 (c.getNetwork() != null) ? c.getNetwork().getNetworkHandle() : 0,
                                 spi,
                                 (auth != null) ? auth.getName() : "",
-                                (auth != null) ? auth.getKey() : null,
+                                (auth != null) ? auth.getKey() : new byte[] {},
                                 (auth != null) ? auth.getTruncationLengthBits() : 0,
                                 (crypt != null) ? crypt.getName() : "",
-                                (crypt != null) ? crypt.getKey() : null,
+                                (crypt != null) ? crypt.getKey() : new byte[] {},
                                 (crypt != null) ? crypt.getTruncationLengthBits() : 0,
                                 (authCrypt != null) ? authCrypt.getName() : "",
-                                (authCrypt != null) ? authCrypt.getKey() : null,
+                                (authCrypt != null) ? authCrypt.getKey() : new byte[] {},
                                 (authCrypt != null) ? authCrypt.getTruncationLengthBits() : 0,
                                 encapType,
                                 encapLocalPort,
index b4b8094..9e97d84 100644 (file)
@@ -206,7 +206,7 @@ public class IpSecServiceParameterizedTest {
                         eq(CRYPT_KEY),
                         anyInt(),
                         eq(""),
-                        isNull(),
+                        eq(new byte[] {}),
                         eq(0),
                         anyInt(),
                         anyInt(),
@@ -227,7 +227,7 @@ public class IpSecServiceParameterizedTest {
                         eq(CRYPT_KEY),
                         anyInt(),
                         eq(""),
-                        isNull(),
+                        eq(new byte[] {}),
                         eq(0),
                         anyInt(),
                         anyInt(),
@@ -256,10 +256,10 @@ public class IpSecServiceParameterizedTest {
                         anyLong(),
                         eq(TEST_SPI_OUT),
                         eq(""),
-                        isNull(),
+                        eq(new byte[] {}),
                         eq(0),
                         eq(""),
-                        isNull(),
+                        eq(new byte[] {}),
                         eq(0),
                         eq(IpSecAlgorithm.AUTH_CRYPT_AES_GCM),
                         eq(CRYPT_KEY),
@@ -277,10 +277,10 @@ public class IpSecServiceParameterizedTest {
                         anyLong(),
                         eq(TEST_SPI_IN),
                         eq(""),
-                        isNull(),
+                        eq(new byte[] {}),
                         eq(0),
                         eq(""),
-                        isNull(),
+                        eq(new byte[] {}),
                         eq(0),
                         eq(IpSecAlgorithm.AUTH_CRYPT_AES_GCM),
                         eq(CRYPT_KEY),