Skip to content

Commit 802fbe7

Browse files
Buristanligurio
authored andcommitted
tests/capi: fix possible timeout in result chunks
This patch fixes the Lua inputs in `luaL_loadbuffer_fuzzer` that generate the infinite cycles or recursive function calls, like the following: ``` if counter_0 > 5 then break end counter_0 = counter_0 + 1 and (0.000000 ); ``` The `and` here is generated by the `NameToString()` function, which doesn't check that the name shouldn't be reserved. This patch adds the corresponding check and separates the counter increment with `;` to avoid any ambiguous syntax. Follows up the commit 82ec1cc ("tests: fix errors "'<name>' expected near 'and'""). Backported tarantool/tarantool@5836426
1 parent dece9f2 commit 802fbe7

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

tests/capi/luaL_loadbuffer_proto/serializer.cc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ GetCounterIncrement(const std::string &counter_name)
230230
std::string retval = counter_name;
231231
retval += " = ";
232232
retval += counter_name;
233-
retval += " + 1\n";
233+
retval += " + 1;\n";
234234
return retval;
235235
}
236236

@@ -1209,6 +1209,10 @@ PROTO_TOSTRING(UnaryOperator, op)
12091209
PROTO_TOSTRING(Name, name)
12101210
{
12111211
std::string ident = ConvertToStringDefault(name.name(), true);
1212+
/* Prevent using reserved keywords as identifiers. */
1213+
if (KReservedLuaKeywords.find(ident) != KReservedLuaKeywords.end()) {
1214+
ident += "_1";
1215+
}
12121216
/* Identifier has default name, add an index. */
12131217
if (!ident.compare(kDefaultIdent)) {
12141218
ident += std::to_string(name.num() % kMaxIdentifiers);

0 commit comments

Comments
 (0)