From 554e4fc26a64a90012b0d7dcc1205441273f214c Mon Sep 17 00:00:00 2001 From: Kristian Høgsberg Date: Fri, 14 May 2010 12:07:38 -0400 Subject: egl: Only allow valid config attributes in _eglParseConfigAttribList() Passing 0x3030, 0 in the chooser list didn't get caught. --- src/egl/main/eglconfig.c | 52 ++++++++++++++++++++++-------------------------- 1 file changed, 24 insertions(+), 28 deletions(-) (limited to 'src/egl/main/eglconfig.c') diff --git a/src/egl/main/eglconfig.c b/src/egl/main/eglconfig.c index 47513a4edb..a659d19c37 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. */ -- cgit v1.2.3