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

Make hx properly handle being passed invalid paths #27

Merged
merged 2 commits into from
Oct 26, 2020
Merged

Make hx properly handle being passed invalid paths #27

merged 2 commits into from
Oct 26, 2020

Conversation

poliorcetics
Copy link
Contributor

@poliorcetics poliorcetics commented Oct 25, 2020

Fixes #26.
Fixes #23.

With this PR hx is now able to properly report an error when it is given a directory, an invalid filename or a broken pipe:

# All those cases crashed previously.

❯ ./target/release/hx filename-missing
error = "No such file or directory (os error 2)"

❯ ./target/release/hx src
error = "Is a directory (os error 21)"

❯ ./target/release/hx symlink_to_dir
error = "Is a directory (os error 21)"

❯ dd if=/dev/random bs=512 count=10 | RUST_BACKTRACE=1 ./target/debug/hx | head -n 10
10+0 records in
10+0 records out
5120 bytes transferred in 0.000036 secs (142217460 bytes/sec)
0x000000: 0x6c 0xdc 0x4f 0x43 0xfd 0x5e 0xb3 0xa7 0x79 0xaa l.OC.^..y.
0x00000a: 0x6b 0x2c 0x81 0x47 0x00 0x10 0xa6 0x40 0xb5 0x6a k,.G...@.j
0x000014: 0x4d 0x31 0x5b 0x11 0x15 0x71 0xb8 0xa1 0xff 0x91 M1[..q....
0x00001e: 0x2e 0xaa 0x69 0x77 0x52 0x2a 0x20 0xa6 0x52 0xe5 ..iwR* .R.
0x000028: 0x41 0x2b 0x83 0x55 0x21 0x41 0x33 0xae 0xf8 0x38 A+.U!A3..8
0x000032: 0xba 0x74 0xfe 0x23 0xc2 0xc9 0xf5 0x3d 0x28 0x8e .t.#...=(.
0x00003c: 0xbc 0x0e 0xe1 0xa3 0xbf 0xda 0x81 0x92 0xc6 0xe9 ..........
0x000046: 0x9f 0xb7 0x13 0x72 0x79 0xd3 0x1e 0x4c 0xd8 0x5d ...ry..L.]
0x000050: 0x85 0x36 0x91 0x9f 0x13 0x7e 0x55 0x5f 0x7b 0xa6 .6...~U_{.
0x00005a: 0x23 0xe7 0xed 0x54 0x47 0x9a 0x1c 0x54 0x91 0x85 #..TG..T..
error = "Broken pipe (os error 32)"

With this commit `hx` is now able to properly
report an error when it is given a directory or an
invalid filename.
Fixes #23.

With this `hx` is now able to handle broken pipes as in the command
`dd if=/dev/random bs=512 count=10 | RUST_BACKTRACE=1 ./target/debug/hx | head -n 10`
and will exit with the correct error: `error = "Broken pipe (os error 32)"`
without crashing with a backtrace.
@sitkevij sitkevij changed the base branch from master to develop October 26, 2020 14:58
@sitkevij
Copy link
Owner

pointing PR #27 to develop branch for integration testing.

@sitkevij sitkevij merged commit a6ae005 into sitkevij:develop Oct 26, 2020
@sitkevij sitkevij mentioned this pull request Oct 26, 2020
@poliorcetics poliorcetics deleted the invalid-filename branch October 29, 2020 02:40
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.

Passing a invalid filename causes a crash SIGPIPE causes hex to crash
2 participants