From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/2825 Path: news.gmane.org!not-for-mail From: Isaac Dunham Newsgroups: gmane.linux.lib.musl.general Subject: Re: strcasestr.c Date: Wed, 20 Feb 2013 22:18:27 -0800 Message-ID: <20130220221827.6ee8a6ff.idunham@lavabit.com> References: <201302141459.r1EExuU3024259@core.courtesan.com> <20130214152349.GA20323@brightrain.aerifal.cx> <20130217190452.GH20323@brightrain.aerifal.cx> <51254E0F.7010206@barfooze.de> <20130221010328.GN20323@brightrain.aerifal.cx> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1361427523 23297 80.91.229.3 (21 Feb 2013 06:18:43 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 21 Feb 2013 06:18:43 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-2826-gllmg-musl=m.gmane.org@lists.openwall.com Thu Feb 21 07:19:06 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 1U8PUm-0000tm-NO for gllmg-musl@plane.gmane.org; Thu, 21 Feb 2013 07:19:04 +0100 Original-Received: (qmail 29736 invoked by uid 550); 21 Feb 2013 06:18:42 -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 29725 invoked from network); 21 Feb 2013 06:18:41 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=lavabit; d=lavabit.com; b=C1L6l7z/+elgoxlw9b30q/GUzNtBJM5bUhfuIP4g57i+J+vKZCFqYW//iuv/ErCYrLmYnUmGGW5jGDdiUFDA5JCNCZLmds9Co58/dyiKqU207zVK3LWdW02pYM559soZh4K+v1lqCgEtskXs4pxkctFJDsYZlebrh5VlIu6H1Jc=; h=Date:From:To:Subject:Message-Id:In-Reply-To:References:X-Mailer:Mime-Version:Content-Type:Content-Transfer-Encoding; In-Reply-To: <20130221010328.GN20323@brightrain.aerifal.cx> X-Mailer: Sylpheed 3.0.2 (GTK+ 2.20.1; i486-pc-linux-gnu) Xref: news.gmane.org gmane.linux.lib.musl.general:2825 Archived-At: On Wed, 20 Feb 2013 20:03:28 -0500 Rich Felker wrote: > > Yes, it seems to have been an early mistake I made getting wget to > work. Unfortunately, I think it would be bad policy to remove it now > since that would break existing dynamic binaries using it, but one > could make an argument that breaking them is "right" since they were > already broken (not behaving as intended)... > > > >Since strcasestr is nonstandard and not clearly specified, > > > > it's so non-standard that even nobody uses it. > > i looked up the usage of the function in codesearch.debian.net, and > > the only *user* (from all ~20K debian packages) of the function is > > gnu wget. > > Are you sure this search was correct? IIRC there were more... A quick check here indicates that busybox, mutt, git, midnight commander, sylpheed, foomatic-rip, elinks, and a couple libraries use it. Busycox uses it in grep and for checking passwords (see libbb/obscure.c). > I think leaving it as-is is the worst case. It's impossible to detect > without runtime checks that it's incorrect, so it might encourage > configure scripts to add runtime checks for broken strcasestr that > break cross compiling. Or it might lead to programs just assuming it's > correct, then breaking. > > > in any case it doesnt make sense to put much work and especially > > much code into it. > > if it's gonna be implemented "correctly" at all, it should be as > > slim as possible, in the order of 3-5 LOC. > > As much as I appreciate Todd's interest in contributing a 2way-based > version, I tend to agree. Not only would adopting the 2way code be a > fairly large code addition for a never-used feature, but it would also > bind us to the choice to do ASCII-only case mapping or drop > performance drastically in the future if we want to change that > decision. > > My leaning right now would be to write the naive strstr loop using > strcasecmp instead of strcmp (or an inline loop) for the inner loop. > This will cause strcasestr to have the exact same case-folding > semantics as strcasecmp, whatever those are in the future. This is > best for consistency. Unfortunately, it's very bad from a performance > standpoint, but I don't know of any code using this function for > high-performance use. Busybox implements their own version using this approach. > The other somewhat reasonable option would be removing the function, > which would expose breakage in programs that were already using the > broken version in musl. I'm mildly against this, but I'd be interested > in hearing arguments either way. Were the claimed frequency correct, I would want it gone. As it stands, I think that a small but slow version is justifiable. A large one isn't. -- Isaac Dunham