From e5d3c3f3d0dfcc399ef1f7623ddeab619db4b4ea Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Fri, 27 Feb 2026 11:40:53 +0100 Subject: Bad the input buffer with nul bytes --- oryxc/src/compiler.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'oryxc/src/compiler.rs') diff --git a/oryxc/src/compiler.rs b/oryxc/src/compiler.rs index 14919ba..bdb4475 100644 --- a/oryxc/src/compiler.rs +++ b/oryxc/src/compiler.rs @@ -44,7 +44,13 @@ pub struct FileData { impl FileData { fn new(name: OsString) -> Result { - let buffer = fs::read_to_string(&name)?; + const PAD: [u8; 64] = [0; 64]; /* 512 bits */ + + // Append extra data to the end so that we can safely read past + // instead of branching on length + let mut buffer = fs::read_to_string(&name)?; + buffer.push_str(unsafe { str::from_utf8_unchecked(&PAD) }); + return Ok(Self { name: name.into(), buffer: buffer.into(), -- cgit v1.2.3