renderer: check for shader_text validity

Submitted by Po-Hsien Wang on Aug. 2, 2018, 8:32 p.m.

Details

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

Not browsing as part of any series.

Commit Message

Po-Hsien Wang Aug. 2, 2018, 8:32 p.m.
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(+)

Patch hide | download patch | download mbox

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)