From 58e6c5c837cd85598a5492f5e493833aee0a7e3f Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Thu, 24 Jan 2019 14:33:57 +0100 Subject: [PATCH] Fix argument checks in ThreadPool.RegisterWaitForSingleObject. --- .../shared/System/Threading/ThreadPool.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/System.Private.CoreLib/shared/System/Threading/ThreadPool.cs b/src/System.Private.CoreLib/shared/System/Threading/ThreadPool.cs index e0447c55994..ffcab54c5e8 100644 --- a/src/System.Private.CoreLib/shared/System/Threading/ThreadPool.cs +++ b/src/System.Private.CoreLib/shared/System/Threading/ThreadPool.cs @@ -49,7 +49,7 @@ internal static class ThreadPoolGlobals } [StructLayout(LayoutKind.Sequential)] // enforce layout so that padding reduces false sharing - internal sealed partial class ThreadPoolWorkQueue + internal sealed class ThreadPoolWorkQueue { internal static class WorkStealingQueueList { @@ -943,7 +943,7 @@ public static RegisteredWaitHandle RegisterWaitForSingleObject( ) { if (millisecondsTimeOutInterval > (uint)int.MaxValue && millisecondsTimeOutInterval != uint.MaxValue) - throw new ArgumentOutOfRangeException(nameof(millisecondsTimeOutInterval), SR.ArgumentOutOfRange_NeedNonNegOrNegative1); + throw new ArgumentOutOfRangeException(nameof(millisecondsTimeOutInterval), SR.ArgumentOutOfRange_LessEqualToIntegerMaxVal); return RegisterWaitForSingleObject(waitObject, callBack, state, millisecondsTimeOutInterval, executeOnlyOnce, true); } @@ -997,6 +997,8 @@ public static RegisteredWaitHandle RegisterWaitForSingleObject( { if (millisecondsTimeOutInterval < -1) throw new ArgumentOutOfRangeException(nameof(millisecondsTimeOutInterval), SR.ArgumentOutOfRange_NeedNonNegOrNegative1); + if (millisecondsTimeOutInterval > (uint)int.MaxValue) + throw new ArgumentOutOfRangeException(nameof(millisecondsTimeOutInterval), SR.ArgumentOutOfRange_LessEqualToIntegerMaxVal); return RegisterWaitForSingleObject(waitObject, callBack, state, (uint)millisecondsTimeOutInterval, executeOnlyOnce, true); } @@ -1010,6 +1012,8 @@ public static RegisteredWaitHandle UnsafeRegisterWaitForSingleObject( { if (millisecondsTimeOutInterval < -1) throw new ArgumentOutOfRangeException(nameof(millisecondsTimeOutInterval), SR.ArgumentOutOfRange_NeedNonNegOrNegative1); + if (millisecondsTimeOutInterval > (uint)int.MaxValue) + throw new ArgumentOutOfRangeException(nameof(millisecondsTimeOutInterval), SR.ArgumentOutOfRange_LessEqualToIntegerMaxVal); return RegisterWaitForSingleObject(waitObject, callBack, state, (uint)millisecondsTimeOutInterval, executeOnlyOnce, false); }