[Mesa-dev] [PATCH 14/20] mesa/es: Validate glGetMaterial pname in Mesa code rather than the ES wrapper

Ian Romanick idr at freedesktop.org
Fri Aug 24 08:46:58 PDT 2012


From: Ian Romanick <ian.d.romanick at intel.com>

Fixes a bug that glGetMaterial[fx]v in ES1 contexts would (try to) allow
queries of GL_AMBIENT_AND_DIFFUSE.  This enum can only be used in glMaterial,
not in the get.

Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
---
 src/mesa/main/APIspec.xml      |   20 --------------------
 src/mesa/main/es1_conversion.c |    1 -
 src/mesa/main/light.c          |    6 ++++++
 3 files changed, 6 insertions(+), 21 deletions(-)

diff --git a/src/mesa/main/APIspec.xml b/src/mesa/main/APIspec.xml
index 6d6462c..e7777a7 100644
--- a/src/mesa/main/APIspec.xml
+++ b/src/mesa/main/APIspec.xml
@@ -612,26 +612,6 @@
 			<param name="param" type="GLtype"/>
 		</vector>
 	</proto>
-
-	<desc name="face">
-		<value name="GL_FRONT"/>
-		<value name="GL_BACK"/>
-	</desc>
-
-	<desc name="pname">
-		<value name="GL_SHININESS"/>
-		<desc name="params" vector_size="1"/>
-	</desc>
-
-	<desc name="pname">
-		<value name="GL_AMBIENT"/>
-		<value name="GL_DIFFUSE"/>
-		<value name="GL_AMBIENT_AND_DIFFUSE"/>
-		<value name="GL_SPECULAR"/>
-		<value name="GL_EMISSION"/>
-
-		<desc name="params" vector_size="4"/>
-	</desc>
 </template>
 
 <template name="GetString" direction="get">
diff --git a/src/mesa/main/es1_conversion.c b/src/mesa/main/es1_conversion.c
index c1d7b83..c1bcfbe 100644
--- a/src/mesa/main/es1_conversion.c
+++ b/src/mesa/main/es1_conversion.c
@@ -293,7 +293,6 @@ _es_GetMaterialxv(GLenum face, GLenum pname, GLfixed *params)
       break;
    case GL_AMBIENT:
    case GL_DIFFUSE:
-   case GL_AMBIENT_AND_DIFFUSE:
    case GL_SPECULAR:
    case GL_EMISSION:
       n_params = 4;
diff --git a/src/mesa/main/light.c b/src/mesa/main/light.c
index d6fbcd9..a603935 100644
--- a/src/mesa/main/light.c
+++ b/src/mesa/main/light.c
@@ -789,6 +789,10 @@ _mesa_GetMaterialfv( GLenum face, GLenum pname, GLfloat *params )
 	 *params = mat[MAT_ATTRIB_SHININESS(f)][0];
 	 break;
       case GL_COLOR_INDEXES:
+         if (ctx->API != API_OPENGL) {
+            _mesa_error( ctx, GL_INVALID_ENUM, "glGetMaterialfv(pname)" );
+            return;
+         }
 	 params[0] = mat[MAT_ATTRIB_INDEXES(f)][0];
 	 params[1] = mat[MAT_ATTRIB_INDEXES(f)][1];
 	 params[2] = mat[MAT_ATTRIB_INDEXES(f)][2];
@@ -807,6 +811,8 @@ _mesa_GetMaterialiv( GLenum face, GLenum pname, GLint *params )
    GLfloat (*mat)[4] = ctx->Light.Material.Attrib;
    ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); /* update materials */
 
+   ASSERT(ctx->API == API_OPENGL);
+
    FLUSH_CURRENT(ctx, 0); /* update ctx->Light.Material from vertex buffer */
 
    if (face==GL_FRONT) {
-- 
1.7.6.5



More information about the mesa-dev mailing list