Skip to content

Commit

Permalink
improve symlink handling in Ping (#79323)
Browse files Browse the repository at this point in the history
* improve symlink handling in Ping

* update comment

* feedback from review
  • Loading branch information
wfurt authored Dec 10, 2022
1 parent d0a1ad2 commit 6407eae
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,8 @@ private static bool IsBusyboxPing(string? pingBinary)
{
if (pingBinary != null)
{
string? linkedName = Interop.Sys.ReadLink(pingBinary);

// If pingBinary is not link linkedName will be null
if (linkedName != null && linkedName.EndsWith("busybox", StringComparison.Ordinal))
System.IO.FileSystemInfo? linkInfo = File.ResolveLinkTarget(pingBinary, returnFinalTarget: true);
if (linkInfo?.Name.EndsWith("busybox", StringComparison.Ordinal) == true)
{
return true;
}
Expand Down
2 changes: 0 additions & 2 deletions src/libraries/System.Net.Ping/src/System.Net.Ping.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@
Link="Common\Interop\Unix\Interop.Libraries.cs" />
<Compile Include="$(CommonPath)Interop\Unix\System.Native\Interop.Close.cs"
Link="Common\Interop\Unix\System.Native\Interop.Close.cs" />
<Compile Include="$(CommonPath)Interop\Unix\System.Native\Interop.ReadLink.cs"
Link="Common\Interop\Unix\System.Native\Interop.ReadLink.cs" />
<Compile Include="$(CommonPath)Interop\Unix\System.Native\Interop.Socket.cs"
Link="Common\Interop\Unix\System.Native\Interop.Socket.cs" />
<Compile Include="$(CommonPath)Interop\Unix\System.Native\Interop.SocketAddress.cs"
Expand Down

0 comments on commit 6407eae

Please sign in to comment.