Commit 7650cb80 authored by David Howells's avatar David Howells

X.509: Handle midnight alternative notation in GeneralizedTime

The ASN.1 GeneralizedTime object carries an ISO 8601 format date and time.
The time is permitted to show midnight as 00:00 or 24:00 (the latter being
equivalent of 00:00 of the following day).

The permitted value is checked in x509_decode_time() but the actual
handling is left to mktime64().

Without this patch, certain X.509 certificates will be rejected and could
lead to an unbootable kernel.

Note that with this patch we also permit any 24:mm:ss time and extend this
to UTCTime, which whilst not strictly correct don't permit much leeway in
fiddling date strings.
Reported-by: default avatarRudolf Polzer <rpolzer@google.com>
Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
Acked-by: default avatarArnd Bergmann <arnd@arndb.de>
cc: David Woodhouse <David.Woodhouse@intel.com>
cc: John Stultz <john.stultz@linaro.org>
parent da02559c
...@@ -525,7 +525,7 @@ int x509_decode_time(time64_t *_t, size_t hdrlen, ...@@ -525,7 +525,7 @@ int x509_decode_time(time64_t *_t, size_t hdrlen,
} }
if (day < 1 || day > mon_len || if (day < 1 || day > mon_len ||
hour > 23 || hour > 24 || /* ISO 8601 permits 24:00:00 as midnight tomorrow */
min > 59 || min > 59 ||
sec > 60) /* ISO 8601 permits leap seconds [X.680 46.3] */ sec > 60) /* ISO 8601 permits leap seconds [X.680 46.3] */
goto invalid_time; goto invalid_time;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment