Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fuzz: also generate the empty string sometimes #6176

Merged
merged 1 commit into from
Apr 1, 2024

Conversation

BenWiederhake
Copy link
Collaborator

Inspired by #6167: #6175 is a bug in uutils, caused by an unexpectedly empty string.

Note that the empty string regularly causes interesting behavior:

$ echo hello world | hd
00000000  68 65 6c 6c 6f 20 77 6f  72 6c 64 0a              |hello world.|
0000000c
$ echo hello "" world | hd # Additional space!
00000000  68 65 6c 6c 6f 20 20 77  6f 72 6c 64 0a           |hello  world.|
0000000d

(uutils already behaves correctly here.)

However, uutils sometimes doesn't behave correctly. To prove my point, I just found this bug merely by inserting the empty string in various places:

$ rm -rf target/test/; mkdir target/test/; cp LICENSE "" README.md target/test/; echo "EXITCODE GNU: $?"; ls -l target/test/; echo "(end)"      
cp: cannot stat '': No such file or directory
EXITCODE GNU: 1
total 12
-rw-r--r-- 1 user user 1056 Apr  1 21:12 LICENSE
-rw-r--r-- 1 user user 7973 Apr  1 21:12 README.md
(end)
$ rm -rf target/test/; mkdir target/test/; cargo run cp LICENSE "" README.md target/test/; echo "EXITCODE uutils: $?"; ls -l target/test/; echo "(end)"
    Finished dev [unoptimized + debuginfo] target(s) in 0.13s
     Running `target/debug/coreutils cp LICENSE '' README.md target/test/`
error: a value is required for '[paths]...' but none was supplied

For more information, try '--help'.
EXITCODE uutils: 1
total 0
(end)

I hope this is enough motivation that we should include the empty string during fuzzing.

Inspired by uutils#6167, uutils#6175, and the observation that 'echo hello "" world | hd' outputs extra spaces.
@sylvestre sylvestre merged commit 8f791da into uutils:main Apr 1, 2024
62 checks passed
@sylvestre
Copy link
Contributor

sounds good, thanks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants