From b59a787b9ea05fd662f70730af4ca98dc3dac9ce Mon Sep 17 00:00:00 2001 From: apio Date: Thu, 18 Apr 2024 21:55:16 +0200 Subject: [PATCH] kernel: Properly initialize the shebang read buffer with zeros Before this patch, a shebang line that was too long could have left the buffer without a null terminator, allowing some other stack contents to pass into the m_interpreter_cmdline. --- kernel/src/binfmt/Script.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kernel/src/binfmt/Script.cpp b/kernel/src/binfmt/Script.cpp index fe56af83..acf5f6c2 100644 --- a/kernel/src/binfmt/Script.cpp +++ b/kernel/src/binfmt/Script.cpp @@ -16,6 +16,8 @@ Result ScriptLoader::sniff() Result ScriptLoader::load(AddressSpace* space) { u8 buf[256]; + memset(buf, 0, sizeof(buf)); + usize nread = TRY(m_inode->read(buf, 2, 255)); if (!nread) return err(ENOEXEC); for (usize i = 0; i < nread; i++)