Revert 'Fix off by one error' because it introduces one
Turns out, it's just redox not having a NULL pointer here. Linux does.
This commit is contained in:
+8
-8
@@ -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
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user