Skip to content

Commit

Permalink
Expand characters disallowed in set names
Browse files Browse the repository at this point in the history
  • Loading branch information
tom95858 committed Nov 1, 2024
1 parent 40ad055 commit f4ccf96
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
21 changes: 21 additions & 0 deletions ldms/src/core/ldms.c
Original file line number Diff line number Diff line change
Expand Up @@ -1579,18 +1579,39 @@ ldms_set_t ldms_set_create(const char *instance_name,
*/
const char *s = instance_name;
while (*s != '\0') {
/* Control characters are not allowed because they would confuse
* parsing of set names
*/
if (iscntrl(*s)) {
errno = EINVAL;
return NULL;
}
/* Double-quote not allowed in quoted string because we
* would have to add logic to handle "" vs. '' when encoding
* as JSON
*/
if (*s == '"') {
errno = EINVAL;
return NULL;
}
/* Single-quote not allowed in quoted string because we
* would have to add logic to handle "" vs. '' when encoding
* as JSON
*/
if (*s == '\'') {
errno = EINVAL;
return NULL;
}
/* Backslash would hide intended character in encoded string */
if (*s == '\\') {
errno = EINVAL;
return NULL;
}
/* Character values above 127 are not allowed */
if (0 != (*s & ~0x7f)) {
errno = EINVAL;
return NULL;
}
s++;
}

Expand Down
8 changes: 6 additions & 2 deletions ldms/src/core/ldms.h
Original file line number Diff line number Diff line change
Expand Up @@ -1618,9 +1618,13 @@ ldms_set_t ldms_set_new_with_auth(const char *instance_name,
uid_t uid, gid_t gid, mode_t perm);

/**
* \brief Create an LDMS metric set with owner, permission, and heap size
* \brief Create an LDMS metric set
*
* Create a metric set, but with customized \c uid, \c gid, \c perm, and \c heap_sz
* Create a metric set, with \c uid, \c gid, \c perm, and \c heap_sz
* The \c instance name must be unique among sets in the application and must only
* contain the characters [a-z], [A-Z], [0-9] and [:-+/%&]. Note that the characters
* +, -, / and * are allowed for compatability reasons, but their use is discouraged
* in new code because they can be confused with mathematical operators.
*
* \param instance_name The name of the metric set
* \param schema The schema of the set
Expand Down

0 comments on commit f4ccf96

Please sign in to comment.