[mini_installer] Leave files with reparse points alone when deleting.

mini_installer recursively deletes directories left behind from previous
runs. As it recurses through them, it may delete files with reparse
points in those dirs. This is bad, since such files may actually be
maliciously-created links to other entities on the filesystem. This CL
skips anything with a reparse point during deletion -- since Chrome
never creates files/dirs with reparse points, it shouldn't try to delete
them.

BUG=1125018
R=wfh@chromium.org

Change-Id: I9897947ed883a91758c31990ed0b9648c38d2942
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2409698
Auto-Submit: Greg Thompson <grt@chromium.org>
Commit-Queue: Will Harris <wfh@chromium.org>
Reviewed-by: Will Harris <wfh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#806715}
diff --git a/chrome/installer/mini_installer/mini_installer.cc b/chrome/installer/mini_installer/mini_installer.cc
index 1c94fd3..d01bb78c 100644
--- a/chrome/installer/mini_installer/mini_installer.cc
+++ b/chrome/installer/mini_installer/mini_installer.cc
@@ -757,6 +757,11 @@
   HANDLE find = ::FindFirstFile(path->get(), &find_data);
   if (find != INVALID_HANDLE_VALUE) {
     do {
+      // Chrome never creates files/directories with reparse points (i.e.,
+      // mounted folders, links, etc), so never try to delete them.
+      if (find_data.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT)
+        continue;
+
       // Use the short name if available to make the most of our buffer.
       const wchar_t* name = find_data.cAlternateFileName[0]
                                 ? find_data.cAlternateFileName
@@ -768,12 +773,10 @@
       if (!path->append(name))
         continue;  // Continue in spite of too long names.
 
-      if ((find_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) &&
-          !(find_data.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT)) {
+      if (find_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
         RecursivelyDeleteDirectory(path);
-      } else {
+      else
         ::DeleteFile(path->get());
-      }
     } while (::FindNextFile(find, &find_data));
     ::FindClose(find);
   }
@@ -803,11 +806,12 @@
 
   PathString path;
   do {
-    // Skip over directories that have reparse points, since these represent
-    // such things as mounted folders, links, etc, and were therefore not
-    // created by a previous run of this installer.
-    if ((find_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) &&
-        !(find_data.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT)) {
+    // Chrome never creates files/directories with reparse points (i.e., mounted
+    // folders, links, etc), so never try to delete them.
+    if (find_data.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT)
+      continue;
+
+    if (find_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
       // Use the short name if available to make the most of our buffer.
       const wchar_t* name = find_data.cAlternateFileName[0]
                                 ? find_data.cAlternateFileName