From: Tomas Weinfurt Date: Fri, 17 Apr 2020 04:50:14 +0000 (-0700) Subject: fix endless loop in GetActiveUdpListeners (#35078) X-Git-Tag: submit/tizen/20210909.063632~8537 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c9f16253f555994a473e4183909db12f6e96e61a;p=platform%2Fupstream%2Fdotnet%2Fruntime.git fix endless loop in GetActiveUdpListeners (#35078) --- diff --git a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/SystemIPGlobalProperties.cs b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/SystemIPGlobalProperties.cs index f792c6d..feda11d 100644 --- a/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/SystemIPGlobalProperties.cs +++ b/src/libraries/System.Net.NetworkInformation/src/System/Net/NetworkInformation/SystemIPGlobalProperties.cs @@ -229,7 +229,8 @@ namespace System.Net.NetworkInformation while (result == Interop.IpHlpApi.ERROR_INSUFFICIENT_BUFFER) { // Allocate the buffer and get the UDP table. - IntPtr buffer = IntPtr.Zero; + IntPtr buffer = Marshal.AllocHGlobal((int)size); + try { result = Interop.IpHlpApi.GetUdpTable(buffer, ref size, true); diff --git a/src/libraries/System.Net.NetworkInformation/tests/FunctionalTests/IPGlobalPropertiesTest.cs b/src/libraries/System.Net.NetworkInformation/tests/FunctionalTests/IPGlobalPropertiesTest.cs index 0b30f86..0989462 100644 --- a/src/libraries/System.Net.NetworkInformation/tests/FunctionalTests/IPGlobalPropertiesTest.cs +++ b/src/libraries/System.Net.NetworkInformation/tests/FunctionalTests/IPGlobalPropertiesTest.cs @@ -28,7 +28,6 @@ namespace System.Net.NetworkInformation.Tests } [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotWindowsSubsystemForLinux))] // [ActiveIssue("https://github.com/dotnet/runtime/issues/18258")] - [PlatformSpecific(TestPlatforms.AnyUnix)] public void IPGlobalProperties_AccessAllMethods_NoErrors() { IPGlobalProperties gp = IPGlobalProperties.GetIPGlobalProperties(); @@ -54,7 +53,6 @@ namespace System.Net.NetworkInformation.Tests [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotWindowsSubsystemForLinux))] // [ActiveIssue("https://github.com/dotnet/runtime/issues/18258")] [MemberData(nameof(Loopbacks))] - [PlatformSpecific(TestPlatforms.AnyUnix)] public void IPGlobalProperties_TcpListeners_Succeed(IPAddress address) { using (var server = new Socket(address.AddressFamily, SocketType.Stream, ProtocolType.Tcp)) @@ -80,7 +78,6 @@ namespace System.Net.NetworkInformation.Tests [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotWindowsSubsystemForLinux))] // [ActiveIssue("https://github.com/dotnet/runtime/issues/18258")] [MemberData(nameof(Loopbacks))] - [PlatformSpecific(TestPlatforms.AnyUnix)] public async Task IPGlobalProperties_TcpActiveConnections_Succeed(IPAddress address) { using (var server = new Socket(address.AddressFamily, SocketType.Stream, ProtocolType.Tcp)) @@ -110,7 +107,6 @@ namespace System.Net.NetworkInformation.Tests } [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotWindowsSubsystemForLinux))] // [ActiveIssue("https://github.com/dotnet/runtime/issues/18258")] - [PlatformSpecific(TestPlatforms.AnyUnix)] public void IPGlobalProperties_TcpActiveConnections_NotListening() { TcpConnectionInformation[] tcpCconnections = IPGlobalProperties.GetIPGlobalProperties().GetActiveTcpConnections();