SarK0Y
November 1, 2024, 4:57pm
1
Hi there, Guys.
i need some advice of Yours. i've tried to run cargo command w/ execve syscall, but cargo can't consume static-sized array of args..
bash> cargo clean ""
error: unrecognized subcommand ''
how to prevent cargo to react on those empty CStrings ???
Thanks a lot in Advance.
SarK0Y
November 1, 2024, 5:18pm
2
match execve ( &c_str ( &app_name), &args[0..cnt], &env ) {
Err(e) => {logErr(e );},
_ => {}
};
seems to work..
use console::truncate_str;
use nix::sys::signal::pthread_sigmask;
use once_cell::sync::Lazy;
use nix::sys::wait::wait;
use nix::unistd::{fork, ForkResult, getpid, getppid, execve};
use std::env;
use std::{ ffi::CString, env::var, num::NonZero };
use crate::globs18::take_list_adr;
use crate::update18::delay_secs;
use procfs::process::all_processes;
use crate::{dbg, errMsg0, getkey, helpful_math_ops, save_file, save_file_append, save_file_append_newline_abs_adr_fast, split_once, split_once_or_ret_null_strns, STRN};
use std::ptr; use std::cell::RefCell;
use std::mem::{forget, ManuallyDrop, ManuallyDrop as md};
use crate::enums::calc_kids;
#[derive( Debug, PartialEq )]
pub struct tree_of_prox {
pub ppid: i32 ,
//ppid: nix::unistd::Pid,
pub up: *mut tree_of_prox,
pub kids: *mut Vec< *mut tree_of_prox >,
This file has been truncated. show original
It's a strange request -- I think most programs will try to deal with an empty argument differently than it would without that argument at all.
In this particular case, ["cargo", "clean", "--"]
would work to pad it to 3 arguments, but you couldn't go any further that way.
the8472
November 2, 2024, 11:35am
4
argv passed to execve
is a pointer to an array of pointers . So just set the pointer in the slot after the last argument to null instead of pointing to an empty string. Then any further elements will be ignored.
2 Likes