From 4545a2eed188cf050fa024c64e371d1eac234298 Mon Sep 17 00:00:00 2001 From: Benedikt Conze Date: Fri, 19 Dec 2025 08:59:42 +0100 Subject: [PATCH] Ensure topic/type name char arrays have enough space for trailing null character --- src/entities/Domain.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/entities/Domain.cpp b/src/entities/Domain.cpp index feeb4bf..da4e499 100644 --- a/src/entities/Domain.cpp +++ b/src/entities/Domain.cpp @@ -350,8 +350,8 @@ rtps::Writer *Domain::createWriter(Participant &part, const char *topicName, // TODO Distinguish WithKey and NoKey (Also changes EntityKind) TopicData attributes; - if (strlen(topicName) > Config::MAX_TOPICNAME_LENGTH || - strlen(typeName) > Config::MAX_TYPENAME_LENGTH) { + if (strlen(topicName) + 1 > Config::MAX_TOPICNAME_LENGTH || // + \0 + strlen(typeName) + 1 > Config::MAX_TYPENAME_LENGTH) { return nullptr; } strcpy(attributes.topicName, topicName); @@ -410,8 +410,8 @@ rtps::Reader *Domain::createReader(Participant &part, const char *topicName, // TODO Distinguish WithKey and NoKey (Also changes EntityKind) TopicData attributes; - if (strlen(topicName) > Config::MAX_TOPICNAME_LENGTH || - strlen(typeName) > Config::MAX_TYPENAME_LENGTH) { + if (strlen(topicName) + 1 > Config::MAX_TOPICNAME_LENGTH || // + \0 + strlen(typeName) + 1 > Config::MAX_TYPENAME_LENGTH) { return nullptr; } strcpy(attributes.topicName, topicName);