Mesa (gallium-0.2): Perform range checking on app supplied texture base level

Alan Hourihane alanh at kemper.freedesktop.org
Mon Dec 15 11:17:00 UTC 2008


Module: Mesa
Branch: gallium-0.2
Commit: 1126aa86bf9ca223218695eec1f41c6523068961
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=1126aa86bf9ca223218695eec1f41c6523068961

Author: Ian Romanick <ian.d.romanick at intel.com>
Date:   Sun Dec 14 18:42:11 2008 -0800

Perform range checking on app supplied texture base level

It is possible for applications to specify any texture base level,
including trivially invalid values (i.e., 47000000).  When an app
specifies an invalide base level, we should gracefully disable the
texture instead of accessing memory outside the gl_texture_object.

This fixes an occasional segfault in one of our conformance tests.

---

 src/mesa/main/texobj.c |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c
index 2a54ff7..d8e8b55 100644
--- a/src/mesa/main/texobj.c
+++ b/src/mesa/main/texobj.c
@@ -383,6 +383,18 @@ _mesa_test_texobj_completeness( const GLcontext *ctx,
 
    t->_Complete = GL_TRUE;  /* be optimistic */
 
+   /* Detect cases where the application set the base level to an invalid
+    * value.
+    */
+   if ((baseLevel < 0) || (baseLevel > MAX_TEXTURE_LEVELS)) {
+      char s[100];
+      _mesa_sprintf(s, "obj %p (%d) base level = %d is invalid",
+              (void *) t, t->Name, baseLevel);
+      incomplete(t, s);
+      t->_Complete = GL_FALSE;
+      return;
+   }
+
    /* Always need the base level image */
    if (!t->Image[0][baseLevel]) {
       char s[100];




More information about the mesa-commit mailing list