From 8a0491a9d4874daa47319b28719537b8fbe6a261 Mon Sep 17 00:00:00 2001 From: Tomoya Fujita Date: Wed, 28 Jul 2021 22:10:40 -0700 Subject: [PATCH] rcl_yaml_param_parser should not accept a relative name in a parameter file. Signed-off-by: Tomoya Fujita --- rcl_yaml_param_parser/src/parse.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/rcl_yaml_param_parser/src/parse.c b/rcl_yaml_param_parser/src/parse.c index acce68a92..f4c402c44 100644 --- a/rcl_yaml_param_parser/src/parse.c +++ b/rcl_yaml_param_parser/src/parse.c @@ -494,11 +494,7 @@ _validate_name(const char * name, rcutils_allocator_t allocator) char * node_name = NULL; char * absolute_namespace = NULL; if (NULL == separator_pos) { - node_name = rcutils_strdup(name, allocator); - if (NULL == node_name) { - ret = RCUTILS_RET_BAD_ALLOC; - goto clean; - } + return RCUTILS_RET_INVALID_ARGUMENT; } else { // substring namespace including the last '/' char * namespace_ = rcutils_strndup(name, ((size_t) (separator_pos - name)) + 1, allocator); @@ -507,12 +503,8 @@ _validate_name(const char * name, rcutils_allocator_t allocator) goto clean; } if (namespace_[0] != '/') { - absolute_namespace = rcutils_format_string(allocator, "/%s", namespace_); - allocator.deallocate(namespace_, allocator.state); - if (NULL == absolute_namespace) { - ret = RCUTILS_RET_BAD_ALLOC; - goto clean; - } + ret = RCUTILS_RET_INVALID_ARGUMENT; + goto clean; } else { absolute_namespace = namespace_; }