Mesa (master): mesa: properly report the length of truncated log messages

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Mar 14 19:58:40 UTC 2019


Module: Mesa
Branch: master
Commit: eb1a869a5d19bfd8a0d4099afd58f180997e4663
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=eb1a869a5d19bfd8a0d4099afd58f180997e4663

Author: Mark Janes <mark.a.janes at intel.com>
Date:   Thu Dec  6 16:35:42 2018 -0800

mesa: properly report the length of truncated log messages

_mesa_log_msg must provide the length of the string passed into the
KHR_debug api.  When the string formatted by _mesa_gl_vdebugf exceeds
MAX_DEBUG_MESSAGE_LENGTH, the length is incorrectly set to the number
of characters that would have been written if enough space had been
available.

Fixes: 30256805784450b8bb9d4dabfb56226271ca9d24
       ("mesa: Add support for GL_ARB_debug_output with dynamic ID allocation.")

Reviewed-by: Erik Faye-Lund <erik.faye-lund at collabora.com>

---

 src/mesa/main/errors.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/mesa/main/errors.c b/src/mesa/main/errors.c
index a9687913627..30560ba047e 100644
--- a/src/mesa/main/errors.c
+++ b/src/mesa/main/errors.c
@@ -231,6 +231,9 @@ _mesa_gl_vdebug(struct gl_context *ctx,
    _mesa_debug_get_id(id);
 
    len = _mesa_vsnprintf(s, MAX_DEBUG_MESSAGE_LENGTH, fmtString, args);
+   if (len >= MAX_DEBUG_MESSAGE_LENGTH)
+      /* message was truncated */
+      len = MAX_DEBUG_MESSAGE_LENGTH - 1;
 
    _mesa_log_msg(ctx, source, type, *id, severity, len, s);
 }




More information about the mesa-commit mailing list