diff options
| author | tb <> | 2020-12-16 18:35:59 +0000 |
|---|---|---|
| committer | tb <> | 2020-12-16 18:35:59 +0000 |
| commit | 25fba608b24a7bf868f7cd6c3cb19e964a7ffcd4 (patch) | |
| tree | c14be4d2e2975a01d1db395a96d115e44073875b /src | |
| parent | cb6846b13d05fa51adb1c44b76664e35c71791b8 (diff) | |
| download | openbsd-25fba608b24a7bf868f7cd6c3cb19e964a7ffcd4.tar.gz openbsd-25fba608b24a7bf868f7cd6c3cb19e964a7ffcd4.tar.bz2 openbsd-25fba608b24a7bf868f7cd6c3cb19e964a7ffcd4.zip | |
Avoid potential use of uninitialized in ASN1_time_parse
When parsing an UTCTime into a struct tm that wasn't cleared by the caller,
the years would be added to the already present value, which could give an
incorrect result. This is an issue in ASN1_UTCTIME_cmp_time_t(), which is
practically unused. Fix this by always zeroing the passed struct tm.
Issue reported by Olivier Taïbi, thanks!
ok jsing
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/libcrypto/asn1/a_time_tm.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/lib/libcrypto/asn1/a_time_tm.c b/src/lib/libcrypto/asn1/a_time_tm.c index b6e22cbd27..33959afe63 100644 --- a/src/lib/libcrypto/asn1/a_time_tm.c +++ b/src/lib/libcrypto/asn1/a_time_tm.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: a_time_tm.c,v 1.15 2018/04/25 11:48:21 tb Exp $ */ | 1 | /* $OpenBSD: a_time_tm.c,v 1.16 2020/12/16 18:35:59 tb Exp $ */ |
| 2 | /* | 2 | /* |
| 3 | * Copyright (c) 2015 Bob Beck <beck@openbsd.org> | 3 | * Copyright (c) 2015 Bob Beck <beck@openbsd.org> |
| 4 | * | 4 | * |
| @@ -163,10 +163,9 @@ ASN1_time_parse(const char *bytes, size_t len, struct tm *tm, int mode) | |||
| 163 | return (-1); | 163 | return (-1); |
| 164 | 164 | ||
| 165 | lt = tm; | 165 | lt = tm; |
| 166 | if (lt == NULL) { | 166 | if (lt == NULL) |
| 167 | memset(<m, 0, sizeof(ltm)); | ||
| 168 | lt = <m; | 167 | lt = <m; |
| 169 | } | 168 | memset(lt, 0, sizeof(*lt)); |
| 170 | 169 | ||
| 171 | /* Timezone is required and must be GMT (Zulu). */ | 170 | /* Timezone is required and must be GMT (Zulu). */ |
| 172 | if (bytes[len - 1] != 'Z') | 171 | if (bytes[len - 1] != 'Z') |
