[Mesa-dev] Truncated extensions string

Kenneth Graunke kenneth at whitecape.org
Sat Mar 12 01:22:36 PST 2011

On Friday, March 11, 2011 01:23:12 PM Patrick Baggett wrote:
> I feel like there is some kind of underlying lesson that we, OpenGL app
> programmers, should be getting out of this...

Yes.  Don't blindly copy abitrary amounts of data into a fixed size buffer. :)  
I hate to be trite, but that -is- the entire problem: a classic buffer overflow, 
the kind we warn people about in early programming courses.  As Ian pointed 
out, it's absolutely trivial to do this correctly: if you're going to copy it, 
just malloc a buffer that's the correct size.

In particular, glGetString says nothing about the length of the returned 
string, so you can't safely assume that it will fit in -any- fixed size buffer.
> What about a psuedo-database of app -> extension list rather than by year?
> Surely Quake3 doesn't make use of but <= 10 extensions. I'd imagine the
> same holds true for other old games as well. A simple "strings" on their
> binary could figure that out...

Brian is right here.  We already have two very simple solutions...let's stick 
with one of those.

More information about the mesa-dev mailing list