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

- when compressing multiple files causes a segfault #3206

Closed
cgbur opened this issue Jul 20, 2022 · 2 comments
Closed

- when compressing multiple files causes a segfault #3206

cgbur opened this issue Jul 20, 2022 · 2 comments
Assignees
Labels
bug release-blocking Must be done by the release

Comments

@cgbur
Copy link
Contributor

cgbur commented Jul 20, 2022

Describe the bug
In normal operation the - should be treated as stdin. When compressing multiple files and one of them is - the cli incorrectly attempts to make a file named stdin.zst and segfaults.

To Reproduce

zstd

cd $(mktemp -d)
echo oops > !
echo oh no > -
zstd ! -
zstd: /*stdin*\.zst: Permission denied                                          280%
fish: Job 1, 'zstd *' terminated by signal SIGSEGV (Address boundary error)

-f makes no difference here and still a segfault

gzip

cd $(mktemp -d)
echo oops > !
echo oh no > -
gzip ! -
gzip: compressed data not written to a terminal. Use -f to force compression.
For help, type: gzip -h

If zstd - ! is passed, zstd will propogate the stdin->stdout behavior to all other files.

cd $(mktemp -d)
echo oops > !
zstd - ! -f
hello
(/X1hello
S(/$)oops
�5~⏎  

however gzip does not propogate this behavior

cd $(mktemp -d)
echo oops > !
gzip - ! -f
hello
lQ���� 0:6⏎    

Expected behavior
zstd should print stdin is a console, aborting or if -f is passed, wait for standard input and write it to standard output in between doing the other file behaviors. This matches what gzip does.

Desktop
linux - zstd 1.5.2 built from source

Let me know thoughts a fix and I am happy to move forward with a PR.

@terrelln terrelln added bug release-blocking Must be done by the release labels Jul 25, 2022
@terrelln
Copy link
Contributor

Thanks for the bug report!

Zstd should definitely treat - as stdin when compressing multiple files, and only write that single file to stdout.

We'll make sure to fix this in our next release. I think this one might be a somewhat tricky one to fix, so I'd recommend leaving it to us. However, the pass-through mode issues would be a good candidate to work on.

@yoniko yoniko self-assigned this Jul 26, 2022
yoniko added a commit to yoniko/zstd that referenced this issue Jul 29, 2022
yoniko added a commit that referenced this issue Jul 29, 2022
* Fixes for #3206 - bugs when handling stdin as part of multiple files.

* new line at end of multiple-files.sh
@yoniko
Copy link
Contributor

yoniko commented Jul 29, 2022

Thank you for reporting.
Fixed in #3222.

@yoniko yoniko closed this as completed Jul 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug release-blocking Must be done by the release
Projects
None yet
Development

No branches or pull requests

3 participants