From fb437de4f822c7a1135b2c4a6aa964721c0ae500 Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Sat, 17 Feb 2024 02:04:32 -0300 Subject: fix(build): add some validation to the build table LuaRocks does not validate the contents of the build table because each backend defines it on this own. These validations should be enough to address #1477, but ideally each bundled `build` backend should have its own validator like the one on `luarocks.type.rockspec`. Fixes #1477. --- src/luarocks/build/builtin.lua | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src') diff --git a/src/luarocks/build/builtin.lua b/src/luarocks/build/builtin.lua index cd4d4486..33e19c6b 100644 --- a/src/luarocks/build/builtin.lua +++ b/src/luarocks/build/builtin.lua @@ -321,7 +321,13 @@ function builtin.run(rockspec, no_install) local sources = info.sources if info[1] then sources = info end if type(sources) == "string" then sources = {sources} end + if type(sources) ~= "table" then + return nil, "error in rockspec: module '" .. name .. "' entry has no 'sources' list" + end for _, source in ipairs(sources) do + if type(source) ~= "string" then + return nil, "error in rockspec: module '" .. name .. "' does not specify source correctly." + end local object = source:gsub("%.[^.]*$", "."..cfg.obj_extension) if not object then object = source.."."..cfg.obj_extension -- cgit v1.2.3-55-g6feb