summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorRoshan Pius <rpius@google.com>2019-11-13 13:48:36 -0800
committerRoshan Pius <rpius@google.com>2019-11-13 22:04:30 +0000
commit1f3f7be3dacc8afde521aed1ebaa0e883a46dc10 (patch)
tree13d125b98f6565ae9764f037e1cd087ac5bdb571 /service
parent85065f59a468847d6abe349f182623ed4f94aa71 (diff)
WifiKeyStore: Handle existing config being null
This could be null when there is no existing config matching the added config. Bug: 144444818 Test: Verify the crash reported in the bug no longer occurs. Change-Id: Ic08f3cf84360a9caf50be514a9920ec25163b1c8
Diffstat (limited to 'service')
-rw-r--r--service/java/com/android/server/wifi/WifiKeyStore.java28
1 files changed, 17 insertions, 11 deletions
diff --git a/service/java/com/android/server/wifi/WifiKeyStore.java b/service/java/com/android/server/wifi/WifiKeyStore.java
index 11a23e64f..87289fa68 100644
--- a/service/java/com/android/server/wifi/WifiKeyStore.java
+++ b/service/java/com/android/server/wifi/WifiKeyStore.java
@@ -123,8 +123,10 @@ public class WifiKeyStore {
caCertificateAliases.add(alias);
}
}
- // Remove old private keys.
- removeEntryFromKeyStore(existingAlias);
+ if (existingAlias != null) {
+ // Remove old private keys.
+ removeEntryFromKeyStore(existingAlias);
+ }
// Remove any old CA certs.
for (String oldAlias : oldCaCertificatesToRemove) {
removeEntryFromKeyStore(oldAlias);
@@ -245,21 +247,25 @@ public class WifiKeyStore {
public boolean updateNetworkKeys(WifiConfiguration config, WifiConfiguration existingConfig) {
Preconditions.checkNotNull(mKeyStore);
Preconditions.checkNotNull(config.enterpriseConfig);
- Preconditions.checkNotNull(existingConfig.enterpriseConfig);
WifiEnterpriseConfig enterpriseConfig = config.enterpriseConfig;
+ /* config passed may include only fields being updated.
+ * In order to generate the key id, fetch uninitialized
+ * fields from the currently tracked configuration
+ */
+ String keyId = config.getKeyIdForCredentials(existingConfig);
+ WifiEnterpriseConfig existingEnterpriseConfig = null;
+ String existingKeyId = null;
+ if (existingConfig != null) {
+ Preconditions.checkNotNull(existingConfig.enterpriseConfig);
+ existingEnterpriseConfig = existingConfig.enterpriseConfig;
+ existingKeyId = existingConfig.getKeyIdForCredentials(existingConfig);
+ }
if (!needsKeyStore(enterpriseConfig)) {
return true;
}
try {
- /* config passed may include only fields being updated.
- * In order to generate the key id, fetch uninitialized
- * fields from the currently tracked configuration
- */
- String keyId = config.getKeyIdForCredentials(existingConfig);
- String existingKeyId = existingConfig.getKeyIdForCredentials(existingConfig);
- if (!installKeys(existingConfig.enterpriseConfig, enterpriseConfig,
- existingKeyId, keyId)) {
+ if (!installKeys(existingEnterpriseConfig, enterpriseConfig, existingKeyId, keyId)) {
Log.e(TAG, config.SSID + ": failed to install keys");
return false;
}