Skip to content

Commit

Permalink
Fix crash during junk scan on some corrupted/malformed uninstaller da…
Browse files Browse the repository at this point in the history
…ta in registry
  • Loading branch information
Klocman committed Mar 4, 2023
1 parent b9f06b5 commit beee03a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
8 changes: 2 additions & 6 deletions source/UninstallTools/Junk/Finders/Registry/ComScanner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,8 @@ public override IEnumerable<IJunkResult> FindJunk(ApplicationUninstallerEntry ta
if (string.IsNullOrEmpty(target.InstallLocation))
yield break;

try
{
if (UninstallToolsGlobalConfig.IsSystemDirectory(target.InstallLocation))
yield break;
}
catch (ArgumentException ex) { Trace.WriteLine(ex); }
if (UninstallToolsGlobalConfig.IsSystemDirectory(target.InstallLocation))
yield break;

foreach (var comEntry in _comEntries.Where(x => PathTools.SubPathIsInsideBasePath(target.InstallLocation, x.FullFilename, true)))
{
Expand Down
19 changes: 18 additions & 1 deletion source/UninstallTools/UninstallToolsGlobalConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,24 @@ public static bool IsSystemDirectory(DirectoryInfo dir)
/// </summary>
public static bool IsSystemDirectory(string installLocation)
{
return IsSystemDirectory(new DirectoryInfo(installLocation));
if (string.IsNullOrEmpty(installLocation)) return false;

try
{
return IsSystemDirectory(new DirectoryInfo(installLocation));
}
catch (ArgumentException ex)
{
Trace.WriteLine(ex);
// Treat this as a no-touch directory just to be safe
return true;
}
catch (IOException ex)
{
Trace.WriteLine(ex);
// Treat this as a no-touch directory just to be safe
return true;
}
}

/// <summary>
Expand Down

0 comments on commit beee03a

Please sign in to comment.