diff --git a/src/vrend_decode.c b/src/vrend_decode.c index 11fe149..7013cd5 100644 --- a/src/vrend_decode.c +++ b/src/vrend_decode.c @@ -73,7 +73,7 @@ static int vrend_decode_create_shader(struct vrend_decode_ctx *ctx, uint8_t *shd_text; uint32_t type; - if (length < 5) + if (length < VIRGL_OBJ_SHADER_HDR_SIZE(0)) return EINVAL; type = get_buf_entry(ctx, VIRGL_OBJ_SHADER_TYPE); @@ -81,6 +81,8 @@ static int vrend_decode_create_shader(struct vrend_decode_ctx *ctx, offlen = get_buf_entry(ctx, VIRGL_OBJ_SHADER_OFFSET); num_so_outputs = get_buf_entry(ctx, VIRGL_OBJ_SHADER_SO_NUM_OUTPUTS); + if (length < VIRGL_OBJ_SHADER_HDR_SIZE(num_so_outputs)) + return EINVAL; if (num_so_outputs > PIPE_MAX_SO_OUTPUTS) return EINVAL;