fix(factory): skip symlinks/junctions during directory scan (fixes #690)#952
Open
chirag127 wants to merge 1 commit into
Open
fix(factory): skip symlinks/junctions during directory scan (fixes #690)#952chirag127 wants to merge 1 commit into
chirag127 wants to merge 1 commit into
Conversation
…aller#690) Symbolic links and directory junctions were being enumerated as if they were regular files/directories, producing duplicate uninstaller entries and, in the case of a symlink pointing back into the scan tree, risking unbounded recursion into the same content. Guard both: - The .exe file enumeration (both top-level and inside binary subdirs) with FileAttributes.ReparsePoint == 0. - The subdirectory loop with the same check as the first step so we don't recurse into linked directories. Fixes BCUninstaller#690.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Skip symbolic links and directory junctions when scanning
InstallLocationfor executables. Fixes #690.Problem
BCU currently enumerates
.exefiles and subdirectories withdirectory.GetFiles(...)/directory.GetDirectories()and treats each result as if it were regular content. If a symlink or junction points at another location, BCU:Report: #690.
Fix
In
AppExecutablesSearcher.ScanDirectory:.exematches with(f.Attributes & FileAttributes.ReparsePoint) == 0.exematches inside recognised binary subdirectories with the same checkFileAttributes.ReparsePointcovers symlinks (created withmklink/New-Item -ItemType SymbolicLink) and directory junctions (created withmklink /J).Changes
source/UninstallTools/Factory/InfoAdders/AppExecutablesSearcher.csNet 8 lines. No changes to behaviour for regular files/directories.
Test plan
InstallLocation:SortedExecutablesincludes.exefiles from the linked target and duplicates any dupesSortedExecutablesis unchanged as iflinked/did not existRelated