[DTrace-devel] [PATCH 12/14] test: Check strtok() for addresses that are not DTrace pointers

eugene.loh at oracle.com eugene.loh at oracle.com
Thu Nov 3 19:52:24 UTC 2022


From: Eugene Loh <eugene.loh at oracle.com>

Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
---
 .../funcs/strtok/tst.strtok_nonDPTR.d         | 27 +++++++++++++++++++
 .../funcs/strtok/tst.strtok_nonDPTR.r         |  5 ++++
 2 files changed, 32 insertions(+)
 create mode 100644 test/unittest/funcs/strtok/tst.strtok_nonDPTR.d
 create mode 100644 test/unittest/funcs/strtok/tst.strtok_nonDPTR.r

diff --git a/test/unittest/funcs/strtok/tst.strtok_nonDPTR.d b/test/unittest/funcs/strtok/tst.strtok_nonDPTR.d
new file mode 100644
index 00000000..54da5650
--- /dev/null
+++ b/test/unittest/funcs/strtok/tst.strtok_nonDPTR.d
@@ -0,0 +1,27 @@
+/*
+ * Oracle Linux DTrace.
+ * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
+ * Licensed under the Universal Permissive License v 1.0 as shown at
+ * http://oss.oracle.com/licenses/upl.
+ */
+
+#pragma D option quiet
+#pragma D option destructive
+
+BEGIN
+{
+	/* "abcdef" */
+	system("printf '\x61\x62\x63\x64\x65\x66' > /dev/null 2>&1");
+}
+
+syscall::write:entry
+/ppid == $pid/
+{
+	printf("|%s|\n", strtok((void *)arg1, "defghidEFGHI"));
+	printf("|%s|\n", strtok(NULL, "fF"));
+	printf("|%s|\n", strtok("nmlkjihgfFOOBARedcba", (void *)arg1));
+	printf("|%s|\n", strtok(NULL, (void *)arg1));
+	exit(0);
+}
+
+ERROR { exit(1); }
diff --git a/test/unittest/funcs/strtok/tst.strtok_nonDPTR.r b/test/unittest/funcs/strtok/tst.strtok_nonDPTR.r
new file mode 100644
index 00000000..cbfb0b38
--- /dev/null
+++ b/test/unittest/funcs/strtok/tst.strtok_nonDPTR.r
@@ -0,0 +1,5 @@
+|abc|
+|de|
+|nmlkjihg|
+|FOOBAR|
+
-- 
2.18.4




More information about the DTrace-devel mailing list