renderer: check for shader_text validity

Submitted by Po-Hsien Wang on July 26, 2018, 2:43 a.m.

Details

Message ID 20180726024348.129373-1-pwang@chromium.org
State New
Headers show
Series "renderer: check for shader_text validity" ( rev: 2 ) in Virgil 3D

Not browsing as part of any series.

Commit Message

Po-Hsien Wang July 26, 2018, 2:43 a.m.
Add a check for nonterminated string passed into the create_shader
code.
---
 src/vrend_renderer.c | 3 +++
 1 file changed, 3 insertions(+)

Patch hide | download patch | download mbox

diff --git a/src/vrend_renderer.c b/src/vrend_renderer.c
index da24f04..610e796 100644
--- a/src/vrend_renderer.c
+++ b/src/vrend_renderer.c
@@ -2675,6 +2675,9 @@  int vrend_create_shader(struct vrend_context *ctx,
    bool finished = false;
    int ret;
 
+   if (length <= 0 || shd_text[length - 1] != '\0')
+      return EINVAL;
+
    if (type > PIPE_SHADER_TESS_EVAL)
       return EINVAL;
 

Comments

ping. Thanks.

On Wed, Jul 25, 2018 at 7:43 PM Po-Hsien Wang <pwang@chromium.org> wrote:

> Add a check for nonterminated string passed into the create_shader
> code.
> ---
>  src/vrend_renderer.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/src/vrend_renderer.c b/src/vrend_renderer.c
> index da24f04..610e796 100644
> --- a/src/vrend_renderer.c
> +++ b/src/vrend_renderer.c
> @@ -2675,6 +2675,9 @@ int vrend_create_shader(struct vrend_context *ctx,
>     bool finished = false;
>     int ret;
>
> +   if (length <= 0 || shd_text[length - 1] != '\0')
> +      return EINVAL;
> +
>     if (type > PIPE_SHADER_TESS_EVAL)
>        return EINVAL;
>
> --
> 2.18.0.345.g5c9ce644c3-goog
>
>