virgl: disallow null-terminated debug messages
authorRyan Neph <ryanneph@google.com>
Fri, 23 Jul 2021 17:27:03 +0000 (10:27 -0700)
committerRyan Neph <ryanneph@google.com>
Fri, 23 Jul 2021 18:04:19 +0000 (11:04 -0700)
virglrenderer doesn't support null-terminated message strings, so
there's no reason for the guest to allow it.

Signed-off-by: Ryan Neph <ryanneph@google.com>
Reviewed-by: Chia-I Wu <olvaffe@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12043>

src/gallium/drivers/virgl/virgl_encode.c

index 41b471e..01e5637 100644 (file)
@@ -1536,7 +1536,9 @@ void virgl_encode_get_memory_info(struct virgl_context *ctx, struct virgl_resour
 void virgl_encode_emit_string_marker(struct virgl_context *ctx,
                                      const char *message, int len)
 {
-    if (!len)
+   /* len is guaranteed to be non-negative but be defensive */
+   assert(len >= 0);
+   if (len <= 0)
       return;
 
    if (len > 4 * 0xffff) {