On Fri, Jan 24, 2020 at 2:17 PM Ron Yorston <[email protected]> wrote: > > As reported in bug 11441 when presented with a large number of quoted > arguments xargs can return 'argument line too long': > > seq 10000 29999 | sed -e 's/^/"/' -e 's/$/"/' | busybox xargs echo > > This happens because the variant of process_stdin() which handles quoted > arguments doesn't preserve state between calls. If the allowed number > of characters is exceeded part way through a quoted argument the next > call to process_stdin() incorrectly treats the terminating quote as a > starting quote, thus quoting all of the argument separators. > > function old new delta > process_stdin 301 314 +13 > static.state - 1 +1 > static.q - 1 +1 > ------------------------------------------------------------------------------ > (add/remove: 2/0 grow/shrink: 1/0 up/down: 15/0) Total: 15 bytes > > Signed-off-by: Ron Yorston <[email protected]> > --- > findutils/xargs.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/findutils/xargs.c b/findutils/xargs.c > index 726315803..d215517af 100644 > --- a/findutils/xargs.c > +++ b/findutils/xargs.c > @@ -261,8 +261,8 @@ static char* FAST_FUNC process_stdin(int n_max_chars, int > n_max_arg, char *buf) > #define QUOTE 1 > #define BACKSLASH 2 > #define SPACE 4 > - char q = '\0'; /* quote char */ > - char state = NORM; > + static char q = '\0'; /* quote char */ > + static char state = NORM;
I'm trying to avoid statics. Applied with moving them to "struct globals". _______________________________________________ busybox mailing list [email protected] http://lists.busybox.net/mailman/listinfo/busybox
