[Mesa-dev] [PATCH 1/2] mesa: add blob overrun check to program binary reads

Timothy Arceri tarceri at itsqueeze.com
Fri Jan 26 00:56:49 UTC 2018


---
 src/mesa/main/program_binary.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/src/mesa/main/program_binary.c b/src/mesa/main/program_binary.c
index 2786487362..68a15ec258 100644
--- a/src/mesa/main/program_binary.c
+++ b/src/mesa/main/program_binary.c
@@ -287,5 +287,19 @@ _mesa_program_binary(struct gl_context *ctx, struct gl_shader_program *sh_prog,
       return;
    }
 
+   if (blob.current != blob.end || blob.overrun) {
+      /* Something has gone wrong ignore the binary and set link status to
+       * failure.
+       */
+      assert(!"Invalid program binary cache item!");
+
+      if (ctx->_Shader->Flags & GLSL_CACHE_INFO) {
+         fprintf(stderr, "Error reading program from program binary\n");
+      }
+      sh_prog->data->LinkStatus = linking_failure;
+
+      return;
+   }
+
    sh_prog->data->LinkStatus = linking_success;
 }
-- 
2.14.3



More information about the mesa-dev mailing list