From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/161 Path: news.gmane.org!not-for-mail From: =?UTF-8?B?THVrYSBNYXLEjWV0acSH?= Newsgroups: gmane.linux.lib.musl.general Subject: Re: cluts: strerror_r() test Date: Thu, 14 Jul 2011 12:41:35 +0200 Message-ID: <4E1EC7DF.3070202@gmail.com> References: <4E125DBC.9090809@gmail.com> <4E131E8F.9@gmail.com> <4E14C55E.6030808@gmail.com> <4E16141F.5060303@gmail.com> <4E17877E.30907@gmail.com> <20110709115301.GA6510@openwall.com> <20110710145201.GB133@brightrain.aerifal.cx> <4E1B8041.1050602@gmail.com> <20110714095730.GF27991@openwall.com> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1310640201 23917 80.91.229.12 (14 Jul 2011 10:43:21 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 14 Jul 2011 10:43:21 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-245-gllmg-musl=m.gmane.org@lists.openwall.com Thu Jul 14 12:43:17 2011 Return-path: Envelope-to: gllmg-musl@lo.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by lo.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1QhJNz-0005Fa-VP for gllmg-musl@lo.gmane.org; Thu, 14 Jul 2011 12:43:16 +0200 Original-Received: (qmail 5655 invoked by uid 550); 14 Jul 2011 10:43:15 -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 5644 invoked from network); 14 Jul 2011 10:43:15 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=zZswQaZ3Y67POF1TPWQm9eAKzGg+cG6SVY/Oz+8Ndrk=; b=vg83DbzKvOCOMaD2d0C9D48bFGG0mmGopBiV/JRJ6fKQxR4ihWliP8Wi+u/3ebzWcV E8aS4sd0y93HWZHeZS7VXsbTXKn1S24dPy5ZO9beWBfgv5+LO6utnzbullA5H62uYnFG ArgpkiYArHs2Rl44Tkm0D9/59rdzsBoL0eXmU= User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.18) Gecko/20110626 Icedove/3.1.11 In-Reply-To: <20110714095730.GF27991@openwall.com> Xref: news.gmane.org gmane.linux.lib.musl.general:161 Archived-At: On 07/14/2011 11:57 AM, Solar Designer wrote: > Luka, Rich - > > I've uncommented the test for strerror_r(), which you marked "glibc > fail", and it passed the test on glibc 2.3.6 for me. What exactly was > wrong with it (or rather with glibc) in your testing? > > Thanks, > > Alexander The test was uncommented yesterday morning, as I found it was my fault that it crashed, not glibc's. Actually, I think it was -O2 that helped me realize that, after I had uncommented the function. Here's the relevant diff: https://github.com/lmarcetic/cluts/commit/803ebc888ebe6656287034739229baa93376d0fc#tests/buf.c You can see that strerror_r was passed size-1, although size was not initialized (or rather, it was initialized by a test before that one). Strerror_r implementations are free to redirect a passed pointer to immutable memory if size(buflen) argument is sufficiently large. Of course, wanting to write to s[size-1] would SIGSEGV in that case. My assumption was that glibc redirected the pointer even though I gave it size-1, in which case it's incorrect behavior and it should simply copy to the provided buffer. Turns out that's not the case, and the fail was mine. Luka.