From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/163 Path: news.gmane.org!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: cluts: strerror_r() test Date: Thu, 14 Jul 2011 13:55:09 -0400 Message-ID: <20110714175509.GK16618@brightrain.aerifal.cx> 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> <4E1EC7DF.3070202@gmail.com> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: dough.gmane.org 1310666680 346 80.91.229.12 (14 Jul 2011 18:04:40 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 14 Jul 2011 18:04:40 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-247-gllmg-musl=m.gmane.org@lists.openwall.com Thu Jul 14 20:04:37 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 1QhQH5-0000J9-Jb for gllmg-musl@lo.gmane.org; Thu, 14 Jul 2011 20:04:35 +0200 Original-Received: (qmail 14275 invoked by uid 550); 14 Jul 2011 18:04:34 -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 14260 invoked from network); 14 Jul 2011 18:04:33 -0000 Content-Disposition: inline In-Reply-To: <4E1EC7DF.3070202@gmail.com> User-Agent: Mutt/1.5.21 (2010-09-15) Xref: news.gmane.org gmane.linux.lib.musl.general:163 Archived-At: On Thu, Jul 14, 2011 at 12:41:35PM +0200, Luka Marčetić wrote: > one). Strerror_r implementations are free to redirect a passed > pointer to immutable memory if size(buflen) argument is sufficiently I don't see how this can be. sterror_r (the correct standard function not the GNU bastardization) has no way of returning a pointer to a string. Due to the interface design, it must write into the provided buffer. By the way, this is another reason _POSIX_C_SOURCE or _XOPEN_SOURCE must be defined - glibc likes to give you nonstandard GNU functions by default... > large. Of course, wanting to write to s[size-1] would SIGSEGV in Actually it would probably just corrupt malloc data structures and lead to havoc much later in the program. To test you could use a trick like the string function tests, but that's really overkill. Just allocating a buffer that's large enough, pre-filling it with an unusual value, and calling the function with a shorter length parameter should work. Then you can check that none of the fill bytes were clobbered past the allowed length. I hope this makes sense... Rich