From 85671d63021451ad450f8c57a565b0bb0c0cb2b7 Mon Sep 17 00:00:00 2001 From: Tej Qu Nair Date: Mon, 24 Jun 2024 16:24:29 -0700 Subject: [PATCH] feat: put hook results in the front of the input stream (#973) Hook results must be accessed immediately after calling. One no longer has to rely on the `input_stream` being empty when calling a hook and accessing its results. --- core/src/syscall/write.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/src/syscall/write.rs b/core/src/syscall/write.rs index 697ac48b92..fc159c0719 100644 --- a/core/src/syscall/write.rs +++ b/core/src/syscall/write.rs @@ -74,7 +74,9 @@ impl Syscall for SyscallWrite { rt.state.input_stream.push(slice.to_vec()); } else if let Some(mut hook) = rt.hook_registry.get(&fd) { let res = hook.invoke_hook(rt.hook_env(), slice); - rt.state.input_stream.extend(res); + // Add result vectors to the beginning of the stream. + let ptr = rt.state.input_stream_ptr; + rt.state.input_stream.splice(ptr..ptr, res); } else { log::warn!("tried to write to unknown file descriptor {fd}"); }