Mesa (master): egl: don' t allow eglGetConfigs to set num_configs param to a negative value

Emil Velikov evelikov at kemper.freedesktop.org
Thu Aug 13 16:32:03 UTC 2015


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

Author: Frank Binns <frank.binns at imgtec.com>
Date:   Wed Aug 12 16:35:59 2015 +0100

egl: don't allow eglGetConfigs to set num_configs param to a negative value

When a buffer is provided to eglGetConfigs it's supposed to set the value
of the num_config parameter to the total number of configs that have been
copied into this buffer. For some reason the EGL spec doesn't consider it
to be an error to pass this function a buffer while specifying its size to
be less than 0. Given this, one would expect this combination to result in
the num_config parameter being set to 0 but this wasn't the case. This was
due to the buffer size being copied straight into num_configs without being
clamped to 0.

This was causing the following dEQP EGL test to fail:
dEQP-EGL.functional.query_config.get_configs.get_configs_bounds

Signed-off-by: Frank Binns <frank.binns at imgtec.com>
Reviewed-by: Matt Turner <mattst88 at gmail.com>
Reviewed-by: Emil Velikov <emil.l.velikov at gmail.com>

---

 src/egl/main/eglarray.c |    3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/egl/main/eglarray.c b/src/egl/main/eglarray.c
index 3ccc8a6..d2f39af 100644
--- a/src/egl/main/eglarray.c
+++ b/src/egl/main/eglarray.c
@@ -197,6 +197,9 @@ _eglFlattenArray(_EGLArray *array, void *buffer, EGLint elem_size, EGLint size,
 
    count = array->Size;
    if (buffer) {
+      /* clamp size to 0 */
+      if (size < 0)
+         size = 0;
       /* do not exceed buffer size */
       if (count > size)
          count = size;




More information about the mesa-commit mailing list