Skip to content

Commit

Permalink
test: Check strtok() for addresses that are not DTrace pointers
Browse files Browse the repository at this point in the history
Signed-off-by: Eugene Loh <eugene.loh@oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees@oracle.com>
  • Loading branch information
euloh authored and kvanhees committed Feb 20, 2023
1 parent 542807f commit 469268e
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
27 changes: 27 additions & 0 deletions test/unittest/funcs/strtok/tst.strtok_nonDPTR.d
Original file line number Diff line number Diff line change
@@ -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); }
5 changes: 5 additions & 0 deletions test/unittest/funcs/strtok/tst.strtok_nonDPTR.r
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
|abc|
|de|
|nmlkjihg|
|FOOBAR|

0 comments on commit 469268e

Please sign in to comment.