diff --git a/ldms/src/core/ldms.c b/ldms/src/core/ldms.c index c8611c7cd..5bb53262d 100644 --- a/ldms/src/core/ldms.c +++ b/ldms/src/core/ldms.c @@ -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++; } diff --git a/ldms/src/core/ldms.h b/ldms/src/core/ldms.h index fab1f3d57..41dc0295e 100644 --- a/ldms/src/core/ldms.h +++ b/ldms/src/core/ldms.h @@ -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