summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2011-03-24 11:39:21 -0600
committerBrian Paul <[email protected]>2011-03-24 11:39:23 -0600
commit82dd62fb22c8f88d62e3c77666c6805a2ac6ecd3 (patch)
treed1aed1089b9ffb2173719e6f5ac155d630116c10 /src
parent4c75d5ae63c356ac9b6d23009ccc9af6205dbb4a (diff)
mesa: new MESA_EXTENSION_MAX_YEAR env var
If set to year X, only report extensions up to that year. This is a work-around for games that try to copy the extensions string to a fixed size buffer and overflow. If a game was released in year X, setting MESA_EXTENSION_MAX_YEAR to that year will likely fix the problem.
Diffstat (limited to 'src')
-rw-r--r--src/mesa/main/extensions.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c
index 4b6e91c4f31..728c73c10ae 100644
--- a/src/mesa/main/extensions.c
+++ b/src/mesa/main/extensions.c
@@ -875,12 +875,24 @@ _mesa_make_extension_string(struct gl_context *ctx)
GLboolean *base = (GLboolean *) &ctx->Extensions;
const struct extension *i;
unsigned j;
-
+ unsigned maxYear = ~0;
+
+ /* Check if the MESA_EXTENSION_MAX_YEAR env var is set */
+ {
+ const char *env = getenv("MESA_EXTENSION_MAX_YEAR");
+ if (env) {
+ maxYear = atoi(env);
+ _mesa_debug(ctx, "Note: limiting GL extensions to %u or earlier\n",
+ maxYear);
+ }
+ }
/* Compute length of the extension string. */
count = 0;
for (i = extension_table; i->name != 0; ++i) {
- if (base[i->offset] && (i->api_set & (1 << ctx->API))) {
+ if (base[i->offset] &&
+ i->year <= maxYear &&
+ (i->api_set & (1 << ctx->API))) {
length += strlen(i->name) + 1; /* +1 for space */
++count;
}
@@ -908,7 +920,9 @@ _mesa_make_extension_string(struct gl_context *ctx)
*/
j = 0;
for (i = extension_table; i->name != 0; ++i) {
- if (base[i->offset] && (i->api_set & (1 << ctx->API))) {
+ if (base[i->offset] &&
+ i->year <= maxYear &&
+ (i->api_set & (1 << ctx->API))) {
extension_indices[j++] = i - extension_table;
}
}