mesa: Avoid out-of-bounds stack read via _mesa_Materiali
authorNicolai Hähnle <nicolai.haehnle@amd.com>
Wed, 22 Feb 2017 17:06:46 +0000 (18:06 +0100)
committerNicolai Hähnle <nicolai.haehnle@amd.com>
Wed, 22 Mar 2017 11:12:11 +0000 (12:12 +0100)
MATERIALFV may end up reading up to 4 floats from the passed parameter.

This should really set a GL_INVALID_ENUM error in the cases where it
matters, but does anybody really care?

Found by ASAN in piglit gl-1.0-beginend-coverage.

v2: fix a trivial compiler warning

Reviewed-by: Marek Olšák <marek.olsak@amd.com> (v1)
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com> (v1)
src/mesa/main/api_loopback.c

index 8b63d9c0e95e83ff0d0a9a8b0e304a275cd95403..59b59d3a9ecc64cf0cd515ca65615c6c2d828357 100644 (file)
@@ -865,8 +865,9 @@ _mesa_Materialf( GLenum face, GLenum pname, GLfloat param )
 void GLAPIENTRY
 _mesa_Materiali(GLenum face, GLenum pname, GLint param )
 {
-   GLfloat p = (GLfloat) param;
-   MATERIALFV(face, pname, &p);
+   GLfloat p[4];
+   p[0] = (GLfloat) param;
+   MATERIALFV(face, pname, p);
 }
 
 void GLAPIENTRY