} else if (!strcmp((const char *) probe_attribute_node->name,
config_element_symbol_name)) {
xmlChar *content;
- size_t name_len;
/* symbol_name */
content = xmlNodeGetContent(probe_attribute_node);
goto end;
}
- name_len = strlen((char *) content);
- if (name_len >= LTTNG_SYMBOL_NAME_LEN) {
- WARN("symbol_name too long.");
+ ret = lttng_strncpy(attr->symbol_name,
+ (const char *) content,
+ LTTNG_SYMBOL_NAME_LEN);
+ if (ret == -1) {
+ ERR("symbol name \"%s\"'s length (%zu) exceeds the maximal permitted length (%d) in session configuration",
+ (const char *) content,
+ strlen((const char *) content),
+ LTTNG_SYMBOL_NAME_LEN);
ret = -LTTNG_ERR_LOAD_INVALID_CONFIG;
free(content);
goto end;
}
-
- strncpy(attr->symbol_name, (const char *) content, name_len);
free(content);
}
ret = 0;
node = xmlNextElementSibling(node)) {
if (!strcmp((const char *) node->name, config_element_name)) {
xmlChar *content;
- size_t name_len;
/* name */
content = xmlNodeGetContent(node);
goto end;
}
- name_len = strlen((char *) content);
- if (name_len >= LTTNG_SYMBOL_NAME_LEN) {
- WARN("Channel name too long.");
+ ret = lttng_strncpy(event.name,
+ (const char *) content,
+ LTTNG_SYMBOL_NAME_LEN);
+ if (ret == -1) {
+ WARN("Event \"%s\"'s name length (%zu) exceeds the maximal permitted length (%d) in session configuration",
+ (const char *) content,
+ strlen((const char *) content),
+ LTTNG_SYMBOL_NAME_LEN);
ret = -LTTNG_ERR_LOAD_INVALID_CONFIG;
free(content);
goto end;
}
-
- strncpy(event.name, (const char *) content, name_len);
free(content);
} else if (!strcmp((const char *) node->name,
config_element_enabled)) {
goto end;
}
- strncpy(event.attr.ftrace.symbol_name, (char *) content,
- sym_len);
+ ret = lttng_strncpy(
+ event.attr.ftrace.symbol_name,
+ (char *) content, sym_len);
+ if (ret == -1) {
+ ret = -LTTNG_ERR_LOAD_INVALID_CONFIG;
+ free(content);
+ goto end;
+ }
free(content);
}
}
goto end;
}
}
+ ret = 0;
end:
for (i = 0; i < exclusion_count; i++) {
free(exclusions[i]);
if (!strcmp((const char *) attr_node->name, config_element_name)) {
xmlChar *content;
- size_t name_len;
/* name */
content = xmlNodeGetContent(attr_node);
goto end;
}
- name_len = strlen((char *) content);
- if (name_len >= LTTNG_SYMBOL_NAME_LEN) {
- WARN("Channel name too long.");
+ ret = lttng_strncpy(channel->name,
+ (const char *) content,
+ LTTNG_SYMBOL_NAME_LEN);
+ if (ret == -1) {
+ WARN("Channel \"%s\"'s name length (%zu) exceeds the maximal permitted length (%d) in session configuration",
+ (const char *) content,
+ strlen((const char *) content),
+ LTTNG_SYMBOL_NAME_LEN);
ret = -LTTNG_ERR_LOAD_INVALID_CONFIG;
free(content);
goto end;
}
-
- strncpy(channel->name, (const char *) content, name_len);
free(content);
} else if (!strcmp((const char *) attr_node->name,
config_element_enabled)) {
} else if (!strcmp((const char *) perf_attr_node->name,
config_element_name)) {
xmlChar *content;
- size_t name_len;
/* name */
content = xmlNodeGetContent(perf_attr_node);
goto end;
}
- name_len = strlen((char *) content);
- if (name_len >= LTTNG_SYMBOL_NAME_LEN) {
- WARN("perf context name too long.");
+ ret = lttng_strncpy(context.u.perf_counter.name,
+ (const char *) content,
+ LTTNG_SYMBOL_NAME_LEN);
+ if (ret == -1) {
+ WARN("Perf counter \"%s\"'s name length (%zu) exceeds the maximal permitted length (%d) in session configuration",
+ (const char *) content,
+ strlen((const char *) content),
+ LTTNG_SYMBOL_NAME_LEN);
ret = -LTTNG_ERR_LOAD_INVALID_CONFIG;
free(content);
goto end;
}
-
- strncpy(context.u.perf_counter.name, (const char *) content,
- name_len);
free(content);
}
}