From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/1539 Path: news.gmane.org!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: wcsstr is broken Date: Sat, 11 Aug 2012 18:42:19 -0400 Message-ID: <20120811224219.GP27715@brightrain.aerifal.cx> References: <20120810154136.GC20243@port70.net> 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: dough.gmane.org 1344724899 602 80.91.229.3 (11 Aug 2012 22:41:39 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sat, 11 Aug 2012 22:41:39 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-1540-gllmg-musl=m.gmane.org@lists.openwall.com Sun Aug 12 00:41:39 2012 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 1T0KN9-0002Am-A2 for gllmg-musl@plane.gmane.org; Sun, 12 Aug 2012 00:41:31 +0200 Original-Received: (qmail 24327 invoked by uid 550); 11 Aug 2012 22:41:30 -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 24319 invoked from network); 11 Aug 2012 22:41:29 -0000 Content-Disposition: inline In-Reply-To: <20120810154136.GC20243@port70.net> User-Agent: Mutt/1.5.21 (2010-09-15) Xref: news.gmane.org gmane.linux.lib.musl.general:1539 Archived-At: On Fri, Aug 10, 2012 at 05:41:36PM +0200, Szabolcs Nagy wrote: > naive_wcsstr is wrong, h can overrun in the inner loop > as reported in irc: > > 16:36 < dkl> with certain input, it appears to be overrunning > 16:36 < dkl> for example: wcsstr(L"ab", L"ac"); > .... > 16:41 < dkl> in this case the inner one keeps increasing the "h" pointer past the null terminator > 16:44 < dkl> I had a go at a patch too: http://jafile.com/uploads/dkl/0001-wcsstr-fix-buffer-overrun.patch > > see patch below Is my fix in git acceptable (just removing the buggy function and always calling twoway) or would you like to put back a working function? Looking back, I find it kind of ugly to have a function written to handle arbitrary-length needles that's only used for really short ones... Rich