|
| 1 | +--[=[ |
| 2 | +SPDX-License-Identifier: ISC |
| 3 | +Copyright (c) 2023-2025, Sergey Bronnikov. |
| 4 | +
|
| 5 | +6.6 – Table Manipulation |
| 6 | +https://www.lua.org/manual/5.1/manual.html#5.5 |
| 7 | +
|
| 8 | +Infinite loop on table lookup, |
| 9 | +https://github.com/LuaJIT/LuaJIT/issues/494 |
| 10 | +
|
| 11 | +Synopsis: table.concat(list [, sep [, i [, j]]]) |
| 12 | +--]=] |
| 13 | + |
| 14 | +local luzer = require("luzer") |
| 15 | +local test_lib = require("lib") |
| 16 | + |
| 17 | +local function TestOneInput(buf, _size) |
| 18 | + local fdp = luzer.FuzzedDataProvider(buf) |
| 19 | + local str = fdp:consume_string(test_lib.MAX_STR_LEN) |
| 20 | + local tbl_size = #str |
| 21 | + -- io.stderr:write(tbl_size .. "\n") |
| 22 | + if tbl_size <= 1 then |
| 23 | + return -1 |
| 24 | + end |
| 25 | + local tbl = {} |
| 26 | + str:gsub(".", function(c) |
| 27 | + table.insert(tbl, c) |
| 28 | + end) |
| 29 | + assert(#tbl, tbl_size) |
| 30 | + -- local j = fdp:consume_integer(1, tbl_size) |
| 31 | + -- local i = fdp:consume_integer(1, j) |
| 32 | + -- local sep = "" |
| 33 | + -- io.stderr:write(string.gsub(str, i, j) .. table.concat(tbl, sep, i, j) .. "\n") |
| 34 | + -- assert(string.gsub(str, i, j) == table.concat(tbl, sep, i, j)) |
| 35 | +end |
| 36 | + |
| 37 | +local args = { |
| 38 | + artifact_prefix = "table_concat_", |
| 39 | +} |
| 40 | +luzer.Fuzz(TestOneInput, nil, args) |
0 commit comments