8000 xargs doesn't limit command line lengths properly · Issue #164 · uutils/findutils · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
xargs doesn't limit command line lengths properly #164
Open
@tavianator

Description

@tavianator
$ 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0