Skip to content

Commit e50e42e

Browse files
paulbissfacebook-github-bot
authored andcommitted
Remove support for keys containing * in HDF
Summary: The neo parser allows config names such as "foo*bar" and "*foobar*" where each "*" is replaced with a monotonically increasing process global counter value. In practice this syntax is only used for appending values to a vector type, e.g. `MyVectorConfig.* = value`. Let's ban the more expressive uses of this configuration. Reviewed By: ricklavoie Differential Revision: D39525827 fbshipit-source-id: 6e612a863c2d81f071c86fb18f31009333915215
1 parent 1cb5b39 commit e50e42e

File tree

1 file changed

+24
-14
lines changed

1 file changed

+24
-14
lines changed

hphp/neo/neo_hdf.c

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1318,24 +1318,34 @@ static NEOERR* _hdf_read_string (HDF *hdf, const char **str, NEOSTRING *line,
13181318
{
13191319
/* Valid hdf name is [0-9a-zA-Z_.*\]+ */
13201320
int splice = *s == '@';
1321-
if (splice) s++;
1322-
name = s;
1323-
while (*s && (isalnum(*s) || *s == '_' || *s == '.' || *s == '*' || *s == '\\')) s++;
1324-
SKIPWS(s);
1325-
13261321
char num[256];
13271322
static int counter = 0;
1328-
char *p;
1329-
int i = 0;
1330-
for (p = name; p < s && i < 200; p++) {
1331-
if (*p != '*') {
1332-
num[i++] = *p;
1333-
} else {
1334-
i += snprintf(num + i, 256 - i, "%d", counter++);
1335-
name = num;
1323+
if (splice) s++;
1324+
name = s;
1325+
if (*s == '*') {
1326+
if (*s++ && (isalnum(*s) || *s == '_' || *s == '.' || *s == '\\')) {
1327+
return nerr_raise(NERR_PARSE, "Illegal name containing '*'");
1328+
}
1329+
snprintf(num, 256, "%d", counter++);
1330+
name = num;
1331+
} else {
1332+
int saw_star = 0;
1333+
while (*s && (isalnum(*s) || *s == '_' || *s == '.' || *s == '\\')) {
1334+
if (saw_star || (*s++ != '.' && *s == '*')) {
1335+
return nerr_raise(NERR_PARSE, "Illegal name containing '*'");
1336+
} else if (*s == '*') {
1337+
if (splice) {
1338+
return nerr_raise(NERR_PARSE,
1339+
"Illegal splice name containing '*'");
1340+
}
1341+
*s++ = '\0';
1342+
snprintf(num, 256, "%s%i", name, counter++);
1343+
name = num;
1344+
saw_star = 1;
1345+
}
13361346
}
13371347
}
1338-
num[i] = '\0';
1348+
SKIPWS(s);
13391349

13401350
if (s[0] == '[') /* attributes */
13411351
{

0 commit comments

Comments
 (0)