[Mesa-dev] [PATCH mesa 2/5] egl: take new string into account when checking for overflow

Eric Engestrom eric at engestrom.ch
Wed Mar 1 23:31:51 UTC 2017


Otherwise the check would detect that the previous append() resulted in
a buffer overflow, which would not even be caught if the last extension
in the string is the one that goes over (which is likely).

Signed-off-by: Eric Engestrom <eric at engestrom.ch>
---
 src/egl/main/eglapi.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c
index d964b4d289..220e53be8c 100644
--- a/src/egl/main/eglapi.c
+++ b/src/egl/main/eglapi.c
@@ -470,7 +470,8 @@ _eglCreateExtensionsString(_EGLDisplay *dpy)
 #define _EGL_CHECK_EXTENSION(ext)                                          \
    do {                                                                    \
       if (dpy->Extensions.ext) {                                           \
-         assert(exts <= dpy->ExtensionsString + _EGL_MAX_EXTENSIONS_LEN);  \
+         assert(exts + strlen("EGL_" #ext) <=                              \
+                dpy->ExtensionsString + _EGL_MAX_EXTENSIONS_LEN);          \
          _eglAppendExtension(&exts, "EGL_" #ext);                          \
       }                                                                    \
    } while (0)
-- 
Cheers,
  Eric



More information about the mesa-dev mailing list