From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/393 Path: news.gmane.org!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: New daily reports - nothing Date: Wed, 10 Aug 2011 14:33:35 -0400 Message-ID: <20110810183335.GB132@brightrain.aerifal.cx> References: <4E40A33F.7090804@gmail.com> <4E41E020.7020109@gmail.com> <20110810045933.GW132@brightrain.aerifal.cx> <4E427D34.4000905@gmail.com> <20110810142500.GX132@brightrain.aerifal.cx> <4E42BE37.4030805@gmail.com> <20110810173307.GZ132@brightrain.aerifal.cx> <4E42CCA9.50505@gmail.com> <20110810182115.GA132@brightrain.aerifal.cx> <4E42CF46.4090707@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 1313001998 30961 80.91.229.12 (10 Aug 2011 18:46:38 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 10 Aug 2011 18:46:38 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-394-gllmg-musl=m.gmane.org@lists.openwall.com Wed Aug 10 20:46:33 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 1QrDnV-0000a3-Cz for gllmg-musl@lo.gmane.org; Wed, 10 Aug 2011 20:46:33 +0200 Original-Received: (qmail 7330 invoked by uid 550); 10 Aug 2011 18:46:33 -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 7322 invoked from network); 10 Aug 2011 18:46:32 -0000 Content-Disposition: inline In-Reply-To: <4E42CF46.4090707@gmail.com> User-Agent: Mutt/1.5.21 (2010-09-15) Xref: news.gmane.org gmane.linux.lib.musl.general:393 Archived-At: On Wed, Aug 10, 2011 at 08:34:46PM +0200, Luka Marčetić wrote: > On 08/10/2011 08:21 PM, Rich Felker wrote: > >On Wed, Aug 10, 2011 at 08:23:37PM +0200, Luka Marčetić wrote: > >>On 08/10/2011 07:33 PM, Rich Felker wrote: > >>>What about SIZE_MAX>>(4*sizeof(size_t))? > >>Never heard of it. What about PTRDIFF_MAX though? > >My point was that SIZE_MAX>>(4*sizeof(size_t)) is an easy way to get > >the square root of SIZE_MAX without long double arithmetic. > > Doesn't seem that easy to me. It is. That's the beauty of logarithms. > >PTRDIFF_T > >is rather irrelevant to testing calloc overflows, where the whole > >point is that A*B overflows SIZE_MAX and results in a small integer > >value where the allocation will certainly succeed. > > The task says I should test for PTRDIFF_T. So i tried to make a > general function. Testing if malloc allocates memory larger than PTRDIFF_MAX is independent of testing if calloc is subject to multiplication overflow vulnerabilities. Rich