summaryrefslogtreecommitdiff
path: root/usr.sbin/btrace/btrace.c
diff options
context:
space:
mode:
authorMartin Pieuchot <mpi@cvs.openbsd.org>2024-01-25 20:50:59 +0000
committerMartin Pieuchot <mpi@cvs.openbsd.org>2024-01-25 20:50:59 +0000
commitac86ae3fbb62d1b532f4d9950de889d680c751df (patch)
tree1cbafdd999103f21f7c6036ce3981a0eee184cb8 /usr.sbin/btrace/btrace.c
parentd8358072325ee8392633e153b7cbc9284bad53d0 (diff)
Return 0 when accessing an argument not defined in a probe.
Adapted from a fix from Christian Ludwig.
Diffstat (limited to 'usr.sbin/btrace/btrace.c')
-rw-r--r--usr.sbin/btrace/btrace.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/usr.sbin/btrace/btrace.c b/usr.sbin/btrace/btrace.c
index ac8b5d97d99..98c4af36572 100644
--- a/usr.sbin/btrace/btrace.c
+++ b/usr.sbin/btrace/btrace.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: btrace.c,v 1.82 2024/01/23 22:04:15 mpi Exp $ */
+/* $OpenBSD: btrace.c,v 1.83 2024/01/25 20:50:58 mpi Exp $ */
/*
* Copyright (c) 2019 - 2023 Martin Pieuchot <mpi@openbsd.org>
@@ -797,13 +797,18 @@ const char *
builtin_arg(struct dt_evt *dtev, enum bt_argtype dat)
{
static char buf[sizeof("18446744073709551615")]; /* UINT64_MAX */
- unsigned int argn;
+ struct dtioc_probe_info *dtpi;
struct dtioc_arg_info *dtai;
const char *argtype, *fmt;
+ unsigned int argn;
long value;
- dtai = dt_args[dtev->dtev_pbn - 1];
argn = dat - B_AT_BI_ARG0;
+ dtpi = &dt_dtpis[dtev->dtev_pbn - 1];
+ if (dtpi == NULL || argn >= dtpi->dtpi_nargs)
+ return "0";
+
+ dtai = dt_args[dtev->dtev_pbn - 1];
argtype = dtai[argn].dtai_argtype;
if (strncmp(argtype, "int", DTNAMESIZE) == 0) {