summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Chris Tate <ctate@android.com> 2016-10-03 21:06:20 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2016-10-03 21:06:22 +0000
commitee28c8c22ca5b2f22cd27feccc672da504c23b1e (patch)
tree3a474ccf1f115b0a05fc4cf20beb3b5ff5cdee4e
parent8051c9222e5e6b0120aee0590cbbac737155b589 (diff)
parent91bb0e5cca2612545b3b046f5bb1b3bc747be8af (diff)
Merge "Explicitly close FD binder parameters in backup/restore API calls" into nyc-mr1-dev
-rw-r--r--core/java/android/app/backup/BackupAgent.java22
1 files changed, 22 insertions, 0 deletions
diff --git a/core/java/android/app/backup/BackupAgent.java b/core/java/android/app/backup/BackupAgent.java
index bc8280681e4a..3ba81c8689b9 100644
--- a/core/java/android/app/backup/BackupAgent.java
+++ b/core/java/android/app/backup/BackupAgent.java
@@ -35,6 +35,8 @@ import android.system.StructStat;
import android.util.ArraySet;
import android.util.Log;
+import libcore.io.IoUtils;
+
import org.xmlpull.v1.XmlPullParserException;
import java.io.File;
@@ -921,6 +923,13 @@ public abstract class BackupAgent extends ContextWrapper {
} catch (RemoteException e) {
// we'll time out anyway, so we're safe
}
+
+ // Don't close the fd out from under the system service if this was local
+ if (Binder.getCallingPid() != Process.myPid()) {
+ IoUtils.closeQuietly(oldState);
+ IoUtils.closeQuietly(data);
+ IoUtils.closeQuietly(newState);
+ }
}
}
@@ -951,6 +960,11 @@ public abstract class BackupAgent extends ContextWrapper {
} catch (RemoteException e) {
// we'll time out anyway, so we're safe
}
+
+ if (Binder.getCallingPid() != Process.myPid()) {
+ IoUtils.closeQuietly(data);
+ IoUtils.closeQuietly(newState);
+ }
}
}
@@ -994,6 +1008,10 @@ public abstract class BackupAgent extends ContextWrapper {
} catch (RemoteException e) {
// we'll time out anyway, so we're safe
}
+
+ if (Binder.getCallingPid() != Process.myPid()) {
+ IoUtils.closeQuietly(data);
+ }
}
}
@@ -1041,6 +1059,10 @@ public abstract class BackupAgent extends ContextWrapper {
} catch (RemoteException e) {
// we'll time out anyway, so we're safe
}
+
+ if (Binder.getCallingPid() != Process.myPid()) {
+ IoUtils.closeQuietly(data);
+ }
}
}