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

Kris Van Hees kris.van.hees at oracle.com
Sat Feb 18 06:48:51 UTC 2023


On Thu, Nov 03, 2022 at 03:52:24PM -0400, eugene.loh--- via DTrace-devel wrote:
> From: Eugene Loh <eugene.loh at oracle.com>
> 
> Signed-off-by: Eugene Loh <eugene.loh at oracle.com>

Reviewed-by: Kris Van Hees <kris.van.hees 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
> 
> 
> _______________________________________________
> DTrace-devel mailing list
> DTrace-devel at oss.oracle.com
> https://oss.oracle.com/mailman/listinfo/dtrace-devel



More information about the DTrace-devel mailing list