From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp-2.sys.kth.se (smtp-2.sys.kth.se [130.237.32.160]) by krisdoz.my.domain (8.14.3/8.14.3) with ESMTP id p2EH75na013452 for ; Mon, 14 Mar 2011 13:07:05 -0400 (EDT) Received: from mailscan-1.sys.kth.se (mailscan-1.sys.kth.se [130.237.32.91]) by smtp-2.sys.kth.se (Postfix) with ESMTP id 9F8C514DC52; Mon, 14 Mar 2011 18:06:59 +0100 (CET) X-Virus-Scanned: by amavisd-new at kth.se Received: from smtp-2.sys.kth.se ([130.237.32.160]) by mailscan-1.sys.kth.se (mailscan-1.sys.kth.se [130.237.32.91]) (amavisd-new, port 10024) with LMTP id wuJwGhjQGjiO; Mon, 14 Mar 2011 18:06:58 +0100 (CET) X-KTH-Auth: kristaps [77.202.18.254] X-KTH-mail-from: kristaps@bsd.lv Received: from [192.168.1.90] (254.18.202-77.rev.gaoland.net [77.202.18.254]) by smtp-2.sys.kth.se (Postfix) with ESMTP id 4942214C129; Mon, 14 Mar 2011 18:06:55 +0100 (CET) Message-ID: <4D7E4B2E.5090400@bsd.lv> Date: Mon, 14 Mar 2011 18:06:54 +0100 From: Kristaps Dzonsons User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.13) Gecko/20101207 Thunderbird/3.1.7 X-Mailinglist: mdocml-tech Reply-To: tech@mdocml.bsd.lv MIME-Version: 1.0 To: tech@mdocml.bsd.lv CC: Ingo Schwarze , uqs@spoerlein.net Subject: Re: Logic error in mandoc.c time2a() References: <20110311204204.GA85668@acme.spoerlein.net> <20110312002738.GA12289@iris.usta.de> <20110312015914.GB12289@iris.usta.de> In-Reply-To: <20110312015914.GB12289@iris.usta.de> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit > + p = buf = mandoc_malloc(10 + 4 + 4 + 1); > > - if (0 == (nsz = strftime(p, rsz, "%B ",&tm))) > - return(NULL); > - > - p += (int)nsz; > - rsz -= nsz; > - > - if (-1 == (isz = snprintf(p, rsz, "%d, ", tm.tm_mday))) > - return(NULL); > + if (0 == (ssz = strftime(p, 10 + 1, "%B ",&tm))) > + goto fail; > + p += (int)ssz; > > + if (-1 == (isz = snprintf(p, 4 + 1, "%d, ", tm.tm_mday))) > + goto fail; > p += isz; > - rsz -= isz; > > - return(strftime(p, rsz, "%Y",&tm) ? buf : NULL); > + if (0 == strftime(p, 4 + 1, "%Y",&tm)) > + goto fail; > + return(buf); > + > +fail: > + free(buf); > + return(NULL); Ingo, I'm fine with the motion of this diff, but please thoroughly document the numbers in this before you commit. Yes, they're clear upon inspection, but I want more in there than 10 + 4 + 4 + 1... But given this, ok kristaps. Thanks! Kristaps -- To unsubscribe send an email to tech+unsubscribe@mdocml.bsd.lv