From: José Fonseca Date: Sun, 11 Dec 2011 12:33:55 +0000 (+0000) Subject: Simple buffer overflow detection on glGet*. X-Git-Url: https://git.cworth.org/git?a=commitdiff_plain;h=f7dd5a0dba6061d2f2cea87fbc9f0c90d35e7765;p=apitrace Simple buffer overflow detection on glGet*. --- diff --git a/glstate.py b/glstate.py index 30d749c..9497b7a 100644 --- a/glstate.py +++ b/glstate.py @@ -154,9 +154,12 @@ class StateGetter(Visitor): elem_type = self.inflector.reduced_type(array.type) inflection = self.inflector.inflect(array.type) assert inflection.endswith('v') - print ' %s %s[%s];' % (elem_type, temp_name, array.length) + print ' %s %s[%s + 1];' % (elem_type, temp_name, array.length) print ' memset(%s, 0, %s * sizeof *%s);' % (temp_name, array.length, temp_name) + print ' %s[%s] = (%s)0xdeadc0de;' % (temp_name, array.length, elem_type) print ' %s(%s, %s);' % (inflection + self.suffix, ', '.join(args), temp_name) + # Simple buffer overflow detection + print ' assert(%s[%s] == (%s)0xdeadc0de);' % (temp_name, array.length, elem_type) return temp_name def visit_opaque(self, pointer, args):