From da2018efeb4388d43deb378e9b56029606cdd3bc Mon Sep 17 00:00:00 2001 From: Christopher Tate Date: Thu, 13 Oct 2016 12:12:29 -0700 Subject: [PATCH] Only full-data back up regular files + directories Ignore every filesystem entity that is not a regular file or directory. In particular, we now ignore not only symlinks but also sockets, pipes, et cetera. Bug 32143362 Change-Id: If51b54df1f7a643af145eb15bf12d389d19f8780 --- core/java/android/app/backup/BackupAgent.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/core/java/android/app/backup/BackupAgent.java b/core/java/android/app/backup/BackupAgent.java index 3ba81c8689b96..bad632555c421 100644 --- a/core/java/android/app/backup/BackupAgent.java +++ b/core/java/android/app/backup/BackupAgent.java @@ -649,10 +649,11 @@ public abstract class BackupAgent extends ContextWrapper { File file = scanQueue.remove(0); String filePath; try { - // Ignore symlinks outright + // Ignore things that aren't "real" files or dirs StructStat stat = Os.lstat(file.getPath()); - if (OsConstants.S_ISLNK(stat.st_mode)) { - if (DEBUG) Log.i(TAG, "Symlink (skipping)!: " + file); + if (!OsConstants.S_ISREG(stat.st_mode) + && !OsConstants.S_ISDIR(stat.st_mode)) { + if (DEBUG) Log.i(TAG, "Not a file/dir (skipping)!: " + file); continue; }