vrend_renderer: Check the shader terminator

Before calling tgsi_text_translate, check the last 4 bytes of
shader contains the terminating character.

TEST=WebGLAquarium

[airlied: unfortunately some mesa userspace sends a packet
with 0 shader in it, this should be illegal but we can't
go trapping it now. just include the check for termination]

Reviewed-by: Dave Airlie <airlied@redhat.com>
macos/master
Po-Hsien Wang 6 years ago committed by Dave Airlie
parent 76670ade68
commit a5bfadaab5
  1. 7
      src/vrend_renderer.c

@ -3024,6 +3024,13 @@ int vrend_create_shader(struct vrend_context *ctx,
if (finished) { if (finished) {
struct tgsi_token *tokens; struct tgsi_token *tokens;
/* check for null termination */
int last_chunk_offset = sel->buf_offset ? sel->buf_offset : pkt_length * 4;
if (!memchr(shd_text + last_chunk_offset - 4, '\0', 4)) {
ret = EINVAL;
goto error;
}
tokens = calloc(num_tokens + 10, sizeof(struct tgsi_token)); tokens = calloc(num_tokens + 10, sizeof(struct tgsi_token));
if (!tokens) { if (!tokens) {
ret = ENOMEM; ret = ENOMEM;

Loading…
Cancel
Save