[virglrenderer-devel] [PATCH] renderer: check for shader_text validity

Dave Airlie airlied at gmail.com
Mon Jul 23 22:41:43 UTC 2018


This doesn't look like it even compiles, and the logic seems wrong,
should we also check for garbage after termination? we would expect a
single string of the correct length with one terminating character.

Dave.

On 21 July 2018 at 10:04, Po-Hsien Wang <pwang at chromium.org> wrote:
> Add a check for nonterminated string passed into the create_shader
> code.
> ---
>  src/vrend_renderer.c | 11 +++++++++++
>  1 file changed, 11 insertions(+)
>
> diff --git a/src/vrend_renderer.c b/src/vrend_renderer.c
> index 69f1da3..666af45 100644
> --- a/src/vrend_renderer.c
> +++ b/src/vrend_renderer.c
> @@ -2491,6 +2491,14 @@ static int vrend_finish_shader(struct vrend_context *ctx,
>     return 0;
>  }
>
> +static inline bool is_valid_text(const char *text, uint32_t length)
> +{
> +   for (uint32_t i = 0; i<length; i++)
> +      if (!text[i])
> +         return true;
> +   return false;
> +}
> +
>  int vrend_create_shader(struct vrend_context *ctx,
>                          uint32_t handle,
>                          const struct pipe_stream_output_info *so_info,
> @@ -2503,6 +2511,9 @@ int vrend_create_shader(struct vrend_context *ctx,
>     bool finished = false;
>     int ret;
>
> +   if (!valid_text(shd_text, pkt_length))
> +      return EINVAL;
> +
>     if (type > PIPE_SHADER_TESS_EVAL)
>        return EINVAL;
>
> --
> 2.18.0.233.g985f88cf7e-goog
>
> _______________________________________________
> virglrenderer-devel mailing list
> virglrenderer-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/virglrenderer-devel


More information about the virglrenderer-devel mailing list