facebook/zstd

segfault when a file should be written to a nonexistent directory

rumpelsepp opened this issue · 1 comments

Describe the bug

The CLI tool zstd segfaults when a file should be written to a nonexistent directory.

To Reproduce

$ /bin/sh -c 'echo "foo" | zstd - -o /I/do/not/exist'
zstd: /I/do/not/exist: No such file or directory
Caught SIGSEGV signal, printing stack:
/lib/x86_64-linux-gnu/libc.so.6(setvbuf+0x11) [0x7f2051583fa1]
zstd(+0xeb977) [0x55a767eec977]
zstd(+0xf14fe) [0x55a767ef24fe]
zstd(+0xf579f) [0x55a767ef679f]
zstd(+0x61b0) [0x55a767e071b0]
/lib/x86_64-linux-gnu/libc.so.6(+0x2724a) [0x7f205153324a]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0x85) [0x7f2051533305]
zstd(+0x7f81) [0x55a767e08f81]
Segmentation fault

Expected behavior

An error message is printed and a non-zero exit code is returned.

Desktop (please complete the following information):

  • OS: Debian
  • Version: stable
$ zstd --version
*** Zstandard CLI (64-bit) v1.5.4, by Yann Collet ***

Additional context

$ dpkg-query --showformat='${Version}\n' --show zstd
1.5.4+dfsg2-5

Thanks for the report!

I'm pretty sure this was fixed by #3541. I can repro the crash you report on v1.5.4, but not on v1.5.5 or v1.5.6.

The best thing to do would be to upgrade, either locally or convince Debian to pull in v1.5.6, which is our current / stable release of Zstd.

(Feel free to re-open if you have any other questions.)