[PATCH] stapsdt: fix out-of-bounds access when provider name is not specified

Kris Van Hees <[email protected]>
Newsgroups dev.linux.lists.dtrace
Message-ID <SJ0PR10MB5672584FFCA103989DCF31BBC23AA@SJ0PR10MB5672.namprd10.prod.outlook.com>
Signed-off-by: Kris Van Hees <[email protected]>
---
 libdtrace/dt_pid.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/libdtrace/dt_pid.c b/libdtrace/dt_pid.c
index 4af9141aa..ffc52132f 100644
--- a/libdtrace/dt_pid.c
+++ b/libdtrace/dt_pid.c
@@ -1518,10 +1518,14 @@ dt_pid_create_stapsdt_probes(dtrace_probedesc_t *pdp, dtrace_hdl_t *dtp, dt_pcb_
 	dt_proc_t *dpr = NULL;
 	const char *pidstr;
 	pid_t pid;
+	size_t len = strlen(pdp->prv);
+
+	if (len == 0)
+		return 0;
 
 	assert(pcb != NULL);
 
-	pidstr = &pdp->prv[strlen(pdp->prv)];
+	pidstr = &pdp->prv[len];
 
 	while (isdigit(*(pidstr - 1)))
 		pidstr--;
-- 
2.45.2
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.