From owner-freebsd-audit Fri Mar 22 8:33:38 2002 Delivered-To: freebsd-audit@freebsd.org Received: from sunny.newgold.net (Durham-ar1-4-64-252-018.dsl.genuity.net [4.64.252.18]) by hub.freebsd.org (Postfix) with ESMTP id 8DB7237B427; Fri, 22 Mar 2002 08:33:23 -0800 (PST) Received: from sunny.newgold.net (freebsd@localhost [IPv6:::1]) by sunny.newgold.net (8.12.1/8.12.1) with ESMTP id g2MG85II012588; Fri, 22 Mar 2002 16:12:10 GMT Received: (from freebsd@localhost) by sunny.newgold.net (8.12.1/8.12.1/Submit) id g2MG7svv006089; Fri, 22 Mar 2002 16:07:54 GMT Date: Fri, 22 Mar 2002 16:06:32 +0000 From: "J. Mallett" To: "J. Mallett" Cc: "Tim J. Robbins" , freebsd-audit@FreeBSD.ORG, freebsd-standards@FreeBSD.ORG Subject: Re: patch for review: xargs standards compliance Message-ID: <20020322160631.A31375@FreeBSD.ORG> References: <20020315231100.A20942@FreeBSD.ORG> <20020316192629.A5254@descent.robbins.dropbear.id.au> <20020316090004.A26394@FreeBSD.ORG> <20020316093507.B26394@FreeBSD.ORG> <20020316101434.A2192@FreeBSD.ORG> <20020322035231.A23277@FreeBSD.ORG> <20020322160802.B1338@descent.robbins.dropbear.id.au> <20020322151214.A26549@FreeBSD.ORG> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20020322151214.A26549@FreeBSD.ORG> User-Agent: Mutt/1.3.21i Organisation: FreeBSD Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Fri, Mar 22, 2002 at 03:12:15PM +0000, J. Mallett wrote: > > Well, given all the input thus far, I'd like to commit > http://people.freebsd.org/~jmallett/xargs.patch4 > However I just pulled up the SUS spec online and found I was misremembering how exactly things were worded, and realised that strnsubst needs run with a n of 5 for each argument, not for the entire arguments list. 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... Thoughts? Anyway, here's with strnsubst() taking yet another size_t argument, and it being used to set the maximum size, and checks as I think the standard permits it. The way I've done it is to ensure we either get as much of the input string as possible, or we continue concatenating. This sometimes results in arguments less than 255 bytes, but will never result in a higher amount. The standard is not clear enough on this point in my opinion, and so it is up to the implementation what to do to ensure it never grows beyond 255 bytes per argument, I suppose, in whatever way is seen fit. http://people.freebsd.org/~jmallett/xargs.patch5 This is being copied to -standards, as now I am getting into the grounds of interpereting SUS, and I'd rather not do that without review in principle as well as in code. Thank you, /j. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message