Linux kernel -stable discussions
 help / color / mirror / Atom feed
From: David Howells <dhowells@redhat.com>
To: keyrings@vger.kernel.org
Cc: Arnd Bergmann <arnd@arndb.de>,
	linux-kernel@vger.kernel.org, stable@vger.kernel.org,
	dhowells@redhat.com, linux-security-module@vger.kernel.org,
	John Stultz <john.stultz@linaro.org>
Subject: [PATCH 4/5] Handle both ISO 8601 encodings of midnight in mktime64()
Date: Fri, 18 Dec 2015 00:02:17 +0000	[thread overview]
Message-ID: <20151218000217.29483.43671.stgit@warthog.procyon.org.uk> (raw)
In-Reply-To: <20151218000148.29483.67155.stgit@warthog.procyon.org.uk>

ISO 8601 format dates permit two different encodings of midnight - 00:00:00
and 24:00:00 - the first is midnight today and the second is midnight
tomorrow and is exactly equivalent to the first with tomorrow's date.

Note that the implementation of mktime64() doesn't actually need to be
changed to handle this - the multiplication by 3600 of the hour will take
care of it automatically.  However, we should document that this handling
is done in mktime64() and is thus in a common place in the kernel.

This handling is required for X.509 certificate parsing which can be given
ISO 8601 dates.

Signed-off-by: David Howells <dhowells@redhat.com>
cc: John Stultz <john.stultz@linaro.org>
cc: Arnd Bergmann <arnd@arndb.de>
cc: stable@vger.kernel.org
---

 kernel/time/time.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/kernel/time/time.c b/kernel/time/time.c
index 1858b10602f5..56e7ada38471 100644
--- a/kernel/time/time.c
+++ b/kernel/time/time.c
@@ -326,6 +326,9 @@ EXPORT_SYMBOL(timespec_trunc);
  * A leap second can be indicated by calling this function with sec as
  * 60 (allowable under ISO 8601).  The leap second is treated the same
  * as the preceding second since they don't exist in UNIX time.
+ *
+ * An encoding of midnight at the end of the day as 24:00:00 - ie. midnight
+ * tomorrow - (allowable under ISO 8601) is supported.
  */
 time64_t mktime64(unsigned int year0, unsigned int mon0,
 		  unsigned int day, unsigned int hour,
@@ -346,7 +349,7 @@ time64_t mktime64(unsigned int year0, unsigned int mon0,
 	return ((((time64_t)
 		  (year/4 - year/100 + year/400 + 367*mon/12 + day) +
 		  year*365 - 719499
-	    )*24 + hour /* now have hours */
+	    )*24 + hour /* now have hours - midnight tomorrow handled here */
 	  )*60 + min /* now have minutes */
 	)*60 + sec; /* finally seconds */
 }


  parent reply	other threads:[~2015-12-18  0:02 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20151218000148.29483.67155.stgit@warthog.procyon.org.uk>
2015-12-18  0:01 ` [PATCH 1/5] X.509: Fix leap year handling again David Howells
2015-12-18  0:02 ` [PATCH 2/5] Handle leap seconds in mktime64() David Howells
2015-12-18  9:09   ` Arnd Bergmann
2015-12-18  0:02 ` [PATCH 3/5] X.509: Support leap seconds David Howells
2015-12-18  9:10   ` Arnd Bergmann
2015-12-18  0:02 ` David Howells [this message]
2015-12-18  9:11   ` [PATCH 4/5] Handle both ISO 8601 encodings of midnight in mktime64() Arnd Bergmann
2015-12-18  0:02 ` [PATCH 5/5] X.509: Handle midnight alternative notation in GeneralizedTime David Howells

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20151218000217.29483.43671.stgit@warthog.procyon.org.uk \
    --to=dhowells@redhat.com \
    --cc=arnd@arndb.de \
    --cc=john.stultz@linaro.org \
    --cc=keyrings@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox