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

Po-Hsien Wang pwang at chromium.org
Thu Aug 2 20:32:08 UTC 2018


Add a check for nonterminated string passed into the create_shader
code.

TEST=compile and running with specific testcases.
---
 src/vrend_renderer.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/vrend_renderer.c b/src/vrend_renderer.c
index 0d7b5b8..e71483c 100644
--- a/src/vrend_renderer.c
+++ b/src/vrend_renderer.c
@@ -2914,6 +2914,8 @@ int vrend_create_shader(struct vrend_context *ctx,
 
    if (type > PIPE_SHADER_COMPUTE)
       return EINVAL;
+   if (pkt_length <= 0 || shd_text[pkt_length - 1] != '\0')
+      return EINVAL;
 
    if (!has_feature(feat_geometry_shader) &&
        type == PIPE_SHADER_GEOMETRY)
-- 
2.18.0.597.ga71716f1ad-goog



More information about the virglrenderer-devel mailing list