Skip to content

Commit

Permalink
M4X4 opcode can actually overflow some string buffers.
Browse files Browse the repository at this point in the history
  • Loading branch information
icculus committed Apr 13, 2012
1 parent 2218816 commit 7935c02
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions mojoshader.c
Expand Up @@ -1811,7 +1811,7 @@ static const char *make_GLSL_destarg_assign(Context *ctx, char *buf,
return buf;
} // if

char operation[128];
char operation[256];
va_list ap;
va_start(ap, fmt);
const int len = vsnprintf(operation, sizeof (operation), fmt, ap);
Expand Down Expand Up @@ -2830,7 +2830,7 @@ static void emit_GLSL_M4X4(Context *ctx)
char row1[64]; make_GLSL_srcarg_string_full(ctx, 2, row1, sizeof (row1));
char row2[64]; make_GLSL_srcarg_string_full(ctx, 3, row2, sizeof (row2));
char row3[64]; make_GLSL_srcarg_string_full(ctx, 4, row3, sizeof (row3));
char code[128];
char code[256];
make_GLSL_destarg_assign(ctx, code, sizeof (code),
"vec4(dot(%s, %s), dot(%s, %s), dot(%s, %s), dot(%s, %s))",
src0, row0, src0, row1, src0, row2, src0, row3);
Expand All @@ -2843,7 +2843,7 @@ static void emit_GLSL_M4X3(Context *ctx)
char row0[64]; make_GLSL_srcarg_string_full(ctx, 1, row0, sizeof (row0));
char row1[64]; make_GLSL_srcarg_string_full(ctx, 2, row1, sizeof (row1));
char row2[64]; make_GLSL_srcarg_string_full(ctx, 3, row2, sizeof (row2));
char code[128];
char code[256];
make_GLSL_destarg_assign(ctx, code, sizeof (code),
"vec3(dot(%s, %s), dot(%s, %s), dot(%s, %s))",
src0, row0, src0, row1, src0, row2);
Expand All @@ -2858,7 +2858,7 @@ static void emit_GLSL_M3X4(Context *ctx)
char row2[64]; make_GLSL_srcarg_string_vec3(ctx, 3, row2, sizeof (row2));
char row3[64]; make_GLSL_srcarg_string_vec3(ctx, 4, row3, sizeof (row3));

char code[128];
char code[256];
make_GLSL_destarg_assign(ctx, code, sizeof (code),
"vec4(dot(%s, %s), dot(%s, %s), "
"dot(%s, %s), dot(%s, %s))",
Expand All @@ -2873,7 +2873,7 @@ static void emit_GLSL_M3X3(Context *ctx)
char row0[64]; make_GLSL_srcarg_string_vec3(ctx, 1, row0, sizeof (row0));
char row1[64]; make_GLSL_srcarg_string_vec3(ctx, 2, row1, sizeof (row1));
char row2[64]; make_GLSL_srcarg_string_vec3(ctx, 3, row2, sizeof (row2));
char code[128];
char code[256];
make_GLSL_destarg_assign(ctx, code, sizeof (code),
"vec3(dot(%s, %s), dot(%s, %s), dot(%s, %s))",
src0, row0, src0, row1, src0, row2);
Expand All @@ -2886,7 +2886,7 @@ static void emit_GLSL_M3X2(Context *ctx)
char row0[64]; make_GLSL_srcarg_string_vec3(ctx, 1, row0, sizeof (row0));
char row1[64]; make_GLSL_srcarg_string_vec3(ctx, 2, row1, sizeof (row1));

char code[128];
char code[256];
make_GLSL_destarg_assign(ctx, code, sizeof (code),
"vec2(dot(%s, %s), dot(%s, %s))",
src0, row0, src0, row1);
Expand Down
2 changes: 1 addition & 1 deletion mojoshader_common.c
Expand Up @@ -760,7 +760,7 @@ int buffer_append_fmt(Buffer *buffer, const char *fmt, ...)

int buffer_append_va(Buffer *buffer, const char *fmt, va_list va)
{
char scratch[128];
char scratch[256];

va_list ap;
va_copy(ap, va);
Expand Down

0 comments on commit 7935c02

Please sign in to comment.