summaryrefslogtreecommitdiffstats
path: root/src/egl
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2018-08-28 16:43:57 -0500
committerJason Ekstrand <[email protected]>2018-08-30 11:41:50 -0500
commit8c1b9882b2e0cde0b1ad9c6844fd5939d3bd4b24 (patch)
tree287cae3beeb32cb6535ac72f903f02d6b40a352d /src/egl
parentb95896f4923af820f78be6556c4cd5f4ed087f21 (diff)
egl/dri2: Guard against invalid fourcc formats
We already reject attempts to import images with invalid fourcc formats but don't really guard the queries all that well. This makes us error out in any calls to eglQueryDmaBufModifiersEXT if the given format is not a valid fourcc format. We also add an assert to ensure that drivers don't advertise any non-fourcc formats. Cc: [email protected] Tested-By: Eero Tamminen <[email protected]> Reviewed-by: Eric Engestrom <[email protected]>
Diffstat (limited to 'src/egl')
-rw-r--r--src/egl/drivers/dri2/egl_dri2.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index daf535178ce..c5fa935657e 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -2382,6 +2382,18 @@ dri2_query_dma_buf_formats(_EGLDriver *drv, _EGLDisplay *disp,
formats, count))
return EGL_FALSE;
+ if (max > 0) {
+ /* Assert that all of the formats returned are actually fourcc formats.
+ * Some day, if we want the internal interface function to be able to
+ * return the fake fourcc formats defined in dri_interface.h, we'll have
+ * to do something more clever here to pair the list down to just real
+ * fourcc formats so that we don't leak the fake internal ones.
+ */
+ for (int i = 0; i < *count; i++) {
+ assert(dri2_num_fourcc_format_planes(formats[i]) > 0);
+ }
+ }
+
return EGL_TRUE;
}
@@ -2392,6 +2404,9 @@ dri2_query_dma_buf_modifiers(_EGLDriver *drv, _EGLDisplay *disp, EGLint format,
{
struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
+ if (dri2_num_fourcc_format_planes(format) == 0)
+ return _eglError(EGL_BAD_PARAMETER, "invalid fourcc format");
+
if (max < 0)
return _eglError(EGL_BAD_PARAMETER, "invalid value for max count of formats");