From: Kristian Høgsberg Date: Fri, 14 May 2010 16:07:38 +0000 (-0400) Subject: egl: Only allow valid config attributes in _eglParseConfigAttribList() X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=554e4fc26a64a90012b0d7dcc1205441273f214c;p=mesa.git egl: Only allow valid config attributes in _eglParseConfigAttribList() Passing 0x3030, 0 in the chooser list didn't get caught. --- diff --git a/src/egl/main/eglconfig.c b/src/egl/main/eglconfig.c index 47513a4edb2..a659d19c373 100644 --- a/src/egl/main/eglconfig.c +++ b/src/egl/main/eglconfig.c @@ -478,6 +478,26 @@ _eglMatchConfig(const _EGLConfig *conf, const _EGLConfig *criteria) return matched; } +static INLINE EGLBoolean +_eglIsConfigAttribValid(_EGLConfig *conf, EGLint attr) +{ + if (_eglIndexConfig(conf, attr) < 0) + return EGL_FALSE; + + /* there are some holes in the range */ + switch (attr) { + case 0x3030 /* a gap before EGL_SAMPLES */: + case EGL_NONE: +#ifdef EGL_VERSION_1_4 + case EGL_MATCH_NATIVE_PIXMAP: +#endif + return EGL_FALSE; + default: + break; + } + + return EGL_TRUE; +} /** * Initialize a criteria config from the given attribute list. @@ -500,15 +520,13 @@ _eglParseConfigAttribList(_EGLConfig *conf, const EGLint *attrib_list) /* parse the list */ for (i = 0; attrib_list && attrib_list[i] != EGL_NONE; i += 2) { - EGLint idx; - attr = attrib_list[i]; val = attrib_list[i + 1]; - idx = _eglIndexConfig(conf, attr); - if (idx < 0) - return EGL_FALSE; - conf->Storage[idx] = val; + if (!_eglIsConfigAttribValid(conf, attr)) + return EGL_FALSE; + + SET_CONFIG_ATTRIB(conf, attr, val); /* rememeber some attributes for post-processing */ switch (attr) { @@ -781,28 +799,6 @@ _eglChooseConfig(_EGLDriver *drv, _EGLDisplay *disp, const EGLint *attrib_list, } -static INLINE EGLBoolean -_eglIsConfigAttribValid(_EGLConfig *conf, EGLint attr) -{ - if (_eglIndexConfig(conf, attr) < 0) - return EGL_FALSE; - - /* there are some holes in the range */ - switch (attr) { - case 0x3030 /* a gap before EGL_SAMPLES */: - case EGL_NONE: -#ifdef EGL_VERSION_1_4 - case EGL_MATCH_NATIVE_PIXMAP: -#endif - return EGL_FALSE; - default: - break; - } - - return EGL_TRUE; -} - - /** * Fallback for eglGetConfigAttrib. */