From fe34b072d6b67d546a0ea910032f9b91ae8fc473 Mon Sep 17 00:00:00 2001 From: gavanderhoorn Date: Fri, 16 Jun 2023 18:12:33 +0200 Subject: [PATCH] inform_gen: pass correct remaining length to strncat(..) Improved version based on CodeQL documentation. --- src/InformCheckerAndGenerator.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/InformCheckerAndGenerator.c b/src/InformCheckerAndGenerator.c index 7bb1e24c..71547263 100644 --- a/src/InformCheckerAndGenerator.c +++ b/src/InformCheckerAndGenerator.c @@ -73,7 +73,8 @@ void Ros_InformChecker_CreateJob() if (group->baseTrackGroupId != -1) //this robot has a base { sprintf(tagBuffer, ",BS%d", (group->baseTrackGroupId - MP_B1_GID) + 1); - strncat(lineBuffer, tagBuffer, MAX_JOB_LINE_LENGTH); + strncat(lineBuffer, tagBuffer, + sizeof(lineBuffer) - Ros_strnlen(lineBuffer, MAX_JOB_LINE_LENGTH) - 1); } FileUtilityFunctions_WriteLine(fd, lineBuffer);