gallium/tgsi: fix oob access in parse instruction
authorLi Qiang <liq3ea@gmail.com>
Mon, 23 Jan 2017 07:44:03 +0000 (02:44 -0500)
committerDave Airlie <airlied@redhat.com>
Tue, 7 Feb 2017 04:00:04 +0000 (14:00 +1000)
When parsing texture instruction, it doesn't stop if the
'cur' is ',', the loop variable 'i' will also be increased
and be used to index the 'inst.TexOffsets' array. This can lead
an oob access issue. This patch avoid this.

Reviewed-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Li Qiang <liq3ea@gmail.com>
src/gallium/auxiliary/tgsi/tgsi_text.c

index 308e6b52627988eef6b6cab5e775fa07e131a3e7..4ed905036f18791eebe037f29ddcb9847392ff79 100644 (file)
@@ -1163,7 +1163,7 @@ parse_instruction(
 
    cur = ctx->cur;
    eat_opt_white( &cur );
-   for (i = 0; inst.Instruction.Texture && *cur == ','; i++) {
+   for (i = 0; inst.Instruction.Texture && *cur == ',' && i < TGSI_FULL_MAX_TEX_OFFSETS; i++) {
          cur++;
          eat_opt_white( &cur );
          ctx->cur = cur;