diff options
author | repo sync <gcondra@google.com> | 2013-04-30 16:36:56 -0700 |
---|---|---|
committer | repo sync <gcondra@google.com> | 2013-04-30 17:37:00 -0700 |
commit | f7b8bc48afd2cef342abc4ad3545a6e7d310b159 (patch) | |
tree | a909396f73fe9a195b5736f8c0753bea760fa09a /services/java/com/android/server/updates | |
parent | a934ad112c9da1c7a342a990fcb06bae2ea7485e (diff) | |
download | frameworks_base-f7b8bc48afd2cef342abc4ad3545a6e7d310b159.zip frameworks_base-f7b8bc48afd2cef342abc4ad3545a6e7d310b159.tar.gz frameworks_base-f7b8bc48afd2cef342abc4ad3545a6e7d310b159.tar.bz2 |
Fix an NPE and fd leak in SELinux policy updater.
Bug: 8769213
Change-Id: Iff80be6109a1586d818754c8f9f5053b816fbd57
Diffstat (limited to 'services/java/com/android/server/updates')
-rw-r--r-- | services/java/com/android/server/updates/SELinuxPolicyInstallReceiver.java | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/services/java/com/android/server/updates/SELinuxPolicyInstallReceiver.java b/services/java/com/android/server/updates/SELinuxPolicyInstallReceiver.java index 0ab86e4..5dd30f1 100644 --- a/services/java/com/android/server/updates/SELinuxPolicyInstallReceiver.java +++ b/services/java/com/android/server/updates/SELinuxPolicyInstallReceiver.java @@ -94,11 +94,15 @@ public class SELinuxPolicyInstallReceiver extends ConfigUpdateInstallReceiver { private void unpackBundle() throws IOException { BufferedInputStream stream = new BufferedInputStream(new FileInputStream(updateContent)); - int[] chunkLengths = readChunkLengths(stream); - installFile(new File(updateDir, seappContextsPath), stream, chunkLengths[0]); - installFile(new File(updateDir, propertyContextsPath), stream, chunkLengths[1]); - installFile(new File(updateDir, fileContextsPath), stream, chunkLengths[2]); - installFile(new File(updateDir, sepolicyPath), stream, chunkLengths[3]); + try { + int[] chunkLengths = readChunkLengths(stream); + installFile(new File(updateDir, seappContextsPath), stream, chunkLengths[0]); + installFile(new File(updateDir, propertyContextsPath), stream, chunkLengths[1]); + installFile(new File(updateDir, fileContextsPath), stream, chunkLengths[2]); + installFile(new File(updateDir, sepolicyPath), stream, chunkLengths[3]); + } finally { + IoUtils.closeQuietly(stream); + } } private void applyUpdate() throws IOException, ErrnoException { @@ -124,10 +128,10 @@ public class SELinuxPolicyInstallReceiver extends ConfigUpdateInstallReceiver { private void setEnforcingMode(Context context) { String mode = Settings.Global.getString(context.getContentResolver(), Settings.Global.SELINUX_STATUS); - if (mode.equals("1")) { + if ("1".equals(mode)) { Slog.i(TAG, "Setting enforcing mode"); SystemProperties.set("persist.selinux.enforcing", mode); - } else if (mode.equals("0")) { + } else if ("0".equals(mode)) { Slog.i(TAG, "Tried to set permissive mode, ignoring"); } else { Slog.e(TAG, "Got invalid enforcing mode: " + mode); |