The branch main has been updated by jlduran:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=57d25b6333523491ac7a3e869bd5d16127203eed

commit 57d25b6333523491ac7a3e869bd5d16127203eed
Author:     Jose Luis Duran <[email protected]>
AuthorDate: 2025-10-21 13:11:50 +0000
Commit:     Jose Luis Duran <[email protected]>
CommitDate: 2025-11-22 17:23:20 +0000

    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
---
 libexec/nuageinit/nuageinit | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/libexec/nuageinit/nuageinit b/libexec/nuageinit/nuageinit
index 0270da5c515b..a5411c60b410 100755
--- a/libexec/nuageinit/nuageinit
+++ b/libexec/nuageinit/nuageinit
@@ -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)

Reply via email to