nuageinit: Add guards against empty user data
Add guards against attempting to process a user data file with an empty first line or contents. PR: 290395 Reviewed by: bapt (earlier), dtxdf, markj MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D53239
This commit is contained in:
@@ -663,8 +663,16 @@ if not f then
|
||||
os.exit(0)
|
||||
end
|
||||
local line = f:read("*l")
|
||||
if not line or #string.gsub(line, "^%s*(.-)%s*$", "%1") == 0 then
|
||||
f:close()
|
||||
os.exit(0)
|
||||
end
|
||||
if citype ~= "postnet" then
|
||||
local content = f:read("*a")
|
||||
if not content or #string.gsub(content, "^%s*(.-)%s*$", "%1") == 0 then
|
||||
f:close()
|
||||
os.exit(0)
|
||||
end
|
||||
nuage.mkdir_p(root .. "/var/cache/nuageinit")
|
||||
local tof = assert(io.open(root .. "/var/cache/nuageinit/user_data", "w"))
|
||||
tof:write(line .. "\n" .. content)
|
||||
|
||||
Reference in New Issue
Block a user