From: tb Date: Wed, 2 Nov 2022 10:04:41 +0000 (+0000) Subject: Fix x509_get_time() error checks X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=10093466eaf3052cdfa94fc7c6a221d271130d92;p=openbsd Fix x509_get_time() error checks Like most x509_* functions, x509_get_time() returns 0/1 on error/success, not -1/0. ok claudio job --- diff --git a/usr.sbin/rpki-client/aspa.c b/usr.sbin/rpki-client/aspa.c index c23054bc863..5ed3d9a8324 100644 --- a/usr.sbin/rpki-client/aspa.c +++ b/usr.sbin/rpki-client/aspa.c @@ -1,4 +1,4 @@ -/* $OpenBSD: aspa.c,v 1.5 2022/10/13 04:43:32 job Exp $ */ +/* $OpenBSD: aspa.c,v 1.6 2022/11/02 10:04:41 tb Exp $ */ /* * Copyright (c) 2022 Job Snijders * Copyright (c) 2022 Theo Buehler @@ -225,7 +225,7 @@ aspa_parse(X509 **x509, const char *fn, const unsigned char *der, size_t len) warnx("%s: X509_get0_notAfter failed", fn); goto out; } - if (x509_get_time(at, &p.res->expires) == -1) { + if (!x509_get_time(at, &p.res->expires)) { warnx("%s: ASN1_time_parse failed", fn); goto out; } diff --git a/usr.sbin/rpki-client/crl.c b/usr.sbin/rpki-client/crl.c index 25bb2b56556..b3df1b5e907 100644 --- a/usr.sbin/rpki-client/crl.c +++ b/usr.sbin/rpki-client/crl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: crl.c,v 1.16 2022/09/03 21:24:02 job Exp $ */ +/* $OpenBSD: crl.c,v 1.17 2022/11/02 10:04:41 tb Exp $ */ /* * Copyright (c) 2019 Kristaps Dzonsons * @@ -57,7 +57,7 @@ crl_parse(const char *fn, const unsigned char *der, size_t len) warnx("%s: X509_CRL_get0_lastUpdate failed", fn); goto out; } - if (x509_get_time(at, &crl->issued) == -1) { + if (!x509_get_time(at, &crl->issued)) { warnx("%s: ASN1_time_parse failed", fn); goto out; } @@ -67,7 +67,7 @@ crl_parse(const char *fn, const unsigned char *der, size_t len) warnx("%s: X509_CRL_get0_nextUpdate failed", fn); goto out; } - if (x509_get_time(at, &crl->expires) == -1) { + if (!x509_get_time(at, &crl->expires)) { warnx("%s: ASN1_time_parse failed", fn); goto out; } diff --git a/usr.sbin/rpki-client/roa.c b/usr.sbin/rpki-client/roa.c index 93a7cdabf72..982ab600cdd 100644 --- a/usr.sbin/rpki-client/roa.c +++ b/usr.sbin/rpki-client/roa.c @@ -1,4 +1,4 @@ -/* $OpenBSD: roa.c,v 1.53 2022/10/13 04:43:32 job Exp $ */ +/* $OpenBSD: roa.c,v 1.54 2022/11/02 10:04:41 tb Exp $ */ /* * Copyright (c) 2022 Theo Buehler * Copyright (c) 2019 Kristaps Dzonsons @@ -235,7 +235,7 @@ roa_parse(X509 **x509, const char *fn, const unsigned char *der, size_t len) warnx("%s: X509_get0_notAfter failed", fn); goto out; } - if (x509_get_time(at, &p.res->expires) == -1) { + if (!x509_get_time(at, &p.res->expires)) { warnx("%s: ASN1_time_parse failed", fn); goto out; } diff --git a/usr.sbin/rpki-client/rsc.c b/usr.sbin/rpki-client/rsc.c index edc727527c2..80adec93058 100644 --- a/usr.sbin/rpki-client/rsc.c +++ b/usr.sbin/rpki-client/rsc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rsc.c,v 1.16 2022/10/13 04:43:32 job Exp $ */ +/* $OpenBSD: rsc.c,v 1.17 2022/11/02 10:04:41 tb Exp $ */ /* * Copyright (c) 2022 Theo Buehler * Copyright (c) 2022 Job Snijders @@ -408,7 +408,7 @@ rsc_parse(X509 **x509, const char *fn, const unsigned char *der, size_t len) warnx("%s: X509_get0_notAfter failed", fn); goto out; } - if (x509_get_time(at, &p.res->expires) == -1) { + if (!x509_get_time(at, &p.res->expires)) { warnx("%s: ASN1_time_parse failed", fn); goto out; } diff --git a/usr.sbin/rpki-client/x509.c b/usr.sbin/rpki-client/x509.c index 5114b3ed7cc..05d0eddd0c7 100644 --- a/usr.sbin/rpki-client/x509.c +++ b/usr.sbin/rpki-client/x509.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x509.c,v 1.51 2022/10/24 10:26:59 tb Exp $ */ +/* $OpenBSD: x509.c,v 1.52 2022/11/02 10:04:41 tb Exp $ */ /* * Copyright (c) 2022 Theo Buehler * Copyright (c) 2021 Claudio Jeker @@ -377,7 +377,7 @@ x509_get_expire(X509 *x, const char *fn, time_t *tt) warnx("%s: X509_get0_notafter failed", fn); return 0; } - if (x509_get_time(at, tt) == -1) { + if (!x509_get_time(at, tt)) { warnx("%s: ASN1_time_parse failed", fn); return 0; }