From 14cb6e731c685865a5e4070192b479783076bb11 Mon Sep 17 00:00:00 2001 From: deraadt Date: Tue, 22 Feb 2022 17:26:04 +0000 Subject: [PATCH] Since other exported commandnames were increased to 24 and graduated into proper strings, adapt dt's exported string in the same way. Old/new files/tools will not work the same way. That this interface needs to also change was pointed out by jsg --- sys/dev/dt/dt_dev.c | 4 ++-- sys/dev/dt/dtvar.h | 10 +++++----- usr.sbin/btrace/btrace.c | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/sys/dev/dt/dt_dev.c b/sys/dev/dt/dt_dev.c index f60860ca508..b8b9a6c75f6 100644 --- a/sys/dev/dt/dt_dev.c +++ b/sys/dev/dt/dt_dev.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dt_dev.c,v 1.20 2022/01/20 07:49:25 visa Exp $ */ +/* $OpenBSD: dt_dev.c,v 1.21 2022/02/22 17:26:04 deraadt Exp $ */ /* * Copyright (c) 2019 Martin Pieuchot @@ -658,7 +658,7 @@ dt_pcb_ring_get(struct dt_pcb *dp, int profiling) nanotime(&dtev->dtev_tsp); if (ISSET(dp->dp_evtflags, DTEVT_EXECNAME)) - memcpy(dtev->dtev_comm, p->p_p->ps_comm, DTMAXCOMLEN - 1); + strlcpy(dtev->dtev_comm, p->p_p->ps_comm, sizeof(dtev->dtev_comm)); if (ISSET(dp->dp_evtflags, DTEVT_KSTACK|DTEVT_USTACK)) { if (profiling) diff --git a/sys/dev/dt/dtvar.h b/sys/dev/dt/dtvar.h index fad7e9eaa45..632f3fa6f3b 100644 --- a/sys/dev/dt/dtvar.h +++ b/sys/dev/dt/dtvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: dtvar.h,v 1.11 2022/01/09 05:42:37 jsg Exp $ */ +/* $OpenBSD: dtvar.h,v 1.12 2022/02/22 17:26:04 deraadt Exp $ */ /* * Copyright (c) 2019 Martin Pieuchot @@ -24,14 +24,14 @@ #include /* - * Length of provider/probe/function names, including terminating '\0'. + * Length of provider/probe/function names, including NUL. */ #define DTNAMESIZE 16 /* - * Length of process name, keep in sync with MAXCOMLEN. + * Length of process name, including NUL. */ -#define DTMAXCOMLEN 16 +#define DTMAXCOMLEN _MAXCOMLEN /* * Maximum number of arguments passed to a function. @@ -52,7 +52,7 @@ struct dt_evt { * Recorded if the corresponding flag is set. */ struct stacktrace dtev_kstack; /* kernel stack frame */ - char dtev_comm[DTMAXCOMLEN+1]; /* current pr. name */ + char dtev_comm[DTMAXCOMLEN]; /* current pr. name */ union { register_t E_entry[DTMAXFUNCARGS]; struct { diff --git a/usr.sbin/btrace/btrace.c b/usr.sbin/btrace/btrace.c index 11fef8bfbc7..5daaab1f969 100644 --- a/usr.sbin/btrace/btrace.c +++ b/usr.sbin/btrace/btrace.c @@ -1,4 +1,4 @@ -/* $OpenBSD: btrace.c,v 1.61 2021/12/07 22:17:03 guenther Exp $ */ +/* $OpenBSD: btrace.c,v 1.62 2022/02/22 17:26:04 deraadt Exp $ */ /* * Copyright (c) 2019 - 2021 Martin Pieuchot @@ -492,7 +492,7 @@ rules_setup(int fd) /* Initialize "fake" event for BEGIN/END */ bt_devt.dtev_pbn = -1; - memcpy(&bt_devt.dtev_comm, getprogname(), sizeof(bt_devt.dtev_comm)); + strlcpy(bt_devt.dtev_comm, getprogname(), sizeof(bt_devt.dtev_comm)); bt_devt.dtev_pid = getpid(); bt_devt.dtev_tid = getthrid(); clock_gettime(CLOCK_REALTIME, &bt_devt.dtev_tsp); -- 2.20.1