From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/10716 Path: news.gmane.org!.POSTED!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: [PATCH v2] fix integer overflow of tm_year in __secs_to_tm Date: Mon, 7 Nov 2016 22:57:14 -0500 Message-ID: <20161108035714.GH1555@brightrain.aerifal.cx> References: <20161103022936.13564-1-dsabogalcc@gmail.com> <20161107170948.GF1555@brightrain.aerifal.cx> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: blaine.gmane.org 1478577454 10083 195.159.176.226 (8 Nov 2016 03:57:34 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 8 Nov 2016 03:57:34 +0000 (UTC) User-Agent: Mutt/1.5.21 (2010-09-15) To: musl@lists.openwall.com Original-X-From: musl-return-10729-gllmg-musl=m.gmane.org@lists.openwall.com Tue Nov 08 04:57:30 2016 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.84_2) (envelope-from ) id 1c3xXI-0001KE-VX for gllmg-musl@m.gmane.org; Tue, 08 Nov 2016 04:57:25 +0100 Original-Received: (qmail 5736 invoked by uid 550); 8 Nov 2016 03:57:26 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 5715 invoked from network); 8 Nov 2016 03:57:25 -0000 Content-Disposition: inline In-Reply-To: Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:10716 Archived-At: On Mon, Nov 07, 2016 at 10:40:52PM -0500, Daniel Sabogal wrote: > On Mon, Nov 7, 2016 at 12:09 PM, Rich Felker wrote: > > On Wed, Nov 02, 2016 at 10:29:36PM -0400, Daniel Sabogal wrote: > >> From: Daniel Sabogal > >> > >> the overflow check for years+100 did not account for the extra > >> year computed from the remaining months. instead, perform this > >> check after obtaining the final number of years. > >> --- > >> v2: Subtract 12 from months, not 10. > > > > Thanks. I almost accepted the old patch with the error. Maybe in the > > future consider including a test case with the patch. > > I provided a sample program within the patch. > Did you have something else in mind for test cases? Admittedly I missed it somehow, but I guess to call it a test case I'd want to see expected results and a justification for them. In this case diff of old vs new output for various inputs would have caught the bug in v1. It might be nice to have a test in libc-test that just runs a bunch of time_t-tm-time_t and tm-time_t-tm round trips for random inputs and checks that they round-trip successfully... > > I don't want to make testcases a prerequisite for bug fixes because > > that leads to bugs going unfixed for a long time, but perhaps for > > obscure issues like this unlikely to be hit in real-world use, it > > would be good to strongly encourage submission of test cases with > > patches. > > I agree. ...but the above ideas are getting well beyond what I'd want to impose on bug reporters/minor patch authors. So it's more just brainstorming about the tests that would be helpful for someone with the time to help with testing to implement. Rich