Received: from pch.mit.edu (PCH.MIT.EDU [18.7.21.90]) by krbdev.mit.edu (8.9.3p2) with ESMTP id UAA25107; Thu, 19 Jan 2006 20:49:42 -0500 (EST) Received: from pch.mit.edu (pch.mit.edu [127.0.0.1]) by pch.mit.edu (8.12.8p2/8.12.8) with ESMTP id k0K1nCei028263 for ; Thu, 19 Jan 2006 20:49:12 -0500 Received: from biscayne-one-station.mit.edu (BISCAYNE-ONE-STATION.MIT.EDU [18.7.7.80]) by pch.mit.edu (8.12.8p2/8.12.8) with ESMTP id k0K1nBei028259 for ; Thu, 19 Jan 2006 20:49:11 -0500 Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103]) by biscayne-one-station.mit.edu (8.12.4/8.9.2) with ESMTP id k0K1n8HX021055; Thu, 19 Jan 2006 20:49:08 -0500 (EST) Received: from all-in-one.mit.edu (ALL-IN-ONE.MIT.EDU [18.18.1.71]) (authenticated bits=56) (User authenticated as raeburn@ATHENA.MIT.EDU) by outgoing.mit.edu (8.13.1/8.12.4) with ESMTP id k0K1n0eI005991 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Thu, 19 Jan 2006 20:49:01 -0500 (EST) Received: (from raeburn@localhost) by all-in-one.mit.edu (8.12.9) id k0K1n0Vg003115; Thu, 19 Jan 2006 20:49:00 -0500 To: krb5-bugs@MIT.EDU Subject: strftime formats in krb5_timestamp_to_sfstring From: Ken Raeburn Date: Thu, 19 Jan 2006 20:49:00 -0500 Message-Id: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam-Score: 1.217 X-Spam-Level: * (1.217) X-Spam-Flag: NO X-Scanned-BY: MIMEDefang 2.42 X-Beenthere: krb5-bugs-incoming@mailman.mit.edu X-Mailman-Version: 2.1.6 Precedence: list Sender: krb5-bugs-incoming-bounces@PCH.mit.edu Errors-To: krb5-bugs-incoming-bounces@PCH.mit.edu X-RT-Original-Encoding: us-ascii Content-Length: 1642 The strftime formats tried by this function, in order, are: "%c", /* Default locale-dependent date and time */ "%d %b %Y %T", /* dd mon yyyy hh:mm:ss */ "%x %X", /* locale-dependent short format */ "%d/%m/%Y %R" /* dd/mm/yyyy hh:mm */ If they all fail, we then try: sprintf(buffer, "%02d/%02d/%4d %02d:%02d", tmp->tm_mday, tmp->tm_mon+1, 1900+tmp->tm_year, tmp->tm_hour, tmp->tm_min); which agrees with the last strftime format, at least. Bug #1: We don't test for localtime(_r) failing. Granted, failure of that function seems pretty unlikely, but some email I've gotten from Lenny Foner shows he's got a weird situation where klist shows all the times as "01/00/00 00:00:00", which would be explained by localtime failing and a block of zeros readable at address 0 (NULL) (or by localtime_r filling in zeros, or localtime_r not doing anything and the stack slots containing zeros). With the recent leap second, there's probably been a lot of timezone-data tweaking lately. Bug #1a: Check the callers of krb5_timestamp_to_sfstring and make sure they check for errors, too. It looks like on a returned error, klist will simply fail to print anything out, instead of printing a broken string. Bug #2: The day/month/year format is ambiguous, and arguably wrong for US users. I'd suggest we go with ISO 8601 and RFC 3339 recommendations, specifically "yyyy-mm-dd HH:MM[:SS]", with either space or "T" separating the date and time. (I doubt we want the time zone data reported.) Also, check the various standards and other specs: Is %c always supported? Is there any reason for so many fallbacks? Ken