Mesa (master): glx: Reject glXSwapIntervalMESA greater than INT_MAX

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Sep 10 19:06:00 UTC 2020


Module: Mesa
Branch: master
Commit: b8239abdf86f251d75567381d0d59976f9d91efd
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=b8239abdf86f251d75567381d0d59976f9d91efd

Author: Adam Jackson <ajax at redhat.com>
Date:   Wed Sep  9 15:54:21 2020 -0400

glx: Reject glXSwapIntervalMESA greater than INT_MAX

It wouldn't work in any case, as the internal API only stores a signed
int, and GLX_EXT_swap_control_tear will overload the meaning of negative
values so we should avoid ambiguity.

If your application needs a swap interval in excess of ~414.25 days, I'm
very sorry.

Reviewed-by: Michel Dänzer <mdaenzer at redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6671>

---

 src/glx/glxcmds.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/glx/glxcmds.c b/src/glx/glxcmds.c
index 60b1e86d206..fb840eb6b7f 100644
--- a/src/glx/glxcmds.c
+++ b/src/glx/glxcmds.c
@@ -51,7 +51,7 @@
 #endif /* GLX_USE_WINDOWSGL */
 #endif
 #endif
-
+#include <limits.h>
 #include <X11/Xlib-xcb.h>
 #include <xcb/xcb.h>
 #include <xcb/glx.h>
@@ -1796,6 +1796,9 @@ glXSwapIntervalMESA(unsigned int interval)
 #ifdef GLX_DIRECT_RENDERING
    struct glx_context *gc = __glXGetCurrentContext();
 
+   if (interval > INT_MAX)
+      return GLX_BAD_VALUE;
+
    if (gc != &dummyContext && gc->isDirect) {
       struct glx_screen *psc;
 



More information about the mesa-commit mailing list