From 66d7aa8553b5b203d6973b9f0bbd06ad458a79cd Mon Sep 17 00:00:00 2001 From: jD91mZM2 <me@krake.one> Date: Mon, 13 Aug 2018 11:37:29 +0200 Subject: [PATCH] Revert 'Fix off by one error' because it introduces one Turns out, it's just redox not having a NULL pointer here. Linux does. --- src/crt0/src/lib.rs | 16 ++++++++-------- src/platform/src/redox/mod.rs | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/crt0/src/lib.rs b/src/crt0/src/lib.rs index ce61529cc..ceb003f96 100644 --- a/src/crt0/src/lib.rs +++ b/src/crt0/src/lib.rs @@ -41,7 +41,7 @@ pub unsafe extern "C" fn _start() { #[repr(C)] pub struct Stack { argc: isize, - argv0: *const u8, + argv0: *const c_char, } impl Stack { @@ -49,12 +49,12 @@ impl Stack { self.argc } - fn argv(&self) -> *const *const u8 { - &self.argv0 as *const *const u8 + fn argv(&self) -> *const *const c_char { + &self.argv0 as *const _ } - fn envp(&self) -> *const *const u8 { - unsafe { self.argv().offset(self.argc()) } + fn envp(&self) -> *const *const c_char { + unsafe { self.argv().offset(self.argc() + 1) } } } @@ -83,7 +83,7 @@ pub unsafe extern "C" fn _start_rust(sp: &'static Stack) -> ! { let buf = platform::alloc(len as usize + 1) as *mut c_char; for i in 0..=len { - *buf.offset(i) = *item.offset(i) as c_char; + *buf.offset(i) = *item.offset(i); } platform::inner_environ.push(buf); } @@ -97,8 +97,8 @@ pub unsafe extern "C" fn _start_rust(sp: &'static Stack) -> ! { platform::exit(main( argc, - argv as *const *const c_char, - envp as *const *const c_char, + argv, + envp )); } diff --git a/src/platform/src/redox/mod.rs b/src/platform/src/redox/mod.rs index 24637c02a..19c02b306 100644 --- a/src/platform/src/redox/mod.rs +++ b/src/platform/src/redox/mod.rs @@ -201,7 +201,7 @@ pub unsafe extern "C" fn execve( ) -> c_int { use alloc::Vec; - let fd = match RawFile::open(path, 0, 0) { + let fd = match RawFile::open(path, O_RDONLY as c_int, 0) { Ok(fd) => fd, Err(_) => return -1 }; -- GitLab