From ff36f0f35a60e4fa38581eb6f24cac17f65cc71b Mon Sep 17 00:00:00 2001 From: thefiddler Date: Wed, 22 Jan 2014 10:35:08 +0100 Subject: [PATCH] [OpenTK] Clamp max AA level to 64x This protects against a potential denial-of-service issue during mode selection, where the platform backend will try to reduce AA level until a supported mode is found. --- Source/OpenTK/Graphics/GraphicsMode.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Source/OpenTK/Graphics/GraphicsMode.cs b/Source/OpenTK/Graphics/GraphicsMode.cs index 1068f833..aad7fae2 100644 --- a/Source/OpenTK/Graphics/GraphicsMode.cs +++ b/Source/OpenTK/Graphics/GraphicsMode.cs @@ -254,7 +254,14 @@ namespace OpenTK.Graphics { return samples; } - private set { samples = value; } + private set + { + // Clamp antialiasing samples to max 64x + // This protects against a potential DOS during + // mode selection, when the user requests an + // abnormally high AA level. + samples = MathHelper.Clamp(value, 0, 64); + } } #endregion