-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix length stored by strjoin() and optimise the implementation
The length that was stored for strjoin() was the sum of the lengths of the two argument strings. That means that if the sum was larger than STRSIZE, we would still store that larger length even though the string itself got truncated. Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com> Reviewed-by: Eugene Loh <eugene.loh@oracle.com>
- Loading branch information
Showing
3 changed files
with
94 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Oracle Linux DTrace. | ||
* Copyright (c) 2021, 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 rawbytes | ||
#pragma D option strsize=5 | ||
#pragma D option quiet | ||
|
||
BEGIN | ||
{ | ||
trace(strjoin("", "123")); | ||
trace(strjoin("", "12345")); | ||
trace(strjoin("", "1234567890")); | ||
|
||
trace(strjoin("123", "abcdefgh")); | ||
trace(strjoin("12345", "abcdefgh")); | ||
trace(strjoin("1234567890", "abcdefgh")); | ||
|
||
trace(strjoin("123", "")); | ||
trace(strjoin("12345", "")); | ||
trace(strjoin("1234567890", "")); | ||
|
||
exit(0); | ||
} | ||
|
||
ERROR | ||
{ | ||
exit(1); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
|
||
0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef | ||
0: 00 03 31 32 33 00 00 00 ..123... | ||
|
||
0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef | ||
0: 00 05 31 32 33 34 35 00 ..12345. | ||
|
||
0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef | ||
0: 00 05 31 32 33 34 35 00 ..12345. | ||
|
||
0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef | ||
0: 00 05 31 32 33 61 62 00 ..123ab. | ||
|
||
0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef | ||
0: 00 05 31 32 33 34 35 00 ..12345. | ||
|
||
0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef | ||
0: 00 05 31 32 33 34 35 00 ..12345. | ||
|
||
0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef | ||
0: 00 03 31 32 33 00 00 00 ..123... | ||
|
||
0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef | ||
0: 00 05 31 32 33 34 35 00 ..12345. | ||
|
||
0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef | ||
0: 00 05 31 32 33 34 35 00 ..12345. | ||
|