Index: xargs.c =================================================================== RCS file: /cvsroot/findutils/findutils/xargs/xargs.c,v retrieving revision 1.18 diff -u -r1.18 xargs.c --- xargs.c 13 Mar 2004 14:52:25 -0000 1.18 +++ xargs.c 1 Jul 2004 11:15:44 -0000 @@ -303,7 +303,6 @@ int optc; int always_run_command = 1; long orig_arg_max; - long arg_size; long size_of_environment = env_size(environ); char *default_cmd = "/bin/echo"; int (*read_args) PARAMS ((void)) = read_line; @@ -322,11 +321,15 @@ orig_arg_max -= 2048; /* POSIX.2 requires subtracting 2048. */ arg_max = orig_arg_max; - arg_size = 20 * 1048 + size_of_environment; - + /* Sanity check for systems with huge ARG_MAX defines (e.g., Suns which + have it at 1 meg). Things will work fine with a large ARG_MAX but it + will probably hurt the system more than it needs to; an array of this + size is allocated. */ + if (arg_max > 20 * 1024 + size_of_environment) + arg_max = 20 * 1024 + size_of_environment; /* Take the size of the environment into account. */ - arg_max -= env_size (environ); + arg_max -= size_of_environment; if (arg_max <= 0) error (1, 0, _("environment is too large for exec")); @@ -381,7 +384,7 @@ break; case 's': - arg_size = parse_num (optarg, 's', 1L, orig_arg_max); + arg_max = parse_num (optarg, 's', 1L, orig_arg_max - size_of_environment); break; case 't': @@ -424,22 +427,6 @@ argv = &default_cmd; } - /* Taking into account the sisze of the environment, - * figure out how large a buffer we need to - * hold all the arguments. We cannot use ARG_MAX - * directly since that may be arbitrarily large. - * This is from a patch by Bob Prolux, . - */ - if (arg_max > arg_size) - { - arg_max = arg_size; - } - if (size_of_environment > arg_max) - { - error (1, 0, _("environment is too large for max-chars size, try using the -s option")); - } - - linebuf = (char *) xmalloc (arg_max + 1); argbuf = (char *) xmalloc (arg_max + 1);