Re: patch for review: xargs standards compliance

"Tim J. Robbins" <[email protected]>
Newsgroups gmane.os.freebsd.devel.audit
Message-ID <[email protected]>
On Fri, Mar 22, 2002 at 04:06:32PM +0000, J. Mallett wrote:

> One thing I am now unsure of that I'd forgotten all about is:
> 	"Constructed arguments cannot grow larger than 255 bytes. "
> 
> Should I errx() if strlen(*tmp) is >255, or should I augment strnsubst() 
> to take a size argument and not allow more than that amount to be 
> allocated, and furthermore, do I strlcat replstr for each match, or do I 
> do checks along the way to see if it is time to give up on replacing, and 
> just concatenate the rest of the string.  I *think* given the language 
> relating to umber of replacements in the argument list, that I should TRY 
> to replace as many times as possible, up to five...

$ echo hello | xargs -I xxx echo `perl -e 'print "A"x255;'`xxx
xargs: Maximum argument size with insertion via xxx's exceeded
Segmentation Fault
$ uname -sr
SunOS 5.8

Since SUS is biased towards SysV, you should probably print an error message
and exit like Solaris tries to; no need for you to segfault like they
do though ;)

Also:
$ echo hello | xargs -Ixxx a xxx b xxx c xxx d xxx e xxx f xxx
xargs: too many args with xxx

So it seems you should quit with an error when either of these limits
are reached. This seems to be a flaw in the standard because these
limits are (a) artifically low and (b) cannot be raised by implementors.


Tim

To Unsubscribe: send mail to [email protected]
with "unsubscribe freebsd-audit" in the body of the message
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.