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

Po-Hsien Wang pwang at chromium.org
Sat Jul 21 00:04:15 UTC 2018


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



More information about the virglrenderer-devel mailing list