sync with OpenBSD -current

This commit is contained in:
purplerain 2024-04-26 00:31:56 +00:00
parent 87d00f0a9c
commit f41d8bece2
Signed by: purplerain
GPG Key ID: F42C07F07E2E35B7
26 changed files with 342 additions and 151 deletions

View File

@ -1147,7 +1147,6 @@
./usr/include/openssl/opensslv.h
./usr/include/openssl/ossl_typ.h
./usr/include/openssl/pem.h
./usr/include/openssl/pem2.h
./usr/include/openssl/pkcs12.h
./usr/include/openssl/pkcs7.h
./usr/include/openssl/poly1305.h

View File

@ -1,4 +1,4 @@
# $OpenBSD: Makefile,v 1.193 2024/04/15 15:55:01 tb Exp $
# $OpenBSD: Makefile,v 1.194 2024/04/25 16:14:00 tb Exp $
LIB= crypto
LIBREBUILD=y
@ -707,7 +707,6 @@ HDRS=\
${LCRYPTO_SRC}/opensslv.h \
${LCRYPTO_SRC}/ossl_typ.h \
${LCRYPTO_SRC}/pem/pem.h \
${LCRYPTO_SRC}/pem/pem2.h \
${LCRYPTO_SRC}/pkcs12/pkcs12.h \
${LCRYPTO_SRC}/pkcs7/pkcs7.h \
${LCRYPTO_SRC}/poly1305/poly1305.h \

View File

@ -1,71 +0,0 @@
/* $OpenBSD: pem2.h,v 1.5 2014/06/12 15:49:30 deraadt Exp $ */
/* ====================================================================
* Copyright (c) 1999 The OpenSSL Project. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. All advertising materials mentioning features or use of this
* software must display the following acknowledgment:
* "This product includes software developed by the OpenSSL Project
* for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
*
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
* endorse or promote products derived from this software without
* prior written permission. For written permission, please contact
* licensing@OpenSSL.org.
*
* 5. Products derived from this software may not be called "OpenSSL"
* nor may "OpenSSL" appear in their names without prior written
* permission of the OpenSSL Project.
*
* 6. Redistributions of any form whatsoever must retain the following
* acknowledgment:
* "This product includes software developed by the OpenSSL Project
* for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
*
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
* ====================================================================
*
* This product includes cryptographic software written by Eric Young
* (eay@cryptsoft.com). This product includes software written by Tim
* Hudson (tjh@cryptsoft.com).
*
*/
/*
* This header only exists to break a circular dependency between pem and err
* Ben 30 Jan 1999.
*/
#ifdef __cplusplus
extern "C" {
#endif
#ifndef HEADER_PEM_H
void ERR_load_PEM_strings(void);
#endif
#ifdef __cplusplus
}
#endif

View File

@ -1,4 +1,4 @@
# $OpenBSD: Makefile,v 1.56 2024/03/29 07:13:38 joshua Exp $
# $OpenBSD: Makefile,v 1.57 2024/04/25 14:27:29 jsing Exp $
SUBDIR += aead
SUBDIR += aes
@ -14,6 +14,7 @@ SUBDIR += cast
SUBDIR += certs
SUBDIR += chacha
SUBDIR += cms
SUBDIR += crypto
SUBDIR += ct
SUBDIR += curve25519
SUBDIR += des

View File

@ -0,0 +1,12 @@
# $OpenBSD: Makefile,v 1.1 2024/04/25 14:27:29 jsing Exp $
PROG = crypto_test
DPADD+= ${LIBCRYPTO}
WARNINGS= Yes
LDFLAGS+= -lcrypto
CFLAGS+= -DLIBRESSL_INTERNAL
CFLAGS+= -Wall -Wundef -Werror
CFLAGS+= -I${.CURDIR}/../../../../lib/libcrypto
.include <bsd.regress.mk>

View File

