Mesa (mesa_7_4_branch): mesa: Fix buffer overflow when parsing generic vertex attributes.

Brian Paul brianp at kemper.freedesktop.org
Tue Apr 28 16:58:23 UTC 2009


Module: Mesa
Branch: mesa_7_4_branch
Commit: 656cd707db3699079d3a1b886d82e6f04afb1065
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=656cd707db3699079d3a1b886d82e6f04afb1065

Author: Brian Paul <brianp at vmware.com>
Date:   Tue Apr 28 10:57:45 2009 -0600

mesa: Fix buffer overflow when parsing generic vertex attributes.

(cherry picked from master, commit fa92756400ccfbb3f0201df634feb45ab4f98352)

---

 src/mesa/shader/arbprogparse.c |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/mesa/shader/arbprogparse.c b/src/mesa/shader/arbprogparse.c
index 810a7b8..0984d88 100644
--- a/src/mesa/shader/arbprogparse.c
+++ b/src/mesa/shader/arbprogparse.c
@@ -1496,10 +1496,16 @@ generic_attrib_check(struct var_cache *vc_head)
    curr = vc_head;
    while (curr) {
       if (curr->type == vt_attrib) {
-         if (curr->attrib_is_generic)
-            genericAttrib[ curr->attrib_binding ] = GL_TRUE;
-         else
+         if (curr->attrib_is_generic) {
+            GLuint attr = (curr->attrib_binding == 0)
+               ? 0 : (curr->attrib_binding - VERT_ATTRIB_GENERIC0);
+            assert(attr < MAX_VERTEX_PROGRAM_ATTRIBS);
+            genericAttrib[attr] = GL_TRUE;
+         }
+         else {
+            assert(curr->attrib_binding < MAX_VERTEX_PROGRAM_ATTRIBS);
             explicitAttrib[ curr->attrib_binding ] = GL_TRUE;
+         }
       }
 
       curr = curr->next;




More information about the mesa-commit mailing list