/bin/less and /bin/more were able to lock up the system if they call string.gsub(string, function) on a very large string (~144k chars long).
The machine layer intercepts expensive strings calls by checking the length of the string, but it does not intercept gsub calls when the replace action is a function

The fix is to intercept all long string actions, not just non-function replacement gsub calls

Note that /bin/more is now more efficient and doesn't call string.gsub, but this is still the right fix to keep the sandbox from being able to lock up the system with string methods
This commit is contained in:
payonel 2017-09-16 08:40:48 +02:00
parent 47c67a119f
commit 2abd8b3134

View File

@ -577,7 +577,7 @@ do
checkArg(3, repl, "number", "string", "function", "table")
checkArg(4, n, "number", "nil")
if #s < SHORT_STRING or type(repl) == "function" then
if #s < SHORT_STRING then
return string_gsub(s, pattern, repl, n)
end