]> www.infradead.org Git - users/jedix/linux-maple.git/commit
X.509: Fix leap year handling again
authorDavid Howells <dhowells@redhat.com>
Wed, 24 Feb 2016 14:37:15 +0000 (14:37 +0000)
committerChuck Anderson <chuck.anderson@oracle.com>
Thu, 26 May 2016 22:46:11 +0000 (15:46 -0700)
commitdd0023c7e9d01028d45334473b5a9e8f7292c09d
tree47db0b3e401abcfb363bce1e98dde8b902b40db3
parentba548675f4829cc5fe293aa0fe4f29c016ba13b3
X.509: Fix leap year handling again

Orabug: 23331075

[ Upstream commit ac4cbedfdf55455b4c447f17f0fa027dbf02b2a6 ]

There are still a couple of minor issues in the X.509 leap year handling:

 (1) To avoid doing a modulus-by-400 in addition to a modulus-by-100 when
     determining whether the year is a leap year or not, I divided the year
     by 100 after doing the modulus-by-100, thereby letting the compiler do
     one instruction for both, and then did a modulus-by-4.

     Unfortunately, I then passed the now-modified year value to mktime64()
     to construct a time value.

     Since this isn't a fast path and since mktime64() does a bunch of
     divisions, just condense down to "% 400".  It's also easier to read.

 (2) The default month length for any February where the year doesn't
     divide by four exactly is obtained from the month_length[] array where
     the value is 29, not 28.

     This is fixed by altering the table.

Reported-by: Rudolf Polzer <rpolzer@google.com>
Signed-off-by: David Howells <dhowells@redhat.com>
Acked-by: David Woodhouse <David.Woodhouse@intel.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
cc: stable@vger.kernel.org
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
(cherry picked from commit e62c5259a62f3da2a911f8fe6275dbf43d3b624f)

Signed-off-by: Dan Duval <dan.duval@oracle.com>
crypto/asymmetric_keys/x509_cert_parser.c