summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortb <>2024-05-03 18:29:43 +0000
committertb <>2024-05-03 18:29:43 +0000
commit603c25396734cafcf5052772d80d74998ed629a3 (patch)
tree1172459a3de48809914aa8b638f88e50cb6de348
parent20c5da2aca77dcbe946a722d85bfe67619df1130 (diff)
downloadopenbsd-603c25396734cafcf5052772d80d74998ed629a3.tar.gz
openbsd-603c25396734cafcf5052772d80d74998ed629a3.tar.bz2
openbsd-603c25396734cafcf5052772d80d74998ed629a3.zip
Intercept a NULL s early in ASN1_TIME_set_string_internal()
If s is NULL, the only thing the tm_to_*() functions do is a check that a GeneralizedTime has a four digit year (between 0000 and 9999) and a UTCTime has a year between 1950 and 2050. These checks are already done in ASN1_TIME_parse() itself: the century is 100 times a two-digit value (or 19 in the UTCTime case) plus another two-digit value. ok beck
-rw-r--r--src/lib/libcrypto/asn1/a_time_tm.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/lib/libcrypto/asn1/a_time_tm.c b/src/lib/libcrypto/asn1/a_time_tm.c
index d729af5f65..c13b9b5064 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.40 2024/05/03 18:22:26 tb Exp $ */ 1/* $OpenBSD: a_time_tm.c,v 1.41 2024/05/03 18:29:43 tb Exp $ */
2/* 2/*
3 * Copyright (c) 2015 Bob Beck <beck@openbsd.org> 3 * Copyright (c) 2015 Bob Beck <beck@openbsd.org>
4 * 4 *
@@ -325,6 +325,11 @@ ASN1_TIME_set_string_internal(ASN1_TIME *s, const char *str, int mode)
325 325
326 if (ASN1_time_parse(str, strlen(str), &tm, mode) == -1) 326 if (ASN1_time_parse(str, strlen(str), &tm, mode) == -1)
327 return 0; 327 return 0;
328
329 /* Only check str's format, as documented. */
330 if (s == NULL)
331 return 1;
332
328 switch (mode) { 333 switch (mode) {
329 case V_ASN1_UTCTIME: 334 case V_ASN1_UTCTIME:
330 return tm_to_utctime(&tm, s); 335 return tm_to_utctime(&tm, s);