From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/1219 Path: news.gmane.org!not-for-mail From: Paul Eggert Newsgroups: gmane.comp.lib.gnulib.bugs,gmane.linux.lib.musl.general Subject: Re: [musl] Re: musl bugs found through gnulib Date: Thu, 21 Jun 2012 01:52:00 -0700 Organization: UCLA Computer Science Department Message-ID: <4FE2E0B0.7030507@cs.ucla.edu> References: <20120609230541.47eac2de@newbook> <4FD55156.7050302@cs.ucla.edu> <20120611182202.1ee4d019@newbook> <12545931.v3ALTEUUx8@linuix> <20120620192802.GW163@brightrain.aerifal.cx> <20120621022116.GX163@brightrain.aerifal.cx> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1340268758 17976 80.91.229.3 (21 Jun 2012 08:52:38 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 21 Jun 2012 08:52:38 +0000 (UTC) Cc: bug-gnulib@gnu.org, Reuben Thomas , musl@lists.openwall.com, Isaac Dunham To: Rich Felker Original-X-From: bug-gnulib-bounces+gnu-bug-gnulib=m.gmane.org@gnu.org Thu Jun 21 10:52:34 2012 Return-path: Envelope-to: gnu-bug-gnulib@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Shd7t-00019q-MG for gnu-bug-gnulib@m.gmane.org; Thu, 21 Jun 2012 10:52:29 +0200 Original-Received: from localhost ([::1]:45205 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Shd7q-0000Vl-B4 for gnu-bug-gnulib@m.gmane.org; Thu, 21 Jun 2012 04:52:26 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:34127) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Shd7k-0000VD-F8 for bug-gnulib@gnu.org; Thu, 21 Jun 2012 04:52:24 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Shd7d-0001zb-VU for bug-gnulib@gnu.org; Thu, 21 Jun 2012 04:52:20 -0400 Original-Received: from smtp.cs.ucla.edu ([131.179.128.62]:40435) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Shd7d-0001xJ-NH for bug-gnulib@gnu.org; Thu, 21 Jun 2012 04:52:13 -0400 Original-Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id AC286A60019; Thu, 21 Jun 2012 01:52:03 -0700 (PDT) X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu Original-Received: from smtp.cs.ucla.edu ([127.0.0.1]) by localhost (smtp.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 1O7sho3kTfhc; Thu, 21 Jun 2012 01:52:01 -0700 (PDT) Original-Received: from [192.168.1.10] (pool-108-23-119-2.lsanca.fios.verizon.net [108.23.119.2]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id CCE02A6000D; Thu, 21 Jun 2012 01:52:00 -0700 (PDT) User-Agent: Mozilla/5.0 (X11; Linux i686; rv:12.0) Gecko/20120430 Thunderbird/12.0.1 In-Reply-To: <20120621022116.GX163@brightrain.aerifal.cx> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 131.179.128.62 X-BeenThere: bug-gnulib@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Gnulib discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnulib-bounces+gnu-bug-gnulib=m.gmane.org@gnu.org Original-Sender: bug-gnulib-bounces+gnu-bug-gnulib=m.gmane.org@gnu.org Xref: news.gmane.org gmane.comp.lib.gnulib.bugs:31101 gmane.linux.lib.musl.general:1219 Archived-At: On 06/20/2012 07:21 PM, Rich Felker wrote: >>> Replacement of mktime, because of >>> checking for working mktime... no > > This test is buggy; it goes into an infinite loop due to integer > overflow UB, because the condition to break out of the loop is only > checked when the test does not fail: Thanks, I pushed the following patch into gnulib: --- ChangeLog | 9 +++++++++ m4/mktime.m4 | 25 ++++++++++++++----------- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 199b06c..1661a62 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2012-06-21 Paul Eggert + + mktime: fix integer overflow in 'configure'-time test + * m4/mktime.m4 (gl_FUNC_MKTIME): Do not rely on undefined behavior + after integer overflow. Problem reported by Rich Felker in + . + Also, don't look for further instances of a bug if we've already + found one instance; this helps 'configure' run faster. + 2012-06-20 John Darrington (tiny change) tmpfile, clean-temp: Fix invocation of GetVersionEx. diff --git a/m4/mktime.m4 b/m4/mktime.m4 index 5e05dfa..14fcf7f 100644 --- a/m4/mktime.m4 +++ b/m4/mktime.m4 @@ -1,4 +1,4 @@ -# serial 21 +# serial 22 dnl Copyright (C) 2002-2003, 2005-2007, 2009-2012 Free Software Foundation, dnl Inc. dnl This file is free software; the Free Software Foundation @@ -192,20 +192,23 @@ main () if (tz_strings[i]) putenv (tz_strings[i]); - for (t = 0; t <= time_t_max - delta; t += delta) + for (t = 0; t <= time_t_max - delta && (result & 1) == 0; t += delta) if (! mktime_test (t)) result |= 1; - if (! (mktime_test ((time_t) 1) - && mktime_test ((time_t) (60 * 60)) - && mktime_test ((time_t) (60 * 60 * 24)))) + if ((result & 2) == 0 + && ! (mktime_test ((time_t) 1) + && mktime_test ((time_t) (60 * 60)) + && mktime_test ((time_t) (60 * 60 * 24)))) result |= 2; - for (j = 1; ; j <<= 1) - if (! bigtime_test (j)) - result |= 4; - else if (INT_MAX / 2 < j) - break; - if (! bigtime_test (INT_MAX)) + for (j = 1; (result & 4) == 0; j <<= 1) + { + if (! bigtime_test (j)) + result |= 4; + if (INT_MAX / 2 < j) + break; + } + if ((result & 8) == 0 && ! bigtime_test (INT_MAX)) result |= 8; } if (! irix_6_4_bug ()) -- 1.7.6.5