From b5e764d967a11626dd0f54d01d2452b74783ee8e Mon Sep 17 00:00:00 2001 From: Wildan M Date: Tue, 23 Jun 2026 12:22:31 +0700 Subject: [PATCH] Fix posix_spawn launching sh script --- redox-rt/src/proc.rs | 5 +++++ src/platform/redox/mod.rs | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/redox-rt/src/proc.rs b/redox-rt/src/proc.rs index 64e9caf6f0..34b321e5ae 100644 --- a/redox-rt/src/proc.rs +++ b/redox-rt/src/proc.rs @@ -85,6 +85,11 @@ pub fn fexec_impl( pread_all(&image_file, 0, &mut header_bytes)?; let header = Header::from_bytes(&header_bytes); + if header.e_ident[..4] != [0x7F, 0x45, 0x4C, 0x46] { + // Not an ELF, according to posix_spawn() just throw error here + return Err(Error::new(ENOEXEC)); + } + let grants_fd = if let Some(interp) = interp_override.as_ref() { FdGuard::new(interp.grants_fd).to_upper()? } else { diff --git a/src/platform/redox/mod.rs b/src/platform/redox/mod.rs index 5655420c2b..b849ab0287 100644 --- a/src/platform/redox/mod.rs +++ b/src/platform/redox/mod.rs @@ -1332,7 +1332,7 @@ impl Pal for Sys { // .map(|s| str::from_utf8(s).unwrap_or("???")) // .collect::>() // .as_slice(), - // cwd.as_bytes() + // cwd.as_str() // ); new_file_table.call_wo(