From b8bd3c7c8bded595b683440e0a8cb230b36e406a Mon Sep 17 00:00:00 2001 From: Derek Foreman Date: Tue, 5 May 2026 16:50:55 -0500 Subject: [PATCH] trace: Add a max size for the key Not sure we'll ever hit this, but since we're concatenating strings into a static sized buffer I suppose it's useful to ensure it won't have an unreadable result. Signed-off-by: Derek Foreman --- libweston/weston-trace.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libweston/weston-trace.h b/libweston/weston-trace.h index cf416f2df..db0b72512 100644 --- a/libweston/weston-trace.h +++ b/libweston/weston-trace.h @@ -33,6 +33,9 @@ /* maximum allowed debug annotations */ #define WESTON_MAX_DEBUG_ANNOTS 128 +/* maximum key length */ +#define WESTON_TRACE_MAX_KEY_LENGTH 30 + /* note that util_perfetto_is_tracing_enabled always returns false until * util_perfetto_init is called */ @@ -80,6 +83,7 @@ #define _WESTON_TRACE_DO_ANNOTATE_ADD(k, v) \ if (unlikely(util_perfetto_is_tracing_enabled())) { \ + static_assert(sizeof(k) < WESTON_TRACE_MAX_KEY_LENGTH); \ __pd_i += _Generic((v), \ int: perfetto_annotate_int, \ unsigned int: perfetto_annotate_int, \