Skip to content

- when compressing multiple files causes a segfault #3206

@cgbur

Description

@cgbur

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.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions