From: lzhan011 <[email protected]>

for_each_shdr_str() evaluates strlen(str) before checking str < end, so
after the last string of the section it calls strlen() on the bytes just
past the section. Check the bound first.

Fixes: e30f8e61e251 ("tracing: Add a tracepoint verification check at build 
time")
Assisted-by: Claude:claude-opus-5-5 ASan
Signed-off-by: lzhan011 <[email protected]>
---
 scripts/tracepoint-update.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/tracepoint-update.c b/scripts/tracepoint-update.c
index 4c4b66901..ad5f691c1 100644
--- a/scripts/tracepoint-update.c
+++ b/scripts/tracepoint-update.c
@@ -74,7 +74,7 @@ static int add_string(const char *str, const char ***vals, 
int *count)
 #define for_each_shdr_str(len, ehdr, sec)                              \
        for (const char *str = (void *)(ehdr) + shdr_offset(sec),       \
                        *end = str + shdr_size(sec);                    \
-            len = strlen(str), str < end;                              \
+            str < end && (len = strlen(str), true);                    \
             str += (len) + 1)
 
 
-- 
2.34.1


Reply via email to