From 1216bb55373f09705b42ad1e3bc1332f99ea5ae9 Mon Sep 17 00:00:00 2001 From: purplerain Date: Sat, 10 Feb 2024 13:29:41 +0000 Subject: [PATCH] sync with OpenBSD -current --- distrib/arm64/iso/Makefile | 4 ++-- lib/libz/deflate.c | 3 ++- lib/libz/gzguts.h | 11 +++-------- lib/libz/gzlib.c | 28 +++++++++++++++------------- lib/libz/gzread.c | 3 ++- sys/kern/kern_sysctl.c | 11 +++++------ sys/lib/libz/deflate.c | 3 ++- usr.bin/cu/cu.c | 6 +++--- usr.bin/ssh/sshd/Makefile | 4 +++- usr.sbin/vmd/mmio.c | 8 +++++--- 10 files changed, 42 insertions(+), 39 deletions(-) diff --git a/distrib/arm64/iso/Makefile b/distrib/arm64/iso/Makefile index 45f84aea2..5d54edd77 100644 --- a/distrib/arm64/iso/Makefile +++ b/distrib/arm64/iso/Makefile @@ -1,7 +1,7 @@ -# $OpenBSD: Makefile,v 1.8 2023/10/26 14:27:01 deraadt Exp $ +# $OpenBSD: Makefile,v 1.9 2024/02/10 16:47:46 deraadt Exp $ FS= install${OSrev}.img -FSSIZE= 1126400 +FSSIZE= 1136400 CDROM= install${OSrev}.iso MOUNT_POINT= /mnt diff --git a/lib/libz/deflate.c b/lib/libz/deflate.c index 1f0004a70..623119b1f 100644 --- a/lib/libz/deflate.c +++ b/lib/libz/deflate.c @@ -1631,7 +1631,8 @@ local block_state deflate_stored(deflate_state *s, int flush) { * possible. If flushing, copy the remaining available input to next_out as * stored blocks, if there is enough space. */ - unsigned len, left, have, last = 0; + int last = 0; + unsigned len, left, have; unsigned used = s->strm->avail_in; do { /* Set len to the maximum size block that we can copy directly with the diff --git a/lib/libz/gzguts.h b/lib/libz/gzguts.h index bd0a6fe21..a6485ab7e 100644 --- a/lib/libz/gzguts.h +++ b/lib/libz/gzguts.h @@ -20,6 +20,9 @@ #if defined(_WIN32) && !defined(_CRT_SECURE_NO_WARNINGS) # define _CRT_SECURE_NO_WARNINGS #endif +#if defined(_WIN32) && !defined(_CRT_NONSTDC_NO_DEPRECATE) +# define _CRT_NONSTDC_NO_DEPRECATE +#endif #include #include "zlib.h" @@ -40,7 +43,6 @@ #if defined(__TURBOC__) || defined(_MSC_VER) || defined(_WIN32) # include -# include # include #endif @@ -48,13 +50,6 @@ # define WIDECHAR #endif -#if defined(_WIN32) || defined(WINAPI_FAMILY) -# define open _open -# define read _read -# define write _write -# define close _close -#endif - #ifdef NO_DEFLATE /* for compatibility with old definition */ # define NO_GZCOMPRESS #endif diff --git a/lib/libz/gzlib.c b/lib/libz/gzlib.c index 05a9ae519..e485a27bf 100644 --- a/lib/libz/gzlib.c +++ b/lib/libz/gzlib.c @@ -5,15 +5,17 @@ #include "gzguts.h" -#if defined(_WIN32) && !defined(__BORLANDC__) +#if defined(UNDER_CE) +# define LSEEK _wcelseek +#elif defined(__DJGPP__) +# define LSEEK llseek +#elif defined(_WIN32) && !defined(__BORLANDC__) # define LSEEK _lseeki64 -#else -#if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0 +#elif defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0 # define LSEEK lseek64 #else # define LSEEK lseek #endif -#endif #if defined UNDER_CE @@ -52,8 +54,7 @@ char ZLIB_INTERNAL *gz_strwinerror(DWORD error) { msgbuf[chars] = 0; } - z_size_t len; - wcstombs_s(&len, buf, sizeof(buf), msgbuf, chars + 1); + wcstombs(buf, msgbuf, chars + 1); // assumes buf is big enough LocalFree(msgbuf); } else { @@ -180,10 +181,8 @@ local gzFile gz_open(const void *path, int fd, const char *mode) { /* save the path name for error messages */ #ifdef WIDECHAR - if (fd == -2) { - if (wcstombs_s(&len, NULL, 0, path, 0) != 0) - len = 0; - } + if (fd == -2) + len = wcstombs(NULL, path, 0); else #endif len = strlen((const char *)path); @@ -193,18 +192,21 @@ local gzFile gz_open(const void *path, int fd, const char *mode) { return NULL; } #ifdef WIDECHAR - if (fd == -2) + if (fd == -2) { if (len) - wcstombs_s(&len, state->path, len + 1, path, len + 1); + wcstombs(state->path, path, len + 1); else *(state->path) = 0; + } else #endif + { #if !defined(NO_snprintf) && !defined(NO_vsnprintf) (void)snprintf(state->path, len + 1, "%s", (const char *)path); #else strcpy(state->path, path); #endif + } /* compute the flags for open() */ oflag = @@ -232,7 +234,7 @@ local gzFile gz_open(const void *path, int fd, const char *mode) { state->fd = open((const char *)path, oflag, 0666); #ifdef WIDECHAR else if (fd == -2) - _wsopen_s(&state->fd, path, oflag, _SH_DENYNO, _S_IREAD | _S_IWRITE); + state->fd = _wopen(path, oflag, _S_IREAD | _S_IWRITE); #endif else state->fd = fd; diff --git a/lib/libz/gzread.c b/lib/libz/gzread.c index 4168cbc88..2d4ca4290 100644 --- a/lib/libz/gzread.c +++ b/lib/libz/gzread.c @@ -374,7 +374,8 @@ int ZEXPORT gzread(gzFile file, voidp buf, unsigned len) { } /* -- see zlib.h -- */ -z_size_t ZEXPORT gzfread(voidp buf, z_size_t size, z_size_t nitems, gzFile file) { +z_size_t ZEXPORT gzfread(voidp buf, z_size_t size, z_size_t nitems, + gzFile file) { z_size_t len; gz_statep state; diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c index fab73757e..49ba628c9 100644 --- a/sys/kern/kern_sysctl.c +++ b/sys/kern/kern_sysctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_sysctl.c,v 1.424 2024/01/19 01:43:27 bluhm Exp $ */ +/* $OpenBSD: kern_sysctl.c,v 1.425 2024/02/10 15:28:16 deraadt Exp $ */ /* $NetBSD: kern_sysctl.c,v 1.17 1996/05/20 17:49:05 mrg Exp $ */ /*- @@ -771,14 +771,13 @@ hw_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp, case HW_ALLOWPOWERDOWN: return (sysctl_securelevel_int(oldp, oldlenp, newp, newlen, &allowpowerdown)); -#if NUCOM > 0 case HW_UCOMNAMES: { - const char *str = sysctl_ucominit(); - if (str == NULL) - return EINVAL; + const char *str = ""; +#if NUCOM > 0 + str = sysctl_ucominit(); +#endif /* NUCOM > 0 */ return (sysctl_rdstring(oldp, oldlenp, newp, str)); } -#endif /* NUCOM > 0 */ #ifdef __HAVE_CPU_TOPOLOGY case HW_SMT: return (sysctl_hwsmt(oldp, oldlenp, newp, newlen)); diff --git a/sys/lib/libz/deflate.c b/sys/lib/libz/deflate.c index cf8a65d93..598d5a2b2 100644 --- a/sys/lib/libz/deflate.c +++ b/sys/lib/libz/deflate.c @@ -1633,7 +1633,8 @@ local block_state deflate_stored(deflate_state *s, int flush) { * possible. If flushing, copy the remaining available input to next_out as * stored blocks, if there is enough space. */ - unsigned len, left, have, last = 0; + int last = 0; + unsigned len, left, have; unsigned used = s->strm->avail_in; do { /* Set len to the maximum size block that we can copy directly with the diff --git a/usr.bin/cu/cu.c b/usr.bin/cu/cu.c index b6e7a4769..323f5eea5 100644 --- a/usr.bin/cu/cu.c +++ b/usr.bin/cu/cu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cu.c,v 1.30 2023/12/21 11:25:38 jca Exp $ */ +/* $OpenBSD: cu.c,v 1.31 2024/02/10 15:29:04 deraadt Exp $ */ /* * Copyright (c) 2012 Nicholas Marriott @@ -488,13 +488,13 @@ get_ucomnames(void) size = 0; for (;;) { if (sysctl(mib, 2, NULL, &size, NULL, 0) == -1 || size == 0) - err(1, "hw.ucomnames"); + return NULL; if ((names = realloc(names, size)) == NULL) err(1, NULL); if (sysctl(mib, 2, names, &size, NULL, 0) != -1) break; if (errno != ENOMEM) - err(1, "hw.ucomnames"); + return NULL; } return names; } diff --git a/usr.bin/ssh/sshd/Makefile b/usr.bin/ssh/sshd/Makefile index 03d938e56..5cf81da1c 100644 --- a/usr.bin/ssh/sshd/Makefile +++ b/usr.bin/ssh/sshd/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.108 2023/01/18 20:56:36 deraadt Exp $ +# $OpenBSD: Makefile,v 1.109 2024/02/10 11:28:52 naddy Exp $ .PATH: ${.CURDIR}/.. @@ -50,6 +50,8 @@ DPADD+= ${LIBZ} # The random relink kit, used on OpenBSD by /etc/rc +CLEANFILES+= Makefile.relink sshd.tar + Makefile.relink: ${.CURDIR}/../Makefile.inc ${.CURDIR}/Makefile # XXX assume a concatenation of these is OK cat ${.CURDIR}/../Makefile.inc ${.CURDIR}/Makefile > Makefile.relink diff --git a/usr.sbin/vmd/mmio.c b/usr.sbin/vmd/mmio.c index 2de5dcefa..c5a189d5b 100644 --- a/usr.sbin/vmd/mmio.c +++ b/usr.sbin/vmd/mmio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mmio.c,v 1.2 2022/12/28 21:30:19 jmc Exp $ */ +/* $OpenBSD: mmio.c,v 1.3 2024/02/10 12:31:16 dv Exp $ */ /* * Copyright (c) 2022 Dave Voutila @@ -473,7 +473,7 @@ static enum decode_result decode_modrm(struct x86_decode_state *state, struct x86_insn *insn) { enum decode_result res; - uint8_t byte; + uint8_t byte = 0; if (!is_valid_state(state, __func__) || insn == NULL) return (DECODE_ERROR); @@ -486,8 +486,10 @@ decode_modrm(struct x86_decode_state *state, struct x86_insn *insn) case OP_ENC_RM: case OP_ENC_MI: res = next_byte(state, &byte); - if (res == DECODE_ERROR) + if (res == DECODE_ERROR) { log_warnx("%s: failed to get modrm byte", __func__); + break; + } insn->insn_modrm = byte; insn->insn_modrm_valid = 1; break;