From ab8d6e7bca67982dcb52272c67d437345bd7a9fb Mon Sep 17 00:00:00 2001 From: purplerain Date: Wed, 23 Aug 2023 09:28:13 +0000 Subject: [PATCH] sync code with last improvements from OpenBSD --- etc/skel/dot.version | 2 +- lib/libcrypto/cms/cms_lib.c | 39 ++++++++++++++++------------------ lib/libcrypto/ts/ts_rsp_sign.c | 11 ++++++---- lib/libutil/ber.c | 4 ++-- share/man/man5/bsd.port.mk.5 | 6 +++--- sys/arch/i386/isa/clock.c | 14 ++++++++---- sys/kern/kern_clock.c | 10 +++------ 7 files changed, 44 insertions(+), 42 deletions(-) diff --git a/etc/skel/dot.version b/etc/skel/dot.version index 263556c96..01cddfa26 100644 --- a/etc/skel/dot.version +++ b/etc/skel/dot.version @@ -1 +1 @@ -# SecBSD 1.3-7d242c1: Fri Aug 11 00:00:00 UTC 2023 (Tezcatlipoca) +# SecBSD 1.3-5b707e8: Wed Aug 23 00:00:00 UTC 2023 (Tezcatlipoca) diff --git a/lib/libcrypto/cms/cms_lib.c b/lib/libcrypto/cms/cms_lib.c index 37a11ba00..fc899437a 100644 --- a/lib/libcrypto/cms/cms_lib.c +++ b/lib/libcrypto/cms/cms_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cms_lib.c,v 1.19 2023/07/28 10:28:02 tb Exp $ */ +/* $OpenBSD: cms_lib.c,v 1.21 2023/08/22 08:59:44 tb Exp $ */ /* * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project. @@ -144,46 +144,43 @@ cms_content_bio(CMS_ContentInfo *cms) BIO * CMS_dataInit(CMS_ContentInfo *cms, BIO *icont) { - BIO *cmsbio, *cont; + BIO *cmsbio = NULL, *cont = NULL; - if (icont) - cont = icont; - else + if ((cont = icont) == NULL) cont = cms_content_bio(cms); - if (!cont) { + if (cont == NULL) { CMSerror(CMS_R_NO_CONTENT); - return NULL; + goto err; } - switch (OBJ_obj2nid(cms->contentType)) { + switch (OBJ_obj2nid(cms->contentType)) { case NID_pkcs7_data: return cont; - case NID_pkcs7_signed: - cmsbio = cms_SignedData_init_bio(cms); + if ((cmsbio = cms_SignedData_init_bio(cms)) == NULL) + goto err; break; - case NID_pkcs7_digest: - cmsbio = cms_DigestedData_init_bio(cms); + if ((cmsbio = cms_DigestedData_init_bio(cms)) == NULL) + goto err; break; - case NID_pkcs7_encrypted: - cmsbio = cms_EncryptedData_init_bio(cms); + if ((cmsbio = cms_EncryptedData_init_bio(cms)) == NULL) + goto err; break; - case NID_pkcs7_enveloped: - cmsbio = cms_EnvelopedData_init_bio(cms); + if ((cmsbio = cms_EnvelopedData_init_bio(cms)) == NULL) + goto err; break; - default: CMSerror(CMS_R_UNSUPPORTED_TYPE); - return NULL; + goto err; } - if (cmsbio) - return BIO_push(cmsbio, cont); + return BIO_push(cmsbio, cont); - if (!icont) + err: + if (cont != icont) BIO_free(cont); return NULL; diff --git a/lib/libcrypto/ts/ts_rsp_sign.c b/lib/libcrypto/ts/ts_rsp_sign.c index 84a699310..3013cffbc 100644 --- a/lib/libcrypto/ts/ts_rsp_sign.c +++ b/lib/libcrypto/ts/ts_rsp_sign.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ts_rsp_sign.c,v 1.31 2023/07/07 07:25:21 beck Exp $ */ +/* $OpenBSD: ts_rsp_sign.c,v 1.32 2023/08/22 08:09:36 tb Exp $ */ /* Written by Zoltan Glozik (zglozik@stones.com) for the OpenSSL * project 2002. */ @@ -98,18 +98,21 @@ static ASN1_GENERALIZEDTIME *TS_RESP_set_genTime_with_precision( static ASN1_INTEGER * def_serial_cb(struct TS_resp_ctx *ctx, void *data) { - ASN1_INTEGER *serial = ASN1_INTEGER_new(); + ASN1_INTEGER *serial; - if (!serial) + if ((serial = ASN1_INTEGER_new()) == NULL) goto err; if (!ASN1_INTEGER_set(serial, 1)) goto err; + return serial; -err: + err: + ASN1_INTEGER_free(serial); TSerror(ERR_R_MALLOC_FAILURE); TS_RESP_CTX_set_status_info(ctx, TS_STATUS_REJECTION, "Error during serial number generation."); + return NULL; } diff --git a/lib/libutil/ber.c b/lib/libutil/ber.c index 3a192748e..cd3bcd062 100644 --- a/lib/libutil/ber.c +++ b/lib/libutil/ber.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ber.c,v 1.24 2022/11/03 17:58:10 martijn Exp $ */ +/* $OpenBSD: ber.c,v 1.25 2023/08/22 12:50:27 gerhard Exp $ */ /* * Copyright (c) 2007, 2012 Reyk Floeter @@ -797,7 +797,7 @@ ober_scanf_elements(struct ber_element *ber, char *fmt, ...) if (ber->be_encoding != BER_TYPE_SEQUENCE && ber->be_encoding != BER_TYPE_SET) goto fail; - if (ber->be_sub == NULL || level >= _MAX_SEQ-1) + if (level >= _MAX_SEQ-1) goto fail; parent[++level] = ber; ber = ber->be_sub; diff --git a/share/man/man5/bsd.port.mk.5 b/share/man/man5/bsd.port.mk.5 index 42f9bf97b..77ba5ec17 100644 --- a/share/man/man5/bsd.port.mk.5 +++ b/share/man/man5/bsd.port.mk.5 @@ -1,4 +1,4 @@ -.\" $OpenBSD: bsd.port.mk.5,v 1.581 2023/08/21 12:54:04 espie Exp $ +.\" $OpenBSD: bsd.port.mk.5,v 1.582 2023/08/22 03:51:45 jsg Exp $ .\" .\" Copyright (c) 2000-2008 Marc Espie .\" @@ -24,7 +24,7 @@ .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: August 21 2023 $ +.Dd $Mdocdate: August 22 2023 $ .Dt BSD.PORT.MK 5 .Os .Sh NAME @@ -4124,7 +4124,7 @@ Holds the output of .Xr cksum 1 , using .Xr sha256 1 -for the port's ${DISTFILES*}, ${SUPDISFILES*} and ${PATCHFILES*}, +for the port's ${DISTFILES*}, ${SUPDISTFILES*} and ${PATCHFILES*}, as well as the sizes of these files. .It Pa ${DISTDIR}/${CHECKSUMFILES} Cache of normal distribution files for a given port. diff --git a/sys/arch/i386/isa/clock.c b/sys/arch/i386/isa/clock.c index 1472623d5..f9b7c96a8 100644 --- a/sys/arch/i386/isa/clock.c +++ b/sys/arch/i386/isa/clock.c @@ -1,4 +1,4 @@ -/* $OpenBSD: clock.c,v 1.65 2023/07/25 18:16:20 cheloha Exp $ */ +/* $OpenBSD: clock.c,v 1.66 2023/08/22 17:13:22 cheloha Exp $ */ /* $NetBSD: clock.c,v 1.39 1996/05/12 23:11:54 mycroft Exp $ */ /*- @@ -430,10 +430,16 @@ i8254_initclocks(void) clockintr_cpu_init(NULL); - /* When using i8254 for clock, we also use the rtc for profclock */ - (void)isa_intr_establish(NULL, 0, IST_PULSE, IPL_CLOCK, + /* + * When using i8254 for clock, we also use the rtc for profclock. + * + * These IRQs are not MP-safe, but it is harmless to lie about it + * because we cannot reach this point unless we are only booting + * a single CPU. + */ + (void)isa_intr_establish(NULL, 0, IST_PULSE, IPL_CLOCK | IPL_MPSAFE, clockintr, 0, "clock"); - (void)isa_intr_establish(NULL, 8, IST_PULSE, IPL_STATCLOCK, + (void)isa_intr_establish(NULL, 8, IST_PULSE, IPL_STATCLOCK | IPL_MPSAFE, rtcintr, 0, "rtc"); rtcstart(); /* start the mc146818 clock */ diff --git a/sys/kern/kern_clock.c b/sys/kern/kern_clock.c index 06c0d5f4a..4c2175e8c 100644 --- a/sys/kern/kern_clock.c +++ b/sys/kern/kern_clock.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_clock.c,v 1.113 2023/08/12 13:19:28 miod Exp $ */ +/* $OpenBSD: kern_clock.c,v 1.114 2023/08/22 13:46:20 jsg Exp $ */ /* $NetBSD: kern_clock.c,v 1.34 1996/06/09 04:51:03 briggs Exp $ */ /*- @@ -111,13 +111,9 @@ initclocks(void) void hardclock(struct clockframe *frame) { -#if defined(MULTIPROCESSOR) || defined(__hppa__) /* XXX */ - struct cpu_info *ci = curcpu(); -#endif - #if NDT > 0 DT_ENTER(profile, NULL); - if (CPU_IS_PRIMARY(ci)) + if (CPU_IS_PRIMARY(curcpu())) DT_ENTER(interval, NULL); #endif @@ -125,7 +121,7 @@ hardclock(struct clockframe *frame) * If we are not the primary CPU, we're not allowed to do * any more work. */ - if (CPU_IS_PRIMARY(ci) == 0) + if (CPU_IS_PRIMARY(curcpu()) == 0) return; tc_ticktock();