From 5a25525b2e74caeb927a262d018134b95c2e70aa Mon Sep 17 00:00:00 2001 From: Eric Blankenhorn Date: Wed, 31 Aug 2022 13:23:09 -0500 Subject: [PATCH] Check return from call to wc_Time --- wolfcrypt/src/asn.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/wolfcrypt/src/asn.c b/wolfcrypt/src/asn.c index 6931444a3..dec924ad6 100644 --- a/wolfcrypt/src/asn.c +++ b/wolfcrypt/src/asn.c @@ -13727,6 +13727,12 @@ int wc_ValidateDate(const byte* date, byte format, int dateType) (void)tmpTime; ltime = wc_Time(0); + if (ltime < 0){ + /* A negative response here could be due to a 32-bit time_t + * where the year is 2038 or later. */ + WOLFSSL_MSG("wc_Time failed to return a valid value"); + return 0; + } #ifdef WOLFSSL_BEFORE_DATE_CLOCK_SKEW if (dateType == BEFORE) {