Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xargs doesn't limit command line lengths properly #164

Open
tavianator opened this issue May 25, 2022 · 0 comments
Open

xargs doesn't limit command line lengths properly #164

tavianator opened this issue May 25, 2022 · 0 comments

Comments

@tavianator
Copy link
Contributor

$ find ~ -print0 | ./target/debug/xargs -0 echo >/dev/null
Error: Command could not be run: Argument list too long (os error 7)

From a quick look, there's at least an issue here:

findutils/src/xargs/mod.rs

Lines 141 to 146 in 36e3229

#[cfg(unix)]
fn count_osstr_chars_for_exec(s: &OsStr) -> usize {
use std::os::unix::ffi::OsStrExt;
// Include +1 for the null terminator.
s.as_bytes().len() + 1
}

This needs to count not only the length of the string, but also the size of the pointer that ends up in argv/envp.

It might be worth using the https://crates.io/crates/argmax crate to do this accounting for us. It could also help for #6.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant