kernel: Properly initialize the shebang read buffer with zeros
Some checks failed
Build and test / build (push) Failing after 11m23s

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.
This commit is contained in:
apio 2024-04-18 21:55:16 +02:00
parent e2ff0ad273
commit b59a787b9e
Signed by: apio
GPG Key ID: B8A7D06E42258954

View File

@ -16,6 +16,8 @@ Result<bool> ScriptLoader::sniff()
Result<u64> 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++)