@ -0,0 +1,97 @@
/* $OpenBSD: crypto_test.c,v 1.1 2024/04/25 14:27:29 jsing Exp $ */
/*
* Copyright (c) 2024 Joel Sing <jsing@openbsd.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <stdint.h>
#include <stdio.h>
#include "crypto_internal.h"
static int
test_ct_u8(void)
{
uint8_t i, j, mask;
int failed = 1;
i = 0;
do {
if ((i != 0) != crypto_ct_ne_zero_u8(i)) {
fprintf(stderr, "FAIL: crypto_ct_ne_zero_u8(%d) = %d, "
"want %d\n", i, crypto_ct_ne_zero_u8(i), i != 0);
goto failure;
}
mask = (i != 0) ? 0xff : 0x00;
if (mask != crypto_ct_ne_zero_mask_u8(i)) {
fprintf(stderr, "FAIL: crypto_ct_ne_zero_mask_u8(%d) = %x, "
"want %x\n", i, crypto_ct_ne_zero_mask_u8(i), mask);
goto failure;
}
if ((i == 0) != crypto_ct_eq_zero_u8(i)) {
fprintf(stderr, "FAIL: crypto_ct_eq_zero_u8(%d) = %d, "
"want %d\n", i, crypto_ct_ne_zero_u8(i), i != 0);
goto failure;
}
mask = (i == 0) ? 0xff : 0x00;
if (mask != crypto_ct_eq_zero_mask_u8(i)) {
fprintf(stderr, "FAIL: crypto_ct_eq_zero_mask_u8(%d) = %x, "
"want %x\n", i, crypto_ct_ne_zero_mask_u8(i), mask);
goto failure;
}
j = 0;
do {
if ((i != j) != crypto_ct_ne_u8(i, j)) {
fprintf(stderr, "FAIL: crypto_ct_ne_u8(%d, %d) = %d, "
"want %d\n", i, j, crypto_ct_ne_u8(i, j), i != j);
goto failure;
}
mask = (i != j) ? 0xff : 0x00;
if (mask != crypto_ct_ne_mask_u8(i, j)) {
fprintf(stderr, "FAIL: crypto_ct_ne_mask_u8(%d, %d) = %x, "
"want %x\n", i, j, crypto_ct_ne_mask_u8(i, j), mask);
goto failure;
}
if ((i == j) != crypto_ct_eq_u8(i, j)) {
fprintf(stderr, "FAIL: crypto_ct_eq_u8(%d, %d) = %d, "
"want %d\n", i, j, crypto_ct_eq_u8(i, j), i != j);
goto failure;
}
mask = (i == j) ? 0xff : 0x00;
if (mask != crypto_ct_eq_mask_u8(i, j)) {
fprintf(stderr, "FAIL: crypto_ct_eq_mask_u8(%d, %d) = %x, "
"want %x\n", i, j, crypto_ct_eq_mask_u8(i, j), mask);
goto failure;
}
} while (++j != 0);
} while (++i != 0);
failed = 0;
failure:
return failed;
}
int
main(int argc, char **argv)
{
int failed = 0;
failed |= test_ct_u8();
return failed;
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: parse.y,v 1.145 2024/04/13 15:58:10 jrick Exp $ */
/* $OpenBSD: parse.y,v 1.146 2024/04/25 14:24:54 jsg Exp $ */
/*
* Copyright (c) 2019 Tobias Heider <tobias.heider@stusta.de>
@ -1952,6 +1952,8 @@ parsekeyfile(char *filename, struct iked_auth *auth)
err(1, "open %s", filename);
if (check_file_secrecy(fd, filename) == -1)
exit(1);
if (fstat(fd, &sb) == -1)
err(1, "parsekeyfile: stat %s", filename);
if ((sb.st_size > KEYSIZE_LIMIT) || (sb.st_size == 0))
errx(1, "%s: key too %s", filename, sb.st_size ? "large" :
"small");

View File

@ -1,4 +1,4 @@
.\" $OpenBSD: softraid.4,v 1.54 2023/04/13 10:23:21 kn Exp $
.\" $OpenBSD: softraid.4,v 1.55 2024/04/25 07:21:43 stsp Exp $
.\"
.\" Copyright (c) 2007 Todd T. Fries <todd@OpenBSD.org>
.\" Copyright (c) 2007 Marco Peereboom <marco@OpenBSD.org>
@ -15,7 +15,7 @@
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
.Dd $Mdocdate: April 13 2023 $
.Dd $Mdocdate: April 25 2024 $
.Dt SOFTRAID 4
.Os
.Sh NAME
@ -118,6 +118,7 @@ may be used to install
in the boot storage area of the
.Nm
volume.
All chunks in the volume will then be bootable.
Boot support is currently limited to the CRYPTO, RAID 1 disciplines
on the amd64, arm64, i386, riscv64 and sparc64 platforms.
amd64, arm64, riscv64 and sparc64 also have boot support for the RAID 1C discipline.
@ -221,7 +222,7 @@ for more information on configuration of RAID sets.
.Pp
Install
.Xr boot 8
on the RAID volume:
on the RAID volume, writing boot loaders to all 3 chunks:
.Bd -literal -offset indent
# installboot sd0
.Ed

View File

@ -1,4 +1,4 @@
.\" $OpenBSD: boot.8,v 1.34 2023/02/23 19:48:21 miod Exp $
.\" $OpenBSD: boot.8,v 1.35 2024/04/25 18:31:49 kn Exp $
.\"
.\" Copyright (c) 1997-2001 Michael Shalayeff
.\" All rights reserved.
@ -25,7 +25,7 @@
.\" THE POSSIBILITY OF SUCH DAMAGE.
.\"
.\"
.Dd $Mdocdate: February 23 2023 $
.Dd $Mdocdate: April 25 2024 $
.Dt BOOT 8 amd64
.Os
.Sh NAME
@ -245,6 +245,19 @@ If
.Ar mode
is not given,
a list of available modes is shown.
.It Ic idle Op Ar secs
On
.Xr efi 4
systems,
sets the timeout in seconds to power down the machine,
if no input has been given at the
.Xr softraid 4
passphrase prompt.
A value of 0 unsets the timeout.
If
.Ar secs
is not given,
the current timeout is shown.
.It Ic memory
If used without any arguments, this command will print out
the memory configuration as determined through BIOS routines.
@ -426,6 +439,7 @@ option.
.Xr gzip 1 ,
.Xr autoconf 4 ,
.Xr ddb 4 ,
.Xr efi 4 ,
.Xr softraid 4 ,
.Xr biosboot 8 ,
.Xr boot_amd64 8 ,

View File

@ -1,4 +1,4 @@
# $OpenBSD: Makefile.common,v 1.22 2021/11/14 21:51:48 guenther Exp $
# $OpenBSD: Makefile.common,v 1.23 2024/04/25 18:31:49 kn Exp $
S= ${.CURDIR}/../../../../..
SADIR= ${.CURDIR}/../..
@ -18,6 +18,7 @@ COPTS+= -ffreestanding -std=gnu99
COPTS+= -fshort-wchar -fPIC -mno-red-zone
.if ${SOFTRAID:L} == "yes"
COPTS+= -DSOFTRAID
COPTS+= -DIDLE_POWEROFF
.endif
COPTS+= -D_STANDALONE -nostdinc -fno-builtin

View File

@ -1,4 +1,4 @@
/* $OpenBSD: cmd_i386.c,v 1.1 2019/05/10 21:20:42 mlarkin Exp $ */
/* $OpenBSD: cmd_i386.c,v 1.2 2024/04/25 18:31:49 kn Exp $ */
/*
* Copyright (c) 1997-1999 Michael Shalayeff
@ -61,6 +61,9 @@ const struct cmd_table cmd_machine[] = {
{ "poweroff", CMDT_CMD, Xpoweroff_efi },
#ifdef DEBUG
{ "regs", CMDT_CMD, Xregs },
#endif
#ifdef IDLE_POWEROFF
{ "idle", CMDT_CMD, Xidle_efi },
#endif
{ NULL, 0 }
};

View File

@ -1,4 +1,4 @@
/* $OpenBSD: conf.c,v 1.42 2023/07/22 10:11:19 jsg Exp $ */
/* $OpenBSD: conf.c,v 1.43 2024/04/25 18:31:49 kn Exp $ */
/*
* Copyright (c) 1996 Michael Shalayeff
@ -40,7 +40,7 @@
#include "efidev.h"
#include "efipxe.h"
const char version[] = "3.65";
const char version[] = "3.66";
#ifdef EFI_DEBUG
int debug = 0;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: efiboot.c,v 1.41 2023/01/02 22:41:17 kettenis Exp $ */
/* $OpenBSD: efiboot.c,v 1.42 2024/04/25 18:31:49 kn Exp $ */
/*
* Copyright (c) 2015 YASUOKA Masahiko <yasuoka@yasuoka.net>
@ -1078,17 +1078,69 @@ u_int
sleep(u_int i)
{
time_t t;
u_int intr = 0;
/*
* Loop for the requested number of seconds, polling,
* so that it may handle interrupts.
*/
for (t = getsecs() + i; getsecs() < t; cnischar())
for (t = getsecs() + i; intr == 0 && getsecs() < t; intr = cnischar())
;
return intr;
}
#ifdef IDLE_POWEROFF
CHAR16 *idle_name = L"IdlePoweroff";
EFI_STATUS idle_status;
/* randomly generated f948e8a9-0570-4338-ad10-29f4cf12849d */
EFI_GUID openbsd_guid = { 0xf948e8a9, 0x0570, 0x4338,
{ 0xad, 0x10, 0x29, 0xf4, 0xcf, 0x12, 0x84, 0x9d } };
/* Non-Volatile, Boot Service Access, Runtime Service Access */
UINT32 idle_attrs = 0x1 | 0x2 | 0x4;
UINT16 idle_secs;
UINTN idle_sz = sizeof(idle_secs);
int
get_idle_timeout(void)
{
idle_status = RS->GetVariable(idle_name, &openbsd_guid, NULL,
&idle_sz, &idle_secs);
if (idle_status != EFI_SUCCESS) {
if (idle_status != EFI_NOT_FOUND) {
printf("%s: %d\n", __func__, idle_status);
return 1;
}
return -1;
}
return 0;
}
int
set_idle_timeout(int secs)
{
idle_secs = secs;
idle_sz = idle_secs > 0 ? sizeof(idle_secs) : 0;
idle_status = RS->SetVariable(idle_name, &openbsd_guid, idle_attrs,
idle_sz, &idle_secs);
if (idle_status != EFI_SUCCESS) {
printf("%s: %d\n", __func__, idle_status);
return -1;
}
return 0;
}
/* see lib/libsa/softraid.c sr_crypto_passphrase_decrypt() */
void
idle_poweroff(void)
{
if (get_idle_timeout() == 0 && sleep(idle_secs) == 0) {
printf("\nno input after %us, powering off...\n", idle_secs);
Xpoweroff_efi();
}
}
#endif /* IDLE_POWEROFF */
/***********************************************************************
* Commands
***********************************************************************/
@ -1173,3 +1225,21 @@ Xgop_efi(void)
return (0);
}
#ifdef IDLE_POWEROFF
int
Xidle_efi(void)
{
if (cmd.argc >= 2) {
int secs;
secs = strtol(cmd.argv[1], NULL, 10);
if (0 <= secs && secs < UINT16_MAX)
set_idle_timeout(secs);
} else {
if (get_idle_timeout() == 0)
printf("Timeout = %us\n", idle_secs);
}
return 0;
}
#endif /* IDLE_POWEROFF */

View File

@ -1,4 +1,4 @@
/* $OpenBSD: efiboot.h,v 1.5 2022/07/11 19:45:02 kettenis Exp $ */
/* $OpenBSD: efiboot.h,v 1.6 2024/04/25 18:31:49 kn Exp $ */
/*
* Copyright (c) 2015 YASUOKA Masahiko <yasuoka@yasuoka.net>
@ -37,6 +37,9 @@ void efi_makebootargs(void);
void efi_setconsdev(void);
int Xpoweroff_efi(void);
#ifdef IDLE_POWEROFF
int Xidle_efi(void);
#endif
extern void (*run_i386)(u_long, u_long, int, int, int, int, int, int, int, int)
__attribute__ ((noreturn));

View File

@ -1,4 +1,4 @@
/* $OpenBSD: dwqe.c,v 1.18 2024/03/29 08:19:40 stsp Exp $ */
/* $OpenBSD: dwqe.c,v 1.19 2024/04/25 08:51:37 jmatthew Exp $ */
/*
* Copyright (c) 2008, 2019 Mark Kettenis <kettenis@openbsd.org>
* Copyright (c) 2017, 2022 Patrick Wildt <patrick@blueri.se>
@ -213,6 +213,8 @@ dwqe_attach(struct dwqe_softc *sc)
/* Disable interrupts. */
dwqe_write(sc, GMAC_INT_EN, 0);
dwqe_write(sc, GMAC_CHAN_INTR_ENA(0), 0);
dwqe_write(sc, GMAC_MMC_RX_INT_MASK, 0xffffffff);
dwqe_write(sc, GMAC_MMC_TX_INT_MASK, 0xffffffff);
return 0;
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: dwqereg.h,v 1.5 2023/11/11 16:32:56 stsp Exp $ */
/* $OpenBSD: dwqereg.h,v 1.7 2024/04/25 11:37:39 stsp Exp $ */
/*
* Copyright (c) 2008, 2019 Mark Kettenis <kettenis@openbsd.org>
* Copyright (c) 2017, 2022 Patrick Wildt <patrick@blueri.se>
@ -83,6 +83,8 @@
#define GMAC_MAC_MDIO_DATA 0x0204
#define GMAC_MAC_ADDR0_HI 0x0300
#define GMAC_MAC_ADDR0_LO 0x0304
#define GMAC_MMC_RX_INT_MASK 0x070c
#define GMAC_MMC_TX_INT_MASK 0x0710
#define GMAC_MTL_OPERATION_MODE 0x0c00
#define GMAC_MTL_FRPE (1 << 15)
@ -233,14 +235,44 @@ struct dwqe_desc {
#define TDES3_FS (1 << 29)
#define TDES3_OWN (1U << 31)
/* Rx bits */
/* Rx bits (read format; host to device) */
#define RDES3_BUF1V (1 << 24)
#define RDES3_BUF2V (1 << 25)
#define RDES3_IC (1 << 30)
#define RDES3_OWN (1U << 31)
/* Rx bits (writeback format; device to host) */
#define RDES1_IP_PAYLOAD_TYPE 0x7
#define RDES1_IP_PAYLOAD_UNKNOWN 0x0
#define RDES1_IP_PAYLOAD_UDP 0x1
#define RDES1_IP_PAYLOAD_TCP 0x2
#define RDES1_IP_PAYLOAD_ICMP 0x3
#define RDES1_IP_HDR_ERROR (1 << 3)
#define RDES1_IPV4_HDR (1 << 4)
#define RDES1_IPV6_HDR (1 << 5)
#define RDES1_IP_CSUM_BYPASS (1 << 6)
#define RDES1_IP_PAYLOAD_ERROR (1 << 7)
#define RDES3_LENGTH (0x7fff << 0)
#define RDES3_ES (1 << 15)
#define RDES3_LENTYPE 0x70000
#define RDES3_LENTYPE_LENGTH (0x0 << 16)
#define RDES3_LENTYPE_TYPE (0x1 << 16)
/* 0x2 is reserved */
#define RDES3_LENTYPE_ARP (0x3 << 16)
#define RDES3_LENTYPE_VLAN (0x4 << 16)
#define RDES3_LENTYPE_2VLAN (0x5 << 16)
#define RDES3_LENTYPE_MACCTL (0x6 << 16)
#define RDES3_LENTYPE_OAM (0x7 << 16)
#define RDES3_DE (1 << 19)
#define RDES3_RE (1 << 20)
#define RDES3_OE (1 << 21)
#define RDES3_RWT (1 << 22)
#define RDES3_GP (1 << 23)
#define RDES3_CE (1 << 24)
#define RDES3_BUF1V (1 << 24)
#define RDES3_IC (1 << 30)
#define RDES3_OWN (1U << 31)
#define RDES3_LENGTH (0x7fff << 0)
#define RDES3_RDES0_VALID (1 << 25)
#define RDES3_RDES1_VALID (1 << 26)
#define RDES3_RDES2_VALID (1 << 27)
#define RDES3_LD (1 << 28)
#define RDES3_FD (1 << 29)
#define RDES3_CTXT (1 << 30)
/* Bit 31 is the OWN bit, as in "read" format. */

View File

@ -1,4 +1,4 @@
/* $OpenBSD: uipc_socket2.c,v 1.149 2024/04/11 13:32:51 mvs Exp $ */
/* $OpenBSD: uipc_socket2.c,v 1.150 2024/04/25 17:32:53 bluhm Exp $ */
/* $NetBSD: uipc_socket2.c,v 1.11 1996/02/04 02:17:55 christos Exp $ */
/*
@ -559,7 +559,7 @@ sblock(struct socket *so, struct sockbuf *sb, int flags)
while (sb->sb_flags & SB_LOCK) {
sb->sb_flags |= SB_WANT;
mtx_leave(&sb->sb_mtx);
error = sosleep_nsec(so, &sb->sb_flags, prio, "netlck", INFSLP);
error = sosleep_nsec(so, &sb->sb_flags, prio, "sblock", INFSLP);
if (error)
return (error);
mtx_enter(&sb->sb_mtx);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: uipc_syscalls.c,v 1.218 2024/03/01 14:15:01 bluhm Exp $ */
/* $OpenBSD: uipc_syscalls.c,v 1.219 2024/04/25 17:32:53 bluhm Exp $ */
/* $NetBSD: uipc_syscalls.c,v 1.19 1996/02/09 19:00:48 christos Exp $ */
/*
@ -300,7 +300,7 @@ doaccept(struct proc *p, int sock, struct sockaddr *name, socklen_t *anamelen,
break;
}
error = sosleep_nsec(head, &head->so_timeo, PSOCK | PCATCH,
"netcon", INFSLP);
"netacc", INFSLP);
if (error)
goto out_unlock;
}
@ -428,7 +428,7 @@ sys_connect(struct proc *p, void *v, register_t *retval)
}
while ((so->so_state & SS_ISCONNECTING) && so->so_error == 0) {
error = sosleep_nsec(so, &so->so_timeo, PSOCK | PCATCH,
"netcon2", INFSLP);
"netcon", INFSLP);
if (error) {
if (error == EINTR || error == ERESTART)
interrupted = 1;
@ -1651,7 +1651,7 @@ out:
error = soconnect(so, nam);
while ((so->so_state & SS_ISCONNECTING) && so->so_error == 0) {
error = sosleep_nsec(so, &so->so_timeo, PSOCK | PCATCH,
"netcon2", INFSLP);
"ypcon", INFSLP);
if (error)
break;
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: softraid.c,v 1.6 2024/03/24 05:50:20 jsg Exp $ */
/* $OpenBSD: softraid.c,v 1.7 2024/04/25 18:31:49 kn Exp $ */
/*
* Copyright (c) 2012 Joel Sing <jsing@openbsd.org>
@ -150,6 +150,10 @@ sr_crypto_passphrase_decrypt(struct sr_meta_crypto *cm,
for (;;) {
printf("Passphrase: ");
#ifdef IDLE_POWEROFF
extern int idle_poweroff(void);
idle_poweroff();
#endif /* IDLE_POWEROFF */
for (i = 0; i < PASSPHRASE_LENGTH - 1; i++) {
c = cngetc();
if (c == '\r' || c == '\n') {

View File

@ -25,19 +25,33 @@ THIS SOFTWARE.
This file lists all bug fixes, changes, etc., made since the
second edition of the AWK book was published in September 2023.
Apr 22, 2024:
fixed regex engine gototab reallocation issue that was
introduced during the Nov 24 rewrite. Thanks to Arnold Robbins.
Fixed a scan bug in split in the case the separator is a single
character. thanks to Oguz Ismail for spotting the issue.
Mar 10, 2024:
fixed use-after-free bug in fnematch due to adjbuf invalidating
the pointers to buf. thanks to github user caffe3 for spotting
the issue and providing a fix, and to Miguel Pineiro Jr.
for the alternative fix.
MAX_UTF_BYTES in fnematch has been replaced with awk_mb_cur_max.
thanks to Miguel Pineiro Jr.
Jan 22, 2024:
Restore the ability to compile with g++. Thanks to
Arnold Robbins.
Dec 24, 2023:
matchop dereference after free problem fix when the first
argument is a function call. thanks to Oguz Ismail Uysal.
Matchop dereference after free problem fix when the first
argument is a function call. Thanks to Oguz Ismail Uysal.
Fix inconsistent handling of --csv and FS set in the
command line. Thanks to Wilbert van der Poel.
casting changes to int for is* functions.
Casting changes to int for is* functions.
Nov 27, 2023:
Fix exit status of system on MacOS. update to REGRESS.
Fix exit status of system on MacOS. Update to REGRESS.
Thanks to Arnold Robbins.
Fix inconsistent handling of -F and --csv, and loss of csv
mode when FS is set.
@ -45,7 +59,7 @@ Nov 27, 2023:
Nov 24, 2023:
Fix issue #199: gototab improvements to dynamically resize the
table, qsort and bsearch to improve the lookup speed as the
table gets larger for multibyte input. thanks to Arnold Robbins.
table gets larger for multibyte input. Thanks to Arnold Robbins.
Nov 23, 2023:
Fix Issue #169, related to escape sequences in strings.
@ -54,29 +68,29 @@ Nov 23, 2023:
by Miguel Pineiro Jr.
Nov 20, 2023:
rewrite of fnematch to fix a number of issues, including
Rewrite of fnematch to fix a number of issues, including
extraneous output, out-of-bounds access, number of bytes
to push back after a failed match etc.
thanks to Miguel Pineiro Jr.
Thanks to Miguel Pineiro Jr.
Nov 15, 2023:
Man page edit, regression test fixes. thanks to Arnold Robbins
consolidation of sub and gsub into dosub, removing duplicate
code. thanks to Miguel Pineiro Jr.
Man page edit, regression test fixes. Thanks to Arnold Robbins
Consolidation of sub and gsub into dosub, removing duplicate
code. Thanks to Miguel Pineiro Jr.
gcc replaced with cc everywhere.
Oct 30, 2023:
multiple fixes and a minor code cleanup.
disabled utf-8 for non-multibyte locales, such as C or POSIX.
fixed a bad char * cast that causes incorrect results on big-endian
systems. also fixed an out-of-bounds read for empty CCL.
fixed a buffer overflow in substr with utf-8 strings.
many thanks to Todd C Miller.
Multiple fixes and a minor code cleanup.
Disabled utf-8 for non-multibyte locales, such as C or POSIX.
Fixed a bad char * cast that causes incorrect results on big-endian
systems. Also fixed an out-of-bounds read for empty CCL.
Fixed a buffer overflow in substr with utf-8 strings.
Many thanks to Todd C Miller.
Sep 24, 2023:
fnematch and getrune have been overhauled to solve issues around
unicode FS and RS. also fixed gsub null match issue with unicode.
big thanks to Arnold Robbins.
unicode FS and RS. Also fixed gsub null match issue with unicode.
Big thanks to Arnold Robbins.
Sep 12, 2023:
Fixed a length error in u8_byte2char that set RSTART to
@ -101,9 +115,8 @@ Sep 12, 2023:
of a string of 3 emojis is 3, not 12 as it would be if bytes
were counted.
Regular expressions are processes as UTF-8.
Regular expressions are processed as UTF-8.
Unicode literals can be written as \u followed by one
to eight hexadecimal digits. These may appear in strings and
regular expressions.

View File

@ -38,6 +38,7 @@ Regular expressions may include UTF-8 code points, including `\u`.
The option `--csv` turns on CSV processing of input:
fields are separated by commas, fields may be quoted with
double-quote (`"`) characters, quoted fields may contain embedded newlines.
Double-quotes in fields have to be doubled and enclosed in quoted fields.
In CSV mode, `FS` is ignored.
If no explicit separator argument is provided,
@ -112,6 +113,8 @@ move this to some place like `/usr/bin/awk`.
If your system does not have `yacc` or `bison` (the GNU
equivalent), you need to install one of them first.
The default in the `makefile` is `bison`; you will have
to edit the `makefile` to use `yacc`.
NOTE: This version uses ISO/IEC C99, as you should also. We have
compiled this without any changes using `gcc -Wall` and/or local C
@ -131,4 +134,4 @@ We don't usually do releases.
#### Last Updated
Mon 30 Oct 2023 12:53:07 MDT
Mon 05 Feb 2024 08:46:55 IST

View File

@ -1,4 +1,4 @@
/* $OpenBSD: b.c,v 1.50 2024/01/25 16:40:51 millert Exp $ */
/* $OpenBSD: b.c,v 1.51 2024/04/25 18:33:53 millert Exp $ */
/****************************************************************
Copyright (C) Lucent Technologies 1997
All Rights Reserved
@ -613,11 +613,11 @@ static void resize_gototab(fa *f, int state)
size_t orig_size = f->gototab[state].allocated; // 2nd half of new mem is this size
memset(p + orig_size, 0, orig_size * sizeof(gtte)); // clean it out
f->gototab[state].allocated = new_size; // update gotottab info
f->gototab[state].allocated = new_size; // update gototab info
f->gototab[state].entries = p;
}
static int get_gototab(fa *f, int state, int ch) /* hide gototab inplementation */
static int get_gototab(fa *f, int state, int ch) /* hide gototab implementation */
{
gtte key;
gtte *item;
@ -644,7 +644,7 @@ static int entry_cmp(const void *l, const void *r)
return left->ch - right->ch;
}
static int set_gototab(fa *f, int state, int ch, int val) /* hide gototab inplementation */
static int set_gototab(fa *f, int state, int ch, int val) /* hide gototab implementation */
{
if (f->gototab[state].inuse == 0) {
f->gototab[state].entries[0].ch = ch;
@ -657,8 +657,8 @@ static int set_gototab(fa *f, int state, int ch, int val) /* hide gototab inplem
if (tab->inuse + 1 >= tab->allocated)
resize_gototab(f, state);
f->gototab[state].entries[f->gototab[state].inuse-1].ch = ch;
f->gototab[state].entries[f->gototab[state].inuse-1].state = val;
f->gototab[state].entries[f->gototab[state].inuse].ch = ch;
f->gototab[state].entries[f->gototab[state].inuse].state = val;
f->gototab[state].inuse++;
return val;
} else {
@ -683,9 +683,9 @@ static int set_gototab(fa *f, int state, int ch, int val) /* hide gototab inplem
gtt *tab = & f->gototab[state];
if (tab->inuse + 1 >= tab->allocated)
resize_gototab(f, state);
++tab->inuse;
f->gototab[state].entries[tab->inuse].ch = ch;
f->gototab[state].entries[tab->inuse].state = val;
++tab->inuse;
qsort(f->gototab[state].entries,
f->gototab[state].inuse, sizeof(gtte), entry_cmp);
@ -836,8 +836,6 @@ int nematch(fa *f, const char *p0) /* non-empty match, for sub */
}
#define MAX_UTF_BYTES 4 // UTF-8 is up to 4 bytes long
/*
* NAME
* fnematch
@ -874,16 +872,28 @@ bool fnematch(fa *pfa, FILE *f, char **pbuf, int *pbufsize, int quantum)
do {
/*
* Call u8_rune with at least MAX_UTF_BYTES ahead in
* Call u8_rune with at least awk_mb_cur_max ahead in
* the buffer until EOF interferes.
*/
if (k - j < MAX_UTF_BYTES) {
if (k + MAX_UTF_BYTES > buf + bufsize) {
if (k - j < awk_mb_cur_max) {
if (k + awk_mb_cur_max > buf + bufsize) {
char *obuf = buf;
adjbuf(&buf, &bufsize,
bufsize + MAX_UTF_BYTES,
bufsize + awk_mb_cur_max,
quantum, 0, "fnematch");
/* buf resized, maybe moved. update pointers */
*pbufsize = bufsize;
if (obuf != buf) {
i = buf + (i - obuf);
j = buf + (j - obuf);
k = buf + (k - obuf);
*pbuf = buf;
if (patlen)
patbeg = buf + (patbeg - obuf);
}
}
for (n = MAX_UTF_BYTES ; n > 0; n--) {
for (n = awk_mb_cur_max ; n > 0; n--) {
*k++ = (c = getc(f)) != EOF ? c : 0;
if (c == EOF) {
if (ferror(f))
@ -920,10 +930,6 @@ bool fnematch(fa *pfa, FILE *f, char **pbuf, int *pbufsize, int quantum)
s = 2;
} while (1);
/* adjbuf() may have relocated a resized buffer. Inform the world. */
*pbuf = buf;
*pbufsize = bufsize;
if (patlen) {
/*
* Under no circumstances is the last character fed to

View File

@ -1,4 +1,4 @@
/* $OpenBSD: main.c,v 1.68 2024/01/25 16:40:51 millert Exp $ */
/* $OpenBSD: main.c,v 1.69 2024/04/25 18:33:53 millert Exp $ */
/****************************************************************
Copyright (C) Lucent Technologies 1997
All Rights Reserved
@ -23,7 +23,7 @@ ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
THIS SOFTWARE.
****************************************************************/
const char *version = "version 20240122";
const char *version = "version 20240422";
#define DEBUG
#include <stdio.h>

View File

@ -1,4 +1,4 @@
/* $OpenBSD: run.c,v 1.84 2024/01/25 16:40:51 millert Exp $ */
/* $OpenBSD: run.c,v 1.85 2024/04/25 18:33:53 millert Exp $ */
/****************************************************************
Copyright (C) Lucent Technologies 1997
All Rights Reserved
@ -1831,7 +1831,7 @@ Cell *split(Node **a, int nnn) /* split(a[0], a[1], a[2]); a[3] is type */
for (;;) {
n++;
t = s;
while (*s != sep && *s != '\n' && *s != '\0')
while (*s != sep && *s != '\0')
s++;
temp = *s;
setptr(s, '\0');
@ -2527,7 +2527,7 @@ void backsub(char **pb_ptr, const char **sptr_ptr);
Cell *dosub(Node **a, int subop) /* sub and gsub */
{
fa *pfa;
int tempstat;
int tempstat = 0;
char *repl;
Cell *x;

View File

@ -1,4 +1,4 @@
.\" $OpenBSD: set.opt.roff,v 1.13 2020/04/30 10:40:21 millert Exp $
.\" $OpenBSD: set.opt.roff,v 1.14 2024/04/25 05:26:41 jmc Exp $
.\"
.\" Copyright (c) 1994
.\" The Regents of the University of California. All rights reserved.
@ -869,7 +869,7 @@ the set value, it is reported to the user.
.IP "ruler [off]"
.CO Vi
only.
Display a row/column ruler on the colon command line.
Display a row/column/percentage ruler on the colon command line.
.KY scroll
.IP "scroll, scr [(environment variable LINES - 1) / 2]"
Set the number of lines scrolled by the

View File

@ -1,4 +1,4 @@
/* $OpenBSD: vs_refresh.c,v 1.24 2024/04/24 15:15:40 job Exp $ */
/* $OpenBSD: vs_refresh.c,v 1.25 2024/04/25 09:58:17 job Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
@ -781,7 +781,7 @@ vs_modeline(SCR *sp)
size_t cols, curcol, curlen, endpoint, len, midpoint;
const char *t = NULL;
int ellipsis;
char *p, buf[20];
char *p, buf[30];
recno_t last;
/*
@ -859,7 +859,7 @@ vs_modeline(SCR *sp)
if (O_ISSET(sp, O_RULER)) {
vs_column(sp, &curcol);
if (db_last(sp, &last))
if (db_last(sp, &last) || last == 0)
len = snprintf(buf, sizeof(buf), "%lu,%zu",
(ulong)sp->lno, curcol + 1);
else