From: Tobias Ulmer Date: Fri, 11 Apr 2014 16:44:12 +0000 (+0200) Subject: Don't crash when "file" in source config is not of the expected type X-Git-Tag: e2factory-2.3.15rc1~211 X-Git-Url: https://git.e2factory.org/?a=commitdiff_plain;h=5a2877167a8ad331d3dc7fe1537b4bf4eb7e0403;p=e2factory.git Don't crash when "file" in source config is not of the expected type Signed-off-by: Tobias Ulmer --- diff --git a/plugins/files.lua b/plugins/files.lua index 41a748e..478be66 100644 --- a/plugins/files.lua +++ b/plugins/files.lua @@ -59,59 +59,59 @@ function files.validate_source(info, sourcename) e = err.new("in source %s:", sourcename) e:setcount(0) local src = info.sources[ sourcename ] - if not src.file then - e:append("%s: source has no `file' attribute", sourcename) + if type(src.file) ~= "table" then + return false, e:cat(err.new("source has no valid `file' attribute")) end - if src.file then - for _,f in pairs(src.file) do - if type(f) ~= "table" then - e:append("%s: source has invalid file entry in `file' attribute", - sourcename) - break - end - -- catch deprecated configuration - if f.name then - e:append("source has file entry with `name' attribute") - end - if (not f.licences) and src.licences then - f.licences = src.licences - end - if (not f.server) and src.server then - f.server = src.server - end - if not f.licences then - e:append("source has file entry without `licences' attribute") - end - for _,l in ipairs(f.licences) do - if not licence.licences[l] then - e:append("invalid licence assigned to file: %s", l) - end - end - if not f.server then - e:append("source has file entry without `server' attribute") - end - if f.server and (not cache.valid_server(info.cache, f.server)) then - e:append("invalid server: %s", f.server) - end - if not f.location then - e:append("source has file entry without `location' attribute") - end - if f.server ~= info.root_server_name and not f.sha1 then - e:append("source has file entry for remote file without `sha1` ".. - "attribute") - end - if not (f.unpack or f.copy or f.patch) then - e:append("source has file entry without `unpack, copy or patch' " .. - "attribute") - end - if f.checksum_file then - e2lib.warnf("WDEPRECATED", "in source %s:", sourcename) - e2lib.warnf("WDEPRECATED", - " checksum_file attribute is deprecated and no longer used") - f.checksum_file = nil + + for _,f in pairs(src.file) do + if type(f) ~= "table" then + e:append("%s: source has invalid file entry in `file' attribute", + sourcename) + break + end + -- catch deprecated configuration + if f.name then + e:append("source has file entry with `name' attribute") + end + if (not f.licences) and src.licences then + f.licences = src.licences + end + if (not f.server) and src.server then + f.server = src.server + end + if not f.licences then + e:append("source has file entry without `licences' attribute") + end + for _,l in ipairs(f.licences) do + if not licence.licences[l] then + e:append("invalid licence assigned to file: %s", l) end end + if not f.server then + e:append("source has file entry without `server' attribute") + end + if f.server and (not cache.valid_server(info.cache, f.server)) then + e:append("invalid server: %s", f.server) + end + if not f.location then + e:append("source has file entry without `location' attribute") + end + if f.server ~= info.root_server_name and not f.sha1 then + e:append("source has file entry for remote file without `sha1` ".. + "attribute") + end + if not (f.unpack or f.copy or f.patch) then + e:append("source has file entry without `unpack, copy or patch' " .. + "attribute") + end + if f.checksum_file then + e2lib.warnf("WDEPRECATED", "in source %s:", sourcename) + e2lib.warnf("WDEPRECATED", + " checksum_file attribute is deprecated and no longer used") + f.checksum_file = nil + end end + if e:getcount() > 0 then return false, e end