From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/2629 Path: news.gmane.org!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: REG_STARTEND (regex) Date: Wed, 16 Jan 2013 11:57:01 -0500 Message-ID: <20130116165701.GE20323@brightrain.aerifal.cx> References: <20130115184513.GZ20323@brightrain.aerifal.cx> <1358350921.32505.33@driftwood> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1358355433 28157 80.91.229.3 (16 Jan 2013 16:57:13 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 16 Jan 2013 16:57:13 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-2630-gllmg-musl=m.gmane.org@lists.openwall.com Wed Jan 16 17:57:31 2013 Return-path: Envelope-to: gllmg-musl@plane.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1TvWIs-0003BQ-Qv for gllmg-musl@plane.gmane.org; Wed, 16 Jan 2013 17:57:31 +0100 Original-Received: (qmail 1568 invoked by uid 550); 16 Jan 2013 16:57:14 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 1558 invoked from network); 16 Jan 2013 16:57:13 -0000 Content-Disposition: inline In-Reply-To: <1358350921.32505.33@driftwood> User-Agent: Mutt/1.5.21 (2010-09-15) Xref: news.gmane.org gmane.linux.lib.musl.general:2629 Archived-At: On Wed, Jan 16, 2013 at 09:42:01AM -0600, Rob Landley wrote: > On 01/15/2013 12:45:13 PM, Rich Felker wrote: > >> Does anyone have suggestions on how this can be modified to be > >able to > >> use it with musl. > > > >If the start position is 0, which it seems to be here, there's nothing > >to be done but removing REG_STARTEND. All it's doing is allowing you > >to process data with embedded nul bytes, which is not required by the > >standard or useful for any meaningful use of sed. > > Actually people use sed to modify embedded strings in binaries. > (Strange but true.) > > >Nobody will notice > >the difference with it missing unless they're trying to perform > >hideous hacks like patching binary files with sed... > > Which people do. > > However, mostly this involves embedded nuls in the data being > processed, not embedded nuls in the pattern space. So it's merely > creepy rather than outright pathological. And the caller can wrap > the regex library to do its own strlen stuff and restart right after > the embedded NUL if there's data left. (Which was on the todo list > for busybox sed back when Bruce happened, possibly Denys has > implemented it since.) If sed wants to support this without providing its own embedded-NUL-capable regex library, it should just treat NUL as a kind of boundary/line-break so that the pattern space never ends up containing NUL bytes. However, there are still a good many other portability issues with passing binary files to sed, even if you ignore the fact that POSIX sed specifically requires a text file as input, so I think it's rather misguided to cater to these uses anyway. Rich