Fix creative mode inventory search crash

Before this patch it was possible for any user to to crash Minetest in
creative mode. This was possible because queries in the search field
were interpreted as search patterns for string.find().

A search for a single square bracket would reliably crash the server.
Also, a search for 6000 times the string “a?” would hang the server.

The solution to both bugs is to not interpret the query as a pattern.
This commit is contained in:
Nils Dagsson Moskopp 2022-01-21 23:27:03 +01:00
parent 23f1c51912
commit f975055464
Signed by untrusted user who does not match committer: erle
GPG Key ID: A3BC671C35191080
1 changed files with 1 additions and 1 deletions

View File

@ -117,7 +117,7 @@ local function filter_item(name, description, lang, filter)
else
desc = string.lower(minetest.get_translated_string(lang, description))
end
return string.find(name, filter) or string.find(desc, filter)
return string.find(name, filter, nil, true) or string.find(desc, filter, nil, true)
end
local function set_inv_search(filter, player)