[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug #62621] xargs/find: buildcmd incorrectly sizes argv and envp
From: |
Thomas Hurst |
Subject: |
[bug #62621] xargs/find: buildcmd incorrectly sizes argv and envp |
Date: |
Mon, 13 Jun 2022 09:24:22 -0400 (EDT) |
URL:
<https://savannah.gnu.org/bugs/?62621>
Summary: xargs/find: buildcmd incorrectly sizes argv and envp
Project: findutils
Submitter: freaky
Submitted: Mon 13 Jun 2022 01:24:21 PM UTC
Category: xargs
Severity: 3 - Normal
Item Group: Wrong result
Status: None
Privacy: Public
Assigned to: None
Originator Name:
Originator Email:
Open/Closed: Open
Release: None
Discussion Lock: Any
Fixed Release: None
_______________________________________________________
Follow-up Comments:
-------------------------------------------------------
Date: Mon 13 Jun 2022 01:24:21 PM UTC By: Thomas Hurst <freaky>
buildcmd.c calculates the size of both arguments and environment entries as
strlen(s) + 1 - the size of the string plus delimiter.
This fails to take into account the argv/envp pointer to each entry, which at
least on Linux also contributes to the limit. To quote bprm_stack_limits()
from fs/exec.c:
> 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.
And indeed, sizeof(void*)*argc+envc are subtracted from the limit it
enforces.
This issue is masked by xargs defaulting to quite modest limits, and retrying
automatically with smaller sizes on E2BIG - though in testing this I find what
appears to be another issue, which I will file separately.
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?62621>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
- [bug #62621] xargs/find: buildcmd incorrectly sizes argv and envp,
Thomas Hurst <=