[OpenTK] Clamp max AA level to 64x
authorthefiddler <stapostol@gmail.com>
Wed, 22 Jan 2014 09:35:08 +0000 (10:35 +0100)
committerthefiddler <stapostol@gmail.com>
Wed, 22 Jan 2014 09:35:08 +0000 (10:35 +0100)
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

index 1068f83..aad7fae 100644 (file)
@@ -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