summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/x509/x509_vfy.c
diff options
context:
space:
mode:
authortb <>2023-11-13 10:33:00 +0000
committertb <>2023-11-13 10:33:00 +0000
commit934fbb57cd6b0549754b91dafe57b3f63d754fad (patch)
tree1c717e972f99cdd8af5ad4b2f0df134f540e1131 /src/lib/libcrypto/x509/x509_vfy.c
parent54397579be0eaf2a12e40fad1823cd1ce3d1f6fc (diff)
downloadopenbsd-934fbb57cd6b0549754b91dafe57b3f63d754fad.tar.gz
openbsd-934fbb57cd6b0549754b91dafe57b3f63d754fad.tar.bz2
openbsd-934fbb57cd6b0549754b91dafe57b3f63d754fad.zip
Eliminate the timegm(3) dependency in libcrypto
timegm(3) is not available on some operating systems we support in portable. We currently use musl's implementation, for which gcc-13 decided to emit warnings (which seem incorrect in general and are irrelevant in this case anyway). Instead of patching this up and diverge from upstream, we can avoid reports about compiler warnings by simply not depending on this function. Rework the caching of notBefore and notAfter by replacing timegm(3) with asn1_time_tm_to_time_t(3). Also make this API properly error checkable since at the time x509v3_cache_extensions(3) is called, nothing is known about the cert, in particular not whether it isn't malformed one way or the other. suggested by and ok beck
Diffstat (limited to 'src/lib/libcrypto/x509/x509_vfy.c')
-rw-r--r--src/lib/libcrypto/x509/x509_vfy.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/src/lib/libcrypto/x509/x509_vfy.c b/src/lib/libcrypto/x509/x509_vfy.c
index c4ba3d5b14..6c0ad78ec8 100644
--- a/src/lib/libcrypto/x509/x509_vfy.c
+++ b/src/lib/libcrypto/x509/x509_vfy.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: x509_vfy.c,v 1.125 2023/06/08 22:02:40 beck Exp $ */ 1/* $OpenBSD: x509_vfy.c,v 1.126 2023/11/13 10:33:00 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -1969,8 +1969,7 @@ X509_cmp_time_internal(const ASN1_TIME *ctm, time_t *cmp_time, int is_notafter)
1969 else 1969 else
1970 compare = *cmp_time; 1970 compare = *cmp_time;
1971 1971
1972 if ((cert_time = x509_verify_asn1_time_to_time_t(ctm, is_notafter)) == 1972 if (!x509_verify_asn1_time_to_time_t(ctm, is_notafter, &cert_time))
1973 -1)
1974 return 0; /* invalid time */ 1973 return 0; /* invalid time */
1975 1974
1976 if (cert_time <= compare) 1975 if (cert_time <= compare)