[Toybox] xargs "argument too long"

enh enh at google.com
Mon Jul 8 14:06:06 PDT 2019


patch attached.

i did check, in case we're crazy, and the kernel does do the right
thing, there's no weird special case for these bytes in the kernel
(this is linux; i didn't actually check a BSD kernel):

/*
* We must account for the size of all the argv and envp pointers to
* the argv and envp strings, since they will also take up space in
* the stack. They aren't stored until much later when we can't
* signal to the parent that the child has run out of stack space.
* Instead, calculate it here so it's possible to fail gracefully.
*/
ptr_size = (bprm->argc + bprm->envc) * sizeof(void *);
if (limit <= ptr_size)
return -E2BIG;

oddly the [Free]BSD xargs does count the space for the pointers for
the common arguments given on the xargs command line, but not the
pointers for the "extra" arguments from the input.

On Sat, Jul 6, 2019 at 2:33 PM Rob Landley <rob at landley.net> wrote:
>
> On 7/2/19 1:26 PM, enh via Toybox wrote:
> > so you'll not like this...
>
> You're right, I do not.
>
> > as far as i can tell, GNU xargs isn't counting those bytes. that's the
> > only way i can make sense of the behavior when i add/subtract one from
> > the -s argument...
>
> I want a kernel API to query how much environment space exec() can take. I
> really, really do...
>
> > _seems_ like a GNU bug, but if no-one's cared/noticed all these years?
> > plus the BSD xargs on macOS behaves the same as the GNU one, so
> > there's widespread support for not counting the pointers...
>
> I am not currently capable of expressing my disgust in the ascii character set,
> and am not up to trying to get thunderbird to understand emoji just now.
>
> Sigh, could you send me a git am patch? I really don't want to check that in
> under my own name.
>
> Thanks,
>
> Rob
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-xargs-bug-compatibility-with-BSD-busybox-findutils.patch
Type: text/x-patch
Size: 1021 bytes
Desc: not available
URL: <http://lists.landley.net/pipermail/toybox-landley.net/attachments/20190708/dcafa1ff/attachment-0003.bin>


More information about the Toybox mailing